//
// LevelEditorLayer::objectsInRect from 0x1402d5ca0 to 0x1402d6176 (1238 bytes)
//
// 7 xrefs:
// > EditorUI::addObjectsToSmartTemplate @ 0x140116210
// > EditorUI::createSmartObjectsFromTemplate @ 0x140116fde
// > EditorUI::ccTouchEnded @ 0x140124e9f
// > LevelEditorLayer::rotationForSlopeNearObject @ 0x1402d4f18
// > ??> @ 0x14068e23c
// > ??> @ 0x14068e24c
// > ??> @ 0x1406d3080
//
// 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
//
cocos2d::CCArray *LevelEditorLayer::objectsInRect(LevelEditorLayer *a1, cocos2d::CCRect *a2, bool a3)
{
float v3; // xmm0_4
__int64 v7; // rbx
float v8; // xmm6_4
__int64 v9; // rcx
__int64 v10; // rax
float v11; // xmm1_4
cocos2d::CCArray *v12; // r12
float v13; // xmm3_4
float m_sectionXFactor; // xmm3_4
float v15; // xmm3_4
float v16; // xmm3_4
float v17; // xmm3_4
float v18; // xmm1_4
int v19; // r10d
float v20; // xmm3_4
float v21; // xmm3_4
std::_Vector_val *, std::allocator *>> *>>::pointer Mylast; // r8
std::_Vector_val *, std::allocator *>> *>>::pointer Myfirst; // r9
__int64 v24; // rcx
float v25; // xmm0_4
float v26; // xmm0_4
float v27; // xmm0_4
float y; // xmm1_4
float *p_m_sectionYFactor; // rax
int v30; // edx
float v31; // xmm3_4
float v32; // xmm3_4
float v33; // xmm3_4
float v34; // xmm3_4
float v35; // xmm3_4
float v36; // xmm1_4
int v37; // ecx
float v38; // xmm0_4
int v39; // r11d
__int64 v40; // r8
__int64 v41; // r9
std::_Simple_types *, std::allocator *>> *>::value_type v42; // rcx
__int64 v43; // rdx
int v44; // edx
__int64 v45; // r15
std::_Simple_types *>::value_type v46; // r14
std::_Vector_val>::pointer v47; // r9
__int64 v48; // rsi
__int64 v49; // rbp
cocos2d::CCRect *v50; // r15
std::_Simple_types::value_type v51; // rbx
int m_editorLayer2; // eax
int m_currentLayer; // ecx
int m_editorLayer; // r8d
bool v55; // dl
int v56; // ecx
int v57; // r8d
std::_Simple_types::value_type v58; // eax
std::_Simple_types::value_type v59; // eax
OBB2D *v60; // r8
bool X; // [rsp+20h] [rbp-88h]
__int64 v63; // [rsp+30h] [rbp-78h]
__int64 v64; // [rsp+38h] [rbp-70h]
__int64 v65; // [rsp+40h] [rbp-68h]
__int64 v66; // [rsp+48h] [rbp-60h]
cocos2d::CCRect v67; // [rsp+50h] [rbp-58h] BYREF
int v68; // [rsp+B0h] [rbp+8h] BYREF
cocos2d::CCRect *v69; // [rsp+B8h] [rbp+10h]
__int64 v70; // [rsp+C8h] [rbp+20h]
v69 = a2;
v7 = cocos2d::CCRect::CCRect(&v67, a2);
cocos2d::CCPoint::CCPoint(v3, *(float *)(v7 + 8) * 0.5);
cocos2d::CCPoint::operator+(v7, &v68);
v8 = 0.0;
OBB2D::calculateWithCenter(a1->m_obb2, (cocos2d::CCPoint)&v68, *(float *)(v7 + 8), *(float *)(v7 + 12), 0.0);
v10 = cocos2d::CCArray::create(v9);
v11 = a2->origin.x;
v12 = (cocos2d::CCArray *)v10;
if ( a2->origin.x > 0.0 )
{
m_sectionXFactor = a1->m_sectionXFactor;
if ( v11 < 10000000.0 )
v13 = v11 * m_sectionXFactor;
else
v13 = m_sectionXFactor * 10000000.0;
}
else
{
v13 = 0.0;
}
if ( (float)(v13 - 1.0) >= 0.0 )
{
if ( v11 > 0.0 )
{
v17 = a1->m_sectionXFactor;
if ( v11 < 10000000.0 )
v16 = v11 * v17;
else
v16 = v17 * 10000000.0;
}
else
{
v16 = 0.0;
}
v15 = v16 - 1.0;
}
else
{
v15 = 0.0;
}
v18 = v11 + a2->size.width;
v19 = (int)v15;
if ( v18 > 0.0 )
{
v21 = a1->m_sectionXFactor;
if ( v18 < 10000000.0 )
v20 = v18 * v21;
else
v20 = v21 * 10000000.0;
}
else
{
v20 = 0.0;
}
Mylast = a1->m_sections._Mypair._Myval2._Mylast;
Myfirst = a1->m_sections._Mypair._Myval2._Myfirst;
v24 = Mylast - Myfirst - 1;
if ( v24 < 0 )
v25 = (float)(v24 & 1 | (unsigned int)((unsigned __int64)v24 >> 1))
+ (float)(v24 & 1 | (unsigned int)((unsigned __int64)v24 >> 1));
else
v25 = (float)(int)v24;
if ( v25 > (float)(v20 + 1.0) )
{
if ( v18 > 0.0 )
{
v27 = a1->m_sectionXFactor;
if ( v18 < 10000000.0 )
v26 = v27 * v18;
else
v26 = v27 * 10000000.0;
}
else
{
v26 = 0.0;
}
v25 = v26 + 1.0;
}
y = a2->origin.y;
p_m_sectionYFactor = &a1->m_sectionYFactor;
v30 = (int)v25;
if ( y > 0.0 )
{
v32 = *p_m_sectionYFactor;
if ( y < 10000000.0 )
v31 = y * v32;
else
v31 = v32 * 10000000.0;
}
else
{
v31 = 0.0;
}
if ( (float)(v31 - 1.0) >= 0.0 )
{
if ( y > 0.0 )
{
v35 = *p_m_sectionYFactor;
if ( y < 10000000.0 )
v34 = y * v35;
else
v34 = v35 * 10000000.0;
}
else
{
v34 = 0.0;
}
v33 = v34 - 1.0;
}
else
{
v33 = 0.0;
}
v36 = y + a2->size.height;
v37 = (int)v33;
if ( v36 > 0.0 )
{
v38 = *p_m_sectionYFactor;
if ( v36 < 10000000.0 )
v8 = v36 * v38;
else
v8 = v38 * 10000000.0;
}
v39 = (int)(float)(v8 + 1.0);
v68 = v39;
if ( Myfirst != Mylast )
{
v40 = v19;
v63 = v19;
v66 = v30;
if ( v19 <= (__int64)v30 )
{
v41 = v37;
v65 = v37;
while ( 1 )
{
v42 = a1->m_sections._Mypair._Myval2._Myfirst[v40];
if ( v42 )
{
v43 = v42->_Mypair._Myval2._Mylast - v42->_Mypair._Myval2._Myfirst;
v44 = v39 >= (unsigned __int64)(v43 - 1) ? v43 - 1 : v39;
}
else
{
v44 = -1;
}
v45 = v41;
v70 = v41;
v64 = v44;
if ( v41 <= v44 )
break;
LABEL_89:
v63 = ++v40;
if ( v40 > v66 )
return v12;
}
while ( 1 )
{
v46 = a1->m_sections._Mypair._Myval2._Myfirst[v40]->_Mypair._Myval2._Myfirst[v45];
if ( v46 )
{
LOBYTE(v47) = 0;
v48 = 0;
v49 = a1->m_sectionSizes._Mypair._Myval2._Myfirst[v40]->_Mypair._Myval2._Myfirst[v45];
if ( v49 > 0 )
break;
}
LABEL_87:
v70 = ++v45;
if ( v45 > v64 )
{
v41 = v65;
v39 = v68;
goto LABEL_89;
}
}
v50 = v69;
while ( 1 )
{
v51 = v46->_Mypair._Myval2._Myfirst[v48];
if ( a3 )
goto LABEL_93;
m_editorLayer2 = v51->m_editorLayer2;
m_currentLayer = a1->m_currentLayer;
m_editorLayer = v51->m_editorLayer;
if ( !v51->m_editorLayer2 )
m_editorLayer2 = -1;
v55 = (_WORD)m_currentLayer == 0xFFFF || m_currentLayer == m_editorLayer || m_currentLayer == m_editorLayer2;
v56 = 9999;
if ( m_editorLayer < 9999 )
v56 = v51->m_editorLayer;
v57 = 9999;
if ( v56 < 0 )
v56 = 0;
if ( m_editorLayer2 < 9999 )
v57 = m_editorLayer2;
if ( v57 < -1 )
v57 = -1;
if ( !v55 )
goto LABEL_85;
v47 = a1->m_lockedLayers._Myvec._Mypair._Myval2._Myfirst;
v58 = v47[(unsigned __int64)(unsigned int)v56 >> 5];
if ( !_bittest((const int *)&v58, v56 & 0x1F) )
{
if ( v57 == -1 || (v59 = v47[(unsigned __int64)v57 >> 5], !_bittest((const int *)&v59, v57 & 0x1F)) )
{
LABEL_93:
LevelEditorLayer::getObjectRect(
(cocos2d::CCRect *)a1,
(LevelEditorLayer *)&v67,
v46->_Mypair._Myval2._Myfirst[v48],
(bool)v47,
X);
if ( a1->m_nonSquareRotation )
break;
if ( cocos2d::CCRect::intersectsRect(v50, &v67) )
goto LABEL_83;
if ( a1->m_nonSquareRotation )
break;
}
}
LABEL_84:
LOBYTE(v47) = 0;
LABEL_85:
if ( ++v48 >= v49 )
{
v45 = v70;
v40 = v63;
goto LABEL_87;
}
}
if ( !OBB2D::overlaps1Way(a1->m_currentOBB2D) || !OBB2D::overlaps1Way(v60) )
goto LABEL_84;
LABEL_83:
cocos2d::CCArray::addObject(v12, v51);
goto LABEL_84;
}
}
return v12;
}