//
// EditorUI::findSnapObject_1 from 0x1003f835c to 0x1003f8594 (568 bytes)
//
// 2 xrefs:
// > EditorUI::findSnapObject @ 0x1003f8314
// > EditorUI::findSnapObject @ 0x1003f8358
//
// 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
//
void __fastcall EditorUI::findSnapObject_1(EditorUI *a1, cocos2d::CCArray *a2, float a3)
{
unsigned int v6; // w21
float v7; // s9
GameObject *v8; // x23
EditorUI *v9; // x0
float v10; // s0
float v11; // s1
float v13; // s10
unsigned __int64 v14; // t2
GameObject *m_selectedObject; // x0
EditorUI *v16; // x0
unsigned __int64 v17; // t2
__int64 v18; // [xsp+8h] [xbp-78h] BYREF
float v19; // [xsp+10h] [xbp-70h] BYREF
float v20; // [xsp+14h] [xbp-6Ch]
__int64 v21; // [xsp+18h] [xbp-68h] BYREF
cocos2d::CCPoint v22; // 0:s0.4,4:s1.4
cocos2d::CCPoint v23; // 0:s0.4,4:s1.4
cocos2d::CCPoint v24; // 0:s0.4,4:s1.4
cocos2d::CCPoint v25; // 0:s0.4,4:s1.4
cocos2d::CCPoint v26; // 0:s2.4,4:s3.4
cocos2d::CCPoint v27; // 0:s2.4,4:s3.4
if ( a2 && (unsigned int)sub_10024A36C((__int64)a2) )
{
if ( (unsigned int)sub_10024A36C((__int64)a2) )
{
v6 = 0;
v7 = 999.0;
do
{
v8 = (GameObject *)sub_10024A388((__int64)a2, v6);
GameObject::updateStartPos(v8);
EditorUI::positionWithoutOffset(v9, v8);
v22.x = sub_1000229B8(&v18, (__int64 *)&dword_10086E8B0);
EditorUI::applySpecialOffset(a1, v22, (GameObject *)&v19, v26);
v23.x = sub_1000229B8(&v18, &v21);
EditorUI::getGridSnappedPos(a1, v23);
v10 = vabds_f32(v19, *(float *)&v21);
v11 = vabds_f32(v20, *((float *)&v21 + 1));
if ( a3 > 0.0 && (v10 > a3 || v11 > a3) )
goto LABEL_13;
v13 = v10 + v11;
if ( (float)(v10 + v11) < v7 )
{
a1->m_snapObject = v8;
HIDWORD(v14) = 47721858 - 1527099483 * (int)((float (__fastcall *)(GameObject *))v8->getRotation)(v8);
LODWORD(v14) = HIDWORD(v14);
if ( (unsigned int)(v14 >> 1) < 0x2D82D83 )
v7 = v13;
}
LABEL_13:
if ( v7 == 0.0 )
break;
++v6;
}
while ( v6 < (unsigned int)sub_10024A36C((__int64)a2) );
}
}
else
{
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject )
{
HIDWORD(v17) = -1527099483
* (int)((float (__fastcall *)(GameObject *))m_selectedObject->getRotation)(m_selectedObject)
+ 47721858;
LODWORD(v17) = HIDWORD(v17);
if ( (unsigned int)(v17 >> 1) <= 0x2D82D82 )
{
EditorUI::positionWithoutOffset(v16, a1->m_selectedObject);
v24.x = sub_1000229B8(&v18, (__int64 *)&dword_10086E8B0);
EditorUI::applySpecialOffset(a1, v24, (GameObject *)&v19, v27);
v25.x = sub_1000229B8(&v18, &v21);
EditorUI::getGridSnappedPos(a1, v25);
if ( a3 <= 0.0 || vabds_f32(v19, *(float *)&v21) <= a3 && vabds_f32(v20, *((float *)&v21 + 1)) <= a3 )
a1->m_snapObject = a1->m_selectedObject;
}
}
}
}