//
// cocos2d::CCGrid3D::calculateVertexPoints from 0x180022850 to 0x180022e2e (1502 bytes)
//
// 5 xrefs:
// > ??> @ 0x1800e7288
// > ??> @ 0x180133fc8
// > ??> @ 0x180134014
// > ??> @ 0x1801438a8
// > ??> @ 0x1801aef8c
//
// 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 cocos2d::CCGrid3D::calculateVertexPoints(cocos2d::CCGrid3D *this)
{
float v2; // xmm9_4
float v3; // xmm6_4
const struct cocos2d::CCSize *ContentSizeInPixels; // rax
void *v5; // rcx
float height; // xmm7_4
void *v7; // rcx
void *v8; // rcx
void *v9; // rcx
__int64 v10; // rdi
void *v11; // rax
float v12; // xmm0_4
unsigned __int64 v13; // rax
float v14; // xmm0_4
_WORD *v15; // rax
float width; // xmm1_4
int v17; // r13d
__int64 v18; // rdi
__int64 v19; // rsi
float v20; // xmm15_4
float v21; // xmm4_4
int v22; // eax
float v23; // xmm1_4
float v24; // xmm4_4
float v25; // xmm1_4
float v26; // xmm12_4
float v27; // xmm14_4
float v28; // xmm13_4
float v29; // xmm11_4
float v30; // xmm10_4
int v31; // r10d
int v32; // ebx
int v33; // edx
__int64 v34; // rax
int v35; // r8d
__int64 v36; // r14
__int64 v37; // r15
__int64 v38; // r12
__int64 v39; // rax
__int64 v40; // rcx
float v41; // xmm0_4
float v42; // xmm0_4
float v43; // xmm0_4
float v44; // xmm0_4
unsigned __int64 v45; // rax
float v46; // xmm0_4
unsigned int v47; // [rsp+20h] [rbp-118h]
unsigned int v48; // [rsp+24h] [rbp-114h]
int v49; // [rsp+28h] [rbp-110h]
int v50; // [rsp+30h] [rbp-108h]
_WORD *v51; // [rsp+38h] [rbp-100h]
float v52; // [rsp+40h] [rbp-F8h] BYREF
float v53; // [rsp+44h] [rbp-F4h]
float v54; // [rsp+48h] [rbp-F0h] BYREF
float v55; // [rsp+4Ch] [rbp-ECh]
float v56; // [rsp+50h] [rbp-E8h] BYREF
float v57; // [rsp+54h] [rbp-E4h]
float v58; // [rsp+58h] [rbp-E0h] BYREF
float v59; // [rsp+5Ch] [rbp-DCh]
v2 = (float)((int (__fastcall *)(cocos2d::CCTexture2D *))this->m_pTexture->getPixelsWide)(this->m_pTexture);
v3 = (float)((int (__fastcall *)(cocos2d::CCTexture2D *))this->m_pTexture->getPixelsHigh)(this->m_pTexture);
ContentSizeInPixels = cocos2d::CCTexture2D::getContentSizeInPixels(this->m_pTexture);
v5 = *((void **)this + 16);
height = ContentSizeInPixels->height;
if ( v5 )
{
free(v5);
*((_QWORD *)this + 16) = 0;
}
v7 = *((void **)this + 17);
if ( v7 )
{
free(v7);
*((_QWORD *)this + 17) = 0;
}
v8 = *((void **)this + 15);
if ( v8 )
{
free(v8);
*((_QWORD *)this + 15) = 0;
}
v9 = *((void **)this + 18);
if ( v9 )
{
free(v9);
*((_QWORD *)this + 18) = 0;
}
v10 = (unsigned int)(int)(float)((float)(this->m_sGridSize.height + 1.0) * (float)(this->m_sGridSize.width + 1.0));
*((_QWORD *)this + 16) = malloc(12 * v10);
*((_QWORD *)this + 17) = malloc(12 * v10);
v11 = malloc(8 * v10);
v12 = this->m_sGridSize.height * this->m_sGridSize.width;
*((_QWORD *)this + 15) = v11;
v13 = 0;
v14 = (float)(v12 + v12) * 6.0;
if ( v14 >= 9.223372e18 )
{
v14 = v14 - 9.223372e18;
if ( v14 < 9.223372e18 )
v13 = 0x8000000000000000uLL;
}
v15 = malloc(v13 + (unsigned int)(int)v14);
width = this->m_sGridSize.width;
v17 = 0;
v18 = *((_QWORD *)this + 16);
v19 = *((_QWORD *)this + 15);
v51 = v15;
*((_QWORD *)this + 18) = v15;
if ( width > 0.0 )
{
v20 = 0.0;
do
{
v21 = this->m_sGridSize.height;
v22 = 0;
++v17;
if ( v21 > 0.0 )
{
v23 = (float)v17;
do
{
v24 = v21 + 1.0;
v50 = v22 + 1;
v25 = v23 * v24;
v26 = this->m_obStep.y * (float)v22;
v27 = (float)(v22 + 1);
v28 = this->m_obStep.x * v20;
v29 = this->m_obStep.y + v26;
v30 = this->m_obStep.x + v28;
v31 = (int)(float)((float)v22 + (float)(v20 * v24));
v32 = (unsigned __int16)v31;
v33 = (int)(float)((float)v22 + v25);
v34 = 6 * (int)(float)((float)((float)v22 * this->m_sGridSize.width) + v20);
v35 = (int)(float)(v27 + (float)(v20 * v24));
v51[v34] = v31;
v51[v34 + 1] = v33;
v51[v34 + 2] = v35;
v51[v34 + 3] = v33;
v36 = 2 * (unsigned int)(unsigned __int16)v33;
v51[v34 + 4] = (int)(float)(v27 + v25);
v51[v34 + 5] = v35;
v47 = 3 * (unsigned __int16)v33;
v48 = 3 * (unsigned __int16)(int)(float)(v27 + v25);
v37 = 2 * (unsigned int)(unsigned __int16)(int)(float)(v27 + v25);
v49 = 3 * (unsigned __int16)v35;
v38 = 2 * (unsigned int)(unsigned __int16)v35;
kmVec2Fill(&v52, v28, v26);
kmVec2Fill(&v54, v30, v26);
kmVec2Fill(&v56, v30, v29);
kmVec2Fill(&v58, v28, v29);
v39 = (unsigned int)(3 * v32);
v40 = (unsigned int)(2 * v32);
*(float *)(v18 + 4 * v39) = v28;
*(float *)(v18 + 4 * v39 + 4) = v26;
*(_DWORD *)(v18 + 4 * v39 + 8) = 0;
*(float *)(v19 + 4 * v40) = v52 / v2;
if ( this->m_bIsTextureFlipped )
v41 = height - v53;
else
v41 = v53;
*(float *)(v19 + 4 * v40 + 4) = v41 / v3;
*(float *)(v18 + 4LL * v47) = v30;
*(float *)(v18 + 4LL * v47 + 4) = v26;
*(_DWORD *)(v18 + 4LL * v47 + 8) = 0;
*(float *)(v19 + 4 * v36) = v54 / v2;
if ( this->m_bIsTextureFlipped )
v42 = height - v55;
else
v42 = v55;
*(float *)(v19 + 4 * v36 + 4) = v42 / v3;
*(float *)(v18 + 4LL * v48) = v30;
*(float *)(v18 + 4LL * v48 + 4) = v29;
*(_DWORD *)(v18 + 4LL * v48 + 8) = 0;
*(float *)(v19 + 4 * v37) = v56 / v2;
if ( this->m_bIsTextureFlipped )
v43 = height - v57;
else
v43 = v57;
*(float *)(v19 + 4 * v37 + 4) = v43 / v3;
*(float *)(v18 + 4LL * v49) = v28;
*(float *)(v18 + 4LL * v49 + 4) = v29;
*(_DWORD *)(v18 + 4LL * v49 + 8) = 0;
*(float *)(v19 + 4LL * (int)v38) = v58 / v2;
if ( this->m_bIsTextureFlipped )
v44 = height - v59;
else
v44 = v59;
v23 = (float)v17;
v22 = v50;
*(float *)(v19 + 4 * v38 + 4) = v44 / v3;
v21 = this->m_sGridSize.height;
}
while ( v21 > v27 );
}
width = this->m_sGridSize.width;
v20 = (float)v17;
}
while ( width > (float)v17 );
}
v45 = 0;
v46 = (float)((float)(this->m_sGridSize.height + 1.0) * (float)(width + 1.0)) * 12.0;
if ( v46 >= 9.223372e18 )
{
v46 = v46 - 9.223372e18;
if ( v46 < 9.223372e18 )
v45 = 0x8000000000000000uLL;
}
memcpy(*((void **)this + 17), *((const void **)this + 16), v45 + (unsigned int)(int)v46);
}