//
// GJBaseGameLayer::updateGroundShadows from 0x140311ef0 to 0x140312616 (1830 bytes)
//
// 4 xrefs:
// > GJBaseGameLayer::preUpdateVisibility @ 0x14033f562
// > ??> @ 0x1408b4960
// > ??> @ 0x1408b49ac
// > ??> @ 0x14091e80c
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:30:16 +0000
//
double __fastcall GJBaseGameLayer::updateGroundShadows(__int64 a1)
{
__int64 v2; // rax
const struct cocos2d::CCPoint *v3; // rax
__int64 v4; // rax
__int64 v5; // rbx
__int64 v6; // rax
float v7; // xmm6_4
__int64 v8; // rax
__int64 v9; // r8
__int64 v10; // r9
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
bool v15; // r10
bool v16; // r9
bool v17; // r8
double result; // xmm0_8
bool v19; // dl
int v20; // esi
int v21; // ecx
int v22; // r15d
__int64 v23; // rax
__int64 v24; // rax
int v25; // ecx
int v26; // ecx
float v27; // xmm2_4
unsigned int v28; // eax
__int64 v29; // rax
float v30; // xmm2_4
float v31; // xmm4_4
float v32; // xmm1_4
float v33; // xmm0_4
float v34; // [rsp+38h] [rbp-D0h] BYREF
float v35; // [rsp+40h] [rbp-C8h] BYREF
int v36; // [rsp+48h] [rbp-C0h] BYREF
float v37[2]; // [rsp+50h] [rbp-B8h] BYREF
_BYTE v38[8]; // [rsp+58h] [rbp-B0h] BYREF
int v39; // [rsp+60h] [rbp-A8h] BYREF
float v40; // [rsp+68h] [rbp-A0h] BYREF
float v41; // [rsp+6Ch] [rbp-9Ch]
float v42; // [rsp+70h] [rbp-98h] BYREF
float v43; // [rsp+74h] [rbp-94h]
float v44; // [rsp+78h] [rbp-90h] BYREF
float v45; // [rsp+7Ch] [rbp-8Ch]
float v46; // [rsp+80h] [rbp-88h] BYREF
float v47; // [rsp+84h] [rbp-84h]
float v48; // [rsp+88h] [rbp-80h] BYREF
float v49; // [rsp+90h] [rbp-78h] BYREF
float v50; // [rsp+98h] [rbp-70h] BYREF
float v51; // [rsp+A0h] [rbp-68h] BYREF
float v52; // [rsp+A8h] [rbp-60h] BYREF
float v53; // [rsp+B0h] [rbp-58h] BYREF
int v54; // [rsp+B8h] [rbp-50h] BYREF
float v55; // [rsp+C0h] [rbp-48h] BYREF
float v56; // [rsp+C4h] [rbp-44h]
float v57; // [rsp+C8h] [rbp-40h] BYREF
float v58; // [rsp+CCh] [rbp-3Ch]
float v59; // [rsp+D0h] [rbp-38h] BYREF
float v60; // [rsp+D4h] [rbp-34h]
float v61; // [rsp+D8h] [rbp-30h] BYREF
float v62; // [rsp+DCh] [rbp-2Ch]
v2 = cocos2d::CCDirector::sharedDirector(a1);
cocos2d::CCDirector::getWinSize(v2, v37);
v3 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 4336) + 200LL))(*(_QWORD *)(a1 + 4336));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v39, v3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v36, v37[0], 0.0);
v5 = v4;
v6 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 4336) + 200LL))(*(_QWORD *)(a1 + 4336));
cocos2d::CCPoint::operator+(v6, v38, v5);
v7 = *(float *)(a1 + 804) * 0.017453292;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v36, v37[0] * 0.5, v37[1] * 0.5);
OBB2D::calculateWithCenter(*(_QWORD *)(a1 + 13176), v8, v9, v10, v7);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v40,
(const struct cocos2d::CCPoint *)(*(_QWORD *)(a1 + 13176) + 320LL));
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v42,
(const struct cocos2d::CCPoint *)(*(_QWORD *)(a1 + 13176) + 328LL));
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v44,
(const struct cocos2d::CCPoint *)(*(_QWORD *)(a1 + 13176) + 336LL));
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v46,
(const struct cocos2d::CCPoint *)(*(_QWORD *)(a1 + 13176) + 344LL));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v55);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v57);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v59);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v61);
v11 = cocos2d::ccpIntersectPoint(&v36, &v40, &v42, &v39, v38);
cocos2d::CCPoint::operator=(&v55, v11);
v12 = cocos2d::ccpIntersectPoint(&v36, &v42, &v44, &v39, v38);
cocos2d::CCPoint::operator=(&v57, v12);
v13 = cocos2d::ccpIntersectPoint(&v36, &v44, &v46, &v39, v38);
cocos2d::CCPoint::operator=(&v59, v13);
v14 = cocos2d::ccpIntersectPoint(&v36, &v46, &v40, &v39, v38);
cocos2d::CCPoint::operator=(&v61, v14);
v15 = fminf(v40, v42) <= v55 && v55 <= fmaxf(v40, v42) && fminf(v41, v43) <= v56 && v56 <= fmaxf(v41, v43);
v16 = fminf(v42, v44) <= v57 && v57 <= fmaxf(v42, v44) && fminf(v43, v45) <= v58 && v58 <= fmaxf(v43, v45);
v17 = fminf(v44, v46) <= v59 && v59 <= fmaxf(v44, v46) && fminf(v45, v47) <= v60 && v60 <= fmaxf(v45, v47);
*(_QWORD *)&result = LODWORD(v46);
*(float *)&result = fminf(v46, v40);
v19 = false;
if ( *(float *)&result <= v61 && v61 <= fmaxf(v46, v40) )
{
*(_QWORD *)&result = LODWORD(v47);
*(float *)&result = fminf(v47, v41);
if ( *(float *)&result <= v62 && v62 <= fmaxf(v47, v41) )
v19 = true;
}
if ( v15 + v16 + v17 + v19 == 2 )
{
v20 = -1;
v21 = v15 - 1;
if ( v16 )
{
if ( v21 >= 0 )
v20 = 1;
else
v21 = 1;
}
if ( v17 )
{
if ( v21 < 0 )
{
v21 = 2;
}
else if ( v20 < 0 )
{
v20 = 2;
}
}
if ( v19 && v20 < 0 )
v20 = 3;
v22 = v21;
if ( *(&v55 + 2 * v21) <= *(&v55 + 2 * v20) )
{
v22 = v20;
v20 = v21;
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v36, 0.0, -128.0);
cocos2d::CCPoint::operator+(&v55 + 2 * v20, &v48, v23);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v36, 0.0, -128.0);
cocos2d::CCPoint::operator+(&v55 + 2 * v22, &v49, v24);
v25 = -3;
if ( v20 + 1 <= 3 )
v25 = 1;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v50,
(const struct cocos2d::CCPoint *)(*(_QWORD *)(a1 + 13176) + 320LL + 8LL * (v20 + v25)));
v26 = -2;
if ( v20 + 2 <= 3 )
v26 = 2;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v51,
(const struct cocos2d::CCPoint *)(*(_QWORD *)(a1 + 13176) + 320LL + 8LL * (v20 + v26)));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v34, (const struct cocos2d::CCPoint *)(&v55 + 2 * v20));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v35, (const struct cocos2d::CCPoint *)(&v55 + 2 * v22));
v27 = v34;
if ( v34 == 0.0 && v35 == 0.0 )
{
cocos2d::CCPoint::operator=(&v34, &v48);
cocos2d::CCPoint::operator=(&v35, &v49);
v27 = v34;
}
if ( v48 > fminf(v50, v51) && fmaxf(v50, v51) > v48 )
v34 = v27 - fabs(v48 - v50);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v52,
(const struct cocos2d::CCPoint *)(*(_QWORD *)(a1 + 13176) + 320LL + 8LL * v22));
v28 = v22 - 1;
if ( v22 - 1 < 0 )
v28 = 3;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v53,
(const struct cocos2d::CCPoint *)(*(_QWORD *)(a1 + 13176) + 320LL + 8LL * v28));
if ( v49 > fminf(v52, v53) && fmaxf(v52, v53) > v49 )
v35 = v35 + fabs(v49 - v52);
v29 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 4344) + 200LL))(*(_QWORD *)(a1 + 4344));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v54, v37[0] - v34, *(float *)(v29 + 4));
v30 = v35;
v31 = *(float *)(a1 + 424);
v32 = v34;
if ( (float)(v31 * 180.0) > (float)(v35 - v34) )
{
v33 = (float)((float)(v31 * 180.0) - (float)(v35 - v34)) * 0.5;
v32 = v34 - v33;
v30 = v35 + v33;
v34 = v34 - v33;
v35 = v35 + v33;
}
if ( v31 != 1.0 )
{
v34 = v32 * (float)(1.0 / v31);
v35 = v30 * (float)(1.0 / v31);
}
GJGroundLayer::updateShadowXPos(*(_QWORD *)(a1 + 4336));
return GJGroundLayer::updateShadowXPos(*(_QWORD *)(a1 + 4344));
}
return result;
}