//
// LevelEditorLayer::objectsInRect from 0x10035a8d0 to 0x10035ac30 (864 bytes)
//
// 4 xrefs:
// > LevelEditorLayer::rotationForSlopeNearObject @ 0x10035a79c
// > EditorUI::selectObjectsInRect @ 0x1003ede8c
// > EditorUI::addObjectsToSmartTemplate @ 0x1003f0f08
// > EditorUI::createSmartObjectsFromTemplate @ 0x1003f1838
//
// 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; // w2
char v4; // w19
float *v5; // x20
double v7; // d0
cocos2d::CCArray *v8; // x22
float v9; // s0
float m_sectionXFactor; // s1
float v11; // s1
int v12; // w8
float v13; // s1
float v14; // s0
float v15; // s0
float v16; // s2
std::__vector_base *, std::allocator *>> *, std::allocator *, std::allocator *>> *>>::pointer end; // x9
std::__vector_base *, std::allocator *>> *, std::allocator *, std::allocator *>> *>>::pointer begin; // x10
float v19; // s0
float v20; // s0
float v21; // s0
float v22; // s1
float m_sectionYFactor; // s2
float v24; // s2
float v25; // s2
float v26; // s1
float v27; // s1
__int64 v28; // x12
std::vector *, std::allocator *>> *v29; // x8
__int64 v30; // x9
int v31; // w8
__int64 v32; // x24
__int64 v33; // x28
std::vector *v34; // x26
__int64 v35; // x8
unsigned __int64 v36; // x25
__int64 v37; // x20
GameObject *v38; // x23
float v40; // s1
float v41; // s2
float v42; // s3
int v43; // [xsp+18h] [xbp-88h]
int v44; // [xsp+24h] [xbp-7Ch]
int v45; // [xsp+28h] [xbp-78h]
int v46; // [xsp+34h] [xbp-6Ch]
float *v47; // [xsp+38h] [xbp-68h]
float v48[4]; // [xsp+40h] [xbp-60h] BYREF
cocos2d::CCRect v49; // 0:kr10_16.16
v4 = v3;
v5 = (float *)a3;
v7 = sub_100022B98(v48, a3);
v49.origin.x = *(float *)&v7;
v49.origin.y = v40;
v49.size.width = v41;
v49.size.height = v42;
GJBaseGameLayer::updateOBB2(a1, v49);
v8 = (cocos2d::CCArray *)sub_10024A15C();
v47 = v5;
v9 = *v5;
if ( *v5 <= 0.0
|| ((m_sectionXFactor = a1->m_sectionXFactor, v9 >= 10000000.0)
? (v11 = m_sectionXFactor * 10000000.0)
: (v11 = v9 * m_sectionXFactor),
(float)(v11 + -1.0) <= 0.0) )
{
v12 = 0;
}
else
{
v12 = (int)(float)(v11 + -1.0);
}
v13 = v9 + v5[2];
v14 = 0.0;
if ( v13 > 0.0 )
{
v15 = a1->m_sectionXFactor;
if ( v13 >= 10000000.0 )
v14 = v15 * 10000000.0;
else
v14 = v13 * v15;
}
v16 = v14 + 1.0;
end = a1->m_sections.__end_;
begin = a1->m_sections.__begin_;
v19 = (float)(unsigned __int64)(end - begin - 1);
if ( v16 <= v19 )
{
v20 = 0.0;
if ( v13 > 0.0 )
{
v21 = a1->m_sectionXFactor;
if ( v13 >= 10000000.0 )
v20 = v21 * 10000000.0;
else
v20 = v13 * v21;
}
v19 = v20 + 1.0;
}
v22 = v5[1];
if ( v22 <= 0.0
|| ((m_sectionYFactor = a1->m_sectionYFactor, v22 >= 10000000.0)
? (v24 = m_sectionYFactor * 10000000.0)
: (v24 = v22 * m_sectionYFactor),
(float)(v24 + -1.0) <= 0.0) )
{
v45 = 0;
}
else
{
v45 = (int)(float)(v24 + -1.0);
}
v25 = v22 + v5[3];
v26 = 0.0;
if ( v25 > 0.0 )
{
v27 = a1->m_sectionYFactor;
if ( v25 >= 10000000.0 )
v26 = v27 * 10000000.0;
else
v26 = v25 * v27;
}
if ( begin != end && v12 <= (int)v19 )
{
v43 = (int)(float)(v26 + 1.0);
v28 = v12;
v44 = (int)v19 + 1;
while ( 1 )
{
v29 = a1->m_sections.__begin_[v28];
if ( v29 )
{
v30 = (char *)v29->__end_ - (char *)v29->__begin_;
v31 = v43;
if ( (v30 >> 3) - 1 < (unsigned __int64)v43 )
v31 = ((unsigned __int64)v30 >> 3) - 1;
}
else
{
v31 = -1;
}
if ( v45 <= v31 )
break;
LABEL_53:
if ( v44 == (_DWORD)++v28 )
return v8;
}
v46 = v31 + 1;
v32 = v45;
while ( 1 )
{
v33 = v28;
v34 = a1->m_sections.__begin_[v28]->__begin_[v32];
if ( v34 )
{
v35 = (unsigned int)a1->m_sectionSizes.__begin_[v28]->__begin_[v32];
if ( (int)v35 >= 1 )
break;
}
LABEL_52:
++v32;
v28 = v33;
if ( v46 == (_DWORD)v32 )
goto LABEL_53;
}
v36 = 0;
v37 = 8 * v35;
while ( 1 )
{
v38 = v34->__begin_[v36 / 8];
if ( (v4 & 1) == 0 && !LevelEditorLayer::validGroup(a1, v34->__begin_[v36 / 8], 1) )
goto LABEL_48;
LevelEditorLayer::getObjectRect(a1, v38, 0, 0);
if ( a1->m_nonSquareRotation )
goto LABEL_44;
if ( !sub_100022CB0(v47, v48) )
break;
LABEL_47:
sub_10024A2D0((__int64)v8);
LABEL_48:
v36 += 8LL;
if ( v37 == v36 )
goto LABEL_52;
}
if ( !a1->m_nonSquareRotation )
goto LABEL_48;
LABEL_44:
if ( !OBB2D::overlaps(a1->m_currentOBB2D) )
goto LABEL_48;
goto LABEL_47;
}
return v8;
}