//
// LevelEditorLayer::objectsInRect from 0x1000e0c70 to 0x1000e11ed (1405 bytes)
//
// 4 xrefs:
// > EditorUI::selectObjectsInRect @ 0x10003cb9b
// > EditorUI::addObjectsToSmartTemplate @ 0x100041fd8
// > EditorUI::createSmartObjectsFromTemplate @ 0x100042b90
// > LevelEditorLayer::rotationForSlopeNearObject @ 0x1000e0b45
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// local variable allocation has failed, the output may be wrong!
cocos2d::CCArray *__fastcall LevelEditorLayer::objectsInRect(LevelEditorLayer *a1, cocos2d::CCRect a2, bool a3)
{
char v3; // dl
char v4; // r12
float v6; // xmm0_4
int v7; // eax
float v8; // xmm2_4
float m_sectionXFactor; // xmm1_4
float v10; // xmm1_4
float v11; // xmm0_4
float v12; // xmm2_4
float v13; // xmm2_4
std::__vector_base *, std::allocator *>> *, std::allocator *, std::allocator *>> *>>::pointer begin; // rcx
std::__vector_base *, std::allocator *>> *, std::allocator *, std::allocator *>> *>>::pointer end; // rdx
__int64 v16; // rsi
float v17; // xmm1_4
float v18; // xmm1_4
float v19; // xmm1_4
float v20; // xmm2_4
float v21; // xmm0_4
float m_sectionYFactor; // xmm3_4
float v23; // xmm3_4
float v24; // xmm2_4
float v25; // xmm0_4
__int64 v26; // r10
std::vector *, std::allocator *>> *v27; // rcx
__int64 v28; // rax
int v29; // edx
__int64 v30; // rcx
std::__vector_base *, std::allocator *>>::pointer v31; // rax
std::vector *v32; // rbx
__int64 v33; // r12
__int64 v34; // r15
GameObject *v35; // r13
bool m_nonSquareRotation; // al
std::vector *, std::allocator *>> *v37; // rcx
__int64 v38; // rax
int v39; // edx
__int64 v40; // r11
std::vector *v41; // r15
__int64 v42; // rbx
__int64 v43; // r12
std::__vector_base::pointer v44; // rsi
__int64 v45; // rdi
GameObject *v46; // r13
unsigned __int64 m_editorLayer; // rcx
int v48; // eax
__int16 m_currentLayer; // dx
bool v50; // si
bool v51; // di
bool v52; // r8
unsigned __int16 v53; // dx
__int64 v54; // rcx
bool v55; // al
double v57; // xmm0_8
double v58; // xmm0_8
_BYTE v59[16]; // [rsp+0h] [rbp-80h] BYREF
unsigned __int64 v60; // [rsp+10h] [rbp-70h]
__int64 v61; // [rsp+18h] [rbp-68h]
cocos2d::CCArray *v62; // [rsp+20h] [rbp-60h]
__int64 v63; // [rsp+28h] [rbp-58h]
__int64 v64; // [rsp+30h] [rbp-50h]
int v65; // [rsp+3Ch] [rbp-44h]
_BOOL8 v66; // [rsp+40h] [rbp-40h]
int v67; // [rsp+4Ch] [rbp-34h]
int v68; // [rsp+50h] [rbp-30h]
int v69; // [rsp+54h] [rbp-2Ch]
v4 = v3;
*(double *)&a2.origin = sub_10028D180(v59);
GJBaseGameLayer::updateOBB2(a1, a2);
v62 = (cocos2d::CCArray *)sub_10071F9E0(a1, v59);
v66 = a3;
v6 = *(float *)a3;
v7 = 0;
v8 = 0.0;
if ( *(float *)a3 > 0.0 )
{
m_sectionXFactor = a1->m_sectionXFactor;
v10 = v6 >= 10000000.0 ? m_sectionXFactor * 10000000.0 : m_sectionXFactor * v6;
if ( (float)(v10 + -1.0) > 0.0 )
v7 = (int)(float)(v10 + -1.0);
}
v11 = v6 + *(float *)(v66 + 8);
if ( v11 > 0.0 )
{
v12 = a1->m_sectionXFactor;
if ( v11 >= 10000000.0 )
v8 = v12 * 10000000.0;
else
v8 = v12 * v11;
}
v13 = v8 + 1.0;
begin = a1->m_sections.__begin_;
end = a1->m_sections.__end_;
v16 = end - begin - 1;
if ( v16 < 0 )
{
v17 = (float)(int)(((unsigned __int64)v16 >> 1) | v16 & 1) + (float)(int)(((unsigned __int64)v16 >> 1) | v16 & 1);
if ( v13 > v17 )
goto LABEL_20;
}
else
{
v17 = (float)(int)v16;
if ( v13 > (float)(int)v16 )
goto LABEL_20;
}
v18 = 0.0;
if ( v11 > 0.0 )
{
v19 = a1->m_sectionXFactor;
if ( v11 >= 10000000.0 )
v18 = v19 * 10000000.0;
else
v18 = v19 * v11;
}
v17 = v18 + 1.0;
LABEL_20:
v20 = *(float *)(v66 + 4);
v69 = 0;
v21 = 0.0;
if ( v20 > 0.0 )
{
m_sectionYFactor = a1->m_sectionYFactor;
v23 = v20 >= 10000000.0 ? m_sectionYFactor * 10000000.0 : m_sectionYFactor * v20;
if ( (float)(v23 + -1.0) > 0.0 )
v69 = (int)(float)(v23 + -1.0);
}
v24 = v20 + *(float *)(v66 + 12);
if ( v24 <= 0.0 )
{
LABEL_29:
if ( begin == end )
return v62;
goto LABEL_30;
}
v25 = a1->m_sectionYFactor;
if ( v24 < 10000000.0 )
{
v21 = v25 * v24;
goto LABEL_29;
}
v21 = v25 * 10000000.0;
if ( begin == end )
return v62;
LABEL_30:
v68 = (int)v17;
if ( v7 <= (int)v17 )
{
v65 = (int)(float)(v21 + 1.0);
v60 = v65;
v61 = v69;
v26 = v7;
++v68;
if ( v4 )
{
while ( 1 )
{
v27 = a1->m_sections.__begin_[v26];
if ( v27 )
{
v28 = v27->__end_ - v27->__begin_;
v29 = v65;
if ( v28 - 1 < v60 )
v29 = v28 - 1;
if ( v69 <= v29 )
{
LABEL_40:
v30 = v61;
v63 = v26;
v67 = v29 + 1;
while ( 1 )
{
v31 = a1->m_sections.__begin_[v26]->__begin_;
v64 = v30;
v32 = v31[v30];
if ( v32 )
{
v33 = a1->m_sectionSizes.__begin_[v63]->__begin_[v64];
if ( v33 > 0 )
break;
}
LABEL_41:
v30 = v64 + 1;
v26 = v63;
if ( v67 == (_DWORD)v64 + 1 )
goto LABEL_33;
}
v34 = 0;
while ( 2 )
{
v35 = v32->__begin_[v34];
*(_QWORD *)&v57 = (unsigned __int64)LevelEditorLayer::getObjectRect(
(LevelEditorLayer *)v59,
(GameObject *)a1,
(bool)v35,
0).origin;
m_nonSquareRotation = a1->m_nonSquareRotation;
if ( m_nonSquareRotation )
{
LABEL_50:
if ( m_nonSquareRotation && OBB2D::overlaps(a1->m_currentOBB2D) )
goto LABEL_45;
}
else
{
if ( !(unsigned __int8)sub_10028D320(v66, v59, v57) )
{
m_nonSquareRotation = a1->m_nonSquareRotation;
goto LABEL_50;
}
LABEL_45:
sub_10071FCD0(v62, v35);
}
if ( v33 == ++v34 )
goto LABEL_41;
continue;
}
}
}
else
{
v29 = -1;
if ( v69 <= -1 )
goto LABEL_40;
}
LABEL_33:
if ( v68 == (_DWORD)++v26 )
return v62;
}
}
do
{
v37 = a1->m_sections.__begin_[v26];
if ( v37 )
{
v38 = v37->__end_ - v37->__begin_;
v39 = v65;
if ( v38 - 1 < v60 )
v39 = v38 - 1;
if ( v69 <= v39 )
{
LABEL_60:
v40 = v61;
v63 = v26;
v67 = v39 + 1;
while ( 1 )
{
v41 = a1->m_sections.__begin_[v26]->__begin_[v40];
if ( v41 )
{
v42 = a1->m_sectionSizes.__begin_[v26]->__begin_[v40];
if ( v42 > 0 )
break;
}
LABEL_61:
if ( v67 == (_DWORD)++v40 )
goto LABEL_53;
}
v43 = 0;
v64 = v40;
while ( 2 )
{
v46 = v41->__begin_[v43];
m_editorLayer = (unsigned __int16)v46->m_editorLayer;
v48 = (unsigned __int16)*(_DWORD *)&v46->m_editorLayer2 == 0 ? -1 : *(_DWORD *)&v46->m_editorLayer2;
m_currentLayer = a1->m_currentLayer;
v50 = m_currentLayer == -1;
v51 = m_currentLayer == (__int16)m_editorLayer;
v52 = m_currentLayer == (__int16)((unsigned __int16)*(_DWORD *)&v46->m_editorLayer2 == 0
? -1
: v46->m_editorLayer2);
v53 = v48;
if ( (__int16)((unsigned __int16)*(_DWORD *)&v46->m_editorLayer2 == 0 ? -1 : v46->m_editorLayer2) < 9999 )
{
if ( (v48 & 0x8000u) == 0 )
goto LABEL_69;
v53 = -1;
if ( v52 || v51 || v50 )
goto LABEL_73;
LABEL_66:
if ( v42 == ++v43 )
goto LABEL_61;
continue;
}
break;
}
v53 = 9999;
LABEL_69:
if ( !v52 && !v51 && !v50 )
goto LABEL_66;
LABEL_73:
if ( (__int16)m_editorLayer >= 9999 )
m_editorLayer = 9999;
if ( (__int16)m_editorLayer <= 0 )
m_editorLayer = 0;
v44 = a1->m_lockedLayers.__begin_;
v45 = *(_QWORD *)&v44[((unsigned int)m_editorLayer >> 3) & 0x7F8];
if ( _bittest64(&v45, m_editorLayer) )
goto LABEL_66;
if ( (v48 & 0x8000u) == 0 )
{
v54 = *(_QWORD *)&v44[8 * ((unsigned __int64)v53 >> 6)];
if ( _bittest64(&v54, v53) )
goto LABEL_66;
}
*(_QWORD *)&v58 = (unsigned __int64)LevelEditorLayer::getObjectRect(
(LevelEditorLayer *)v59,
(GameObject *)a1,
(bool)v41->__begin_[v43],
0).origin;
v55 = a1->m_nonSquareRotation;
if ( v55 )
{
LABEL_82:
if ( v55 && OBB2D::overlaps(a1->m_currentOBB2D) )
goto LABEL_84;
}
else
{
if ( !(unsigned __int8)sub_10028D320(v66, v59, v58) )
{
v55 = a1->m_nonSquareRotation;
goto LABEL_82;
}
LABEL_84:
sub_10071FCD0(v62, v46);
}
v26 = v63;
v40 = v64;
goto LABEL_66;
}
}
else
{
v39 = -1;
if ( v69 <= -1 )
goto LABEL_60;
}
LABEL_53:
++v26;
}
while ( v68 != (_DWORD)v26 );
}
return v62;
}