//
// GJBaseGameLayer::updateDebugDraw from 0x100121920 to 0x100122358 (2616 bytes)
//
// 3 xrefs:
// > LevelEditorLayer::updateDebugDraw @ 0x1000fe577
// > ??> @ 0x1008b7350
// > ??> @ 0x1008c18d0
//
// 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 GJBaseGameLayer::updateDebugDraw(GJBaseGameLayer *a1)
{
GJBaseGameLayer *v1; // r12
cocos2d::CCDirector *v2; // rsi
std::vector *, std::allocator *>> **begin; // rcx
__int64 v4; // rdx
bool m_isEditor; // cl
__int64 m_leftSectionIndex; // rsi
int m_rightSectionIndex; // eax
__int64 v8; // rdi
std::vector *, std::allocator *>> *v9; // rcx
int m_topSectionIndex; // ecx
std::vector *v11; // r15
__int64 v12; // r14
__int64 v13; // rbx
GameObject *v14; // r13
GameObjectType m_objectType; // eax
cocos2d::CCDrawNode *m_debugDrawNode; // r14
const cocos2d::CCPoint *v17; // r15
float ObjectRadius; // xmm0_4
unsigned int v19; // r8d
char *v20; // r14
__m128 v21; // xmm0
bool m_isObjectRectDirty; // r12
__int64 v23; // rsi
double v24; // xmm0_8
cocos2d::CCDrawNode *v25; // r14
__int64 v26; // rsi
cocos2d::CCDrawNode *v27; // rdi
cocos2d::CCDrawNode *v28; // rdi
PlayerObject *m_player1; // rdi
cocos2d::CCDrawNode *v30; // r14
PlayerObject_vtbl *v31; // rax
__int64 v32; // rax
__int64 v33; // rsi
PlayerObject *m_player2; // rdi
cocos2d::CCDrawNode *v35; // r14
PlayerObject_vtbl *v36; // rax
__int64 v37; // rax
cocos2d::CCDrawNode *v38; // rdi
__int64 v39; // rax
cocos2d::CCDrawNode *v40; // rdi
__int64 v41; // rsi
__int128 v42; // [rsp+0h] [rbp-F0h]
cocos2d::CCRect v43; // [rsp+10h] [rbp-E0h] BYREF
__int64 v44; // [rsp+20h] [rbp-D0h]
__int64 v45; // [rsp+28h] [rbp-C8h]
__int64 v46; // [rsp+30h] [rbp-C0h]
__int64 v47; // [rsp+38h] [rbp-B8h]
float v48[2]; // [rsp+40h] [rbp-B0h] BYREF
_DWORD v49[2]; // [rsp+48h] [rbp-A8h] BYREF
char v50[8]; // [rsp+50h] [rbp-A0h] BYREF
__int64 v51; // [rsp+58h] [rbp-98h]
std::vector *v52; // [rsp+60h] [rbp-90h]
char v53[8]; // [rsp+68h] [rbp-88h] BYREF
__int128 v54; // [rsp+70h] [rbp-80h] BYREF
GJBaseGameLayer *v55; // [rsp+88h] [rbp-68h]
__int128 v56; // [rsp+90h] [rbp-60h] BYREF
char *v57; // [rsp+A8h] [rbp-48h]
cocos2d::ccColor4F v58; // [rsp+B0h] [rbp-40h] BYREF
float v59; // [rsp+C4h] [rbp-2Ch]
double v60; // 0:xmm0_8.8
v1 = a1;
cocos2d::CCDrawNode::clear(a1->m_debugDrawNode);
v2 = cocos2d::CCDirector::sharedDirector();
*(cocos2d::CCSize *)&v60 = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)v48);
LODWORD(v57) = ((float (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCDirector *, double))v1->m_objectLayer->getScale)(
v1->m_objectLayer,
v2,
v60);
((void (__fastcall *)(cocos2d::CCLayer *))v1->m_objectLayer->getPosition)(v1->m_objectLayer);
sub_10028CC60(v49);
sub_10028CD40(&v43, v49, 1.0 / *(float *)&v57);
sub_10028CC90();
sub_10028CD20(&v43, v49);
sub_10028CC90();
sub_10028CC00(
&v43,
COERCE_DOUBLE((unsigned __int64)v49[0]),
COERCE_DOUBLE((unsigned __int64)v49[1]),
v48[0] / *(float *)&v57,
v48[1] / *(float *)&v57);
cocos2d::CCDrawNode::enableDrawArea(a1->m_debugDrawNode, &v43);
begin = a1->m_sections.__begin_;
v4 = 0xFFFFFFFFLL;
if ( a1->m_sections.__end_ != begin )
v4 = (unsigned int)((unsigned __int64)((char *)a1->m_sections.__end_ - (char *)begin) >> 3);
m_isEditor = a1->m_isEditor;
if ( !m_isEditor || a1->m_isDebugDrawEnabled )
{
v59 = 0.25 / *(float *)&v57;
m_leftSectionIndex = (unsigned int)a1->m_leftSectionIndex;
m_rightSectionIndex = a1->m_rightSectionIndex;
if ( (int)m_leftSectionIndex <= m_rightSectionIndex && (int)m_leftSectionIndex < (int)v4 )
{
v8 = (int)m_leftSectionIndex;
v47 = (int)v4;
v42 = (__int128)_mm_unpacklo_pd((__m128d)0x3F800000u, (__m128d)xmmword_1008150D0);
v55 = v1;
while ( 1 )
{
v9 = v1->m_sections.__begin_[v8];
if ( v9 )
{
v4 = (unsigned __int64)((char *)v9->__end_ - (char *)v9->__begin_) >> 3;
m_leftSectionIndex = (unsigned int)v1->m_bottomSectionIndex;
m_topSectionIndex = v1->m_topSectionIndex;
if ( (int)m_leftSectionIndex > m_topSectionIndex )
goto LABEL_57;
}
else
{
v4 = 0xFFFFFFFFLL;
m_leftSectionIndex = (unsigned int)v1->m_bottomSectionIndex;
m_topSectionIndex = v1->m_topSectionIndex;
if ( (int)m_leftSectionIndex > m_topSectionIndex )
goto LABEL_57;
}
if ( (int)m_leftSectionIndex < (int)v4 )
{
m_leftSectionIndex = (int)m_leftSectionIndex;
v4 = (int)v4;
v45 = v8;
v46 = (int)v4;
while ( 1 )
{
v11 = v1->m_sections.__begin_[v8]->__begin_[m_leftSectionIndex];
if ( v11 )
{
v12 = v1->m_sectionSizes.__begin_[v8]->__begin_[m_leftSectionIndex];
if ( v12 > 0 )
break;
}
LABEL_54:
if ( m_leftSectionIndex < m_topSectionIndex && ++m_leftSectionIndex < v4 )
continue;
m_rightSectionIndex = v1->m_rightSectionIndex;
goto LABEL_57;
}
v44 = m_leftSectionIndex;
v13 = 0;
v52 = v11;
v51 = v12;
while ( 2 )
{
v14 = v11->__begin_[v13];
if ( !v14->m_isActivated && !v1->m_isEditor )
goto LABEL_19;
m_objectType = v14->m_objectType;
if ( m_objectType == Decoration || v1->m_playbackMode && v14->m_isGroupDisabled )
goto LABEL_19;
if ( v14->m_objectRadius > 0.0 )
{
if ( m_objectType == Hazard )
{
m_debugDrawNode = v1->m_debugDrawNode;
v17 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(GameObject *))v14->getPosition)(v11->__begin_[v13]);
LODWORD(v57) = GameObject::getObjectRadius(v14);
v58 = 0;
v56 = v42;
ObjectRadius = GameObject::getObjectRadius(v14);
v19 = 8;
if ( ObjectRadius > 8.0 )
v19 = (int)GameObject::getObjectRadius(v14);
cocos2d::CCDrawNode::drawCircle(
m_debugDrawNode,
v17,
*(float *)&v57,
&v58,
v59,
(const cocos2d::ccColor4F *)&v56,
v19);
v11 = v52;
goto LABEL_18;
}
goto LABEL_19;
}
if ( ((unsigned int (__fastcall *)(GameObject *))v14->getType)(v11->__begin_[v13]) == 25 )
{
((void (__fastcall *)(GameObject *))v14->getObjectRect)(v14);
sub_10028D180(&v58);
GameObject::determineSlopeDirection(v14);
v20 = (char *)operator new[](0x18u);
sub_10028CC30(v20);
v57 = v20 + 8;
sub_10028CC30(v20 + 8);
sub_10028CC30(v20 + 16);
sub_10028CBE0(&v56, v58.r, v58.g);
sub_10028CC90();
sub_10028CBE0(&v56, v58.r, v58.g + v58.a);
sub_10028CC90();
sub_10028CBE0(&v56, v58.r + v58.b, v58.g);
sub_10028CC90();
sub_10028CBE0(v53, v58.r + v58.b, v58.g + v58.a);
switch ( v14->m_slopeDirection )
{
case 0:
case 7:
goto LABEL_44;
case 1:
case 5:
v57 = v20;
goto LABEL_44;
case 3:
case 6:
v57 = v20 + 16;
LABEL_44:
sub_10028CC90();
break;
default:
break;
}
v56 = xmmword_100816910;
v11 = v52;
if ( v14->m_isGripSlope )
_mm_storel_ps((double *)&v56, (__m128)0x3F800000u);
v1 = v55;
v28 = v55->m_debugDrawNode;
v54 = 0;
cocos2d::CCDrawNode::drawPolygon(
v28,
v20,
3,
&v54,
&v56,
0,
COERCE_DOUBLE((unsigned __int64)LODWORD(v59)));
operator delete[](v20);
LABEL_18:
v12 = v51;
LABEL_19:
if ( v12 == ++v13 )
{
m_topSectionIndex = v1->m_topSectionIndex;
v8 = v45;
m_leftSectionIndex = v44;
v4 = v46;
goto LABEL_54;
}
continue;
}
break;
}
v58 = (cocos2d::ccColor4F)xmmword_100816910;
if ( ((unsigned int (__fastcall *)(GameObject *))v14->getType)(v14) == 2
|| ((unsigned int (__fastcall *)(GameObject *))v14->getType)(v14) == 47 )
{
_mm_storel_ps((double *)&v58.r, (__m128)0x3F800000u);
v21 = (__m128)0x3F80000000000000uLL;
goto LABEL_35;
}
if ( ((unsigned int (__fastcall *)(GameObject *))v14->getType)(v14) )
{
if ( !v14->m_greenDebugDraw )
goto LABEL_19;
v21 = (__m128)0x3F80000000000000uLL;
_mm_storel_ps((double *)&v58.r, (__m128)0x3F80000000000000uLL);
LABEL_35:
_mm_storel_ps((double *)&v58.b, v21);
}
else if ( v14->m_isPassable )
{
*(_QWORD *)&v58.r = 0x3F80000000000000LL;
v21 = (__m128)xmmword_1008154E0;
goto LABEL_35;
}
if ( v14 != v1->m_anticheatSpike )
{
LOBYTE(v57) = v14->m_boxOffsetCalculated;
m_isObjectRectDirty = v14->m_isObjectRectDirty;
v23 = ((__int64 (__fastcall *)(GameObject *))v14->getObjectRect)(v14);
v24 = sub_10028D180(&v56);
if ( __ROR4__(
-1527099483
* (int)((float (__fastcall *)(GameObject *, __int64, double))v14->getRotation)(v14, v23, v24)
+ 47721858,
1) >= 0x2D82D83u
&& (v55->m_isEditor || v14->m_shouldUseOuterOb) )
{
GameObject::calculateOrientedBox(v14);
v25 = v55->m_debugDrawNode;
v26 = ((__int64 (__fastcall *)(GameObject *))v14->getOrientedBox)(v14) + 316;
v54 = 0;
cocos2d::CCDrawNode::drawPolygon(
v25,
v26,
4,
&v54,
&v58,
0,
COERCE_DOUBLE((unsigned __int64)LODWORD(v59)));
}
else
{
sub_10028CC60(v53);
sub_10028CBE0(v50, *(float *)&v56 + *((float *)&v56 + 2), *((float *)&v56 + 1) + *((float *)&v56 + 3));
v27 = v55->m_debugDrawNode;
v54 = 0;
v11 = v52;
cocos2d::CCDrawNode::drawRect(v27, v53, v50, &v54, &v58, 0, v59);
}
v14->m_isObjectRectDirty = m_isObjectRectDirty;
v14->m_boxOffsetCalculated = (char)v57;
v1 = v55;
goto LABEL_18;
}
goto LABEL_19;
}
LABEL_57:
if ( v8 < m_rightSectionIndex && ++v8 < v47 )
continue;
m_isEditor = v1->m_isEditor;
break;
}
}
if ( !m_isEditor && (!v1->m_disablePlayerHitbox || v1->m_hitboxesOnDeath && v1->m_playerDied) )
{
((void (__fastcall *)(PlayerObject *, __int64, __int64))v1->m_player1->updateOrientedBox)(
v1->m_player1,
m_leftSectionIndex,
v4);
m_player1 = v1->m_player1;
v30 = v1->m_debugDrawNode;
v31 = m_player1->GameObject::CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( m_player1->m_isBall )
{
v32 = ((__int64 (*)(void))v31->getObjectRect)();
v58 = 0;
v56 = xmmword_100816920;
cocos2d::CCDrawNode::drawRect_1(v30, v32, &v58, &v56, 0, v59);
if ( !v1->m_gameState.m_isDualMode )
goto LABEL_70;
}
else
{
v33 = ((__int64 (*)(void))v31->getOrientedBox)() + 316;
v58 = 0;
v56 = xmmword_100816920;
cocos2d::CCDrawNode::drawPolygon(v30, v33, 4, &v58, &v56, 0, COERCE_DOUBLE((unsigned __int64)LODWORD(v59)));
if ( !v1->m_gameState.m_isDualMode )
goto LABEL_70;
}
((void (__fastcall *)(PlayerObject *))v1->m_player2->updateOrientedBox)(v1->m_player2);
m_player2 = v1->m_player2;
v35 = v1->m_debugDrawNode;
v36 = m_player2->GameObject::CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( !m_player2->m_isBall )
{
v41 = ((__int64 (*)(void))v36->getOrientedBox)() + 316;
v58 = 0;
v56 = xmmword_100816920;
cocos2d::CCDrawNode::drawPolygon(v35, v41, 4, &v58, &v56, 0, COERCE_DOUBLE((unsigned __int64)LODWORD(v59)));
if ( !v1->m_hitboxesOnDeath )
return;
goto LABEL_71;
}
v37 = ((__int64 (*)(void))v36->getObjectRect)();
v58 = 0;
v56 = xmmword_100816920;
cocos2d::CCDrawNode::drawRect_1(v35, v37, &v58, &v56, 0, v59);
LABEL_70:
if ( !v1->m_hitboxesOnDeath )
return;
LABEL_71:
if ( v1->m_playerDied )
{
((void (__fastcall *)(PlayerObject *))v1->m_player1->getObjectRect)(v1->m_player1);
sub_10028D180(&v58);
sub_10028CC60(v53);
sub_10028CBE0(v50, v58.r + v58.b, v58.g + v58.a);
v38 = v1->m_debugDrawNode;
v56 = 0;
v54 = xmmword_100816930;
cocos2d::CCDrawNode::drawRect(v38, v53, v50, &v56, &v54, 0, v59);
if ( v1->m_gameState.m_isDualMode )
{
v39 = ((__int64 (__fastcall *)(PlayerObject *))v1->m_player2->getObjectRect)(v1->m_player2);
sub_10028D1A0(&v58, v39);
sub_10028CC90();
sub_10028CBE0(&v56, v58.r + v58.b, v58.g + v58.a);
sub_10028CC90();
v40 = v1->m_debugDrawNode;
v56 = 0;
v54 = xmmword_100816930;
cocos2d::CCDrawNode::drawRect(v40, v53, v50, &v56, &v54, 0, v59);
}
}
}
}
}