//
// PlayerObject::rotateGameplayObject from 0x100406c20 to 0x100406f05 (741 bytes)
//
// 4 xrefs:
// > PlayerObject::handleRotatedCollisionInternal @ 0x100406aa4
// > PlayerObject::handleRotatedCollisionInternal @ 0x100406ac8
// > PlayerObject::rotatePreSlopeObjects @ 0x100406f37
// > PlayerObject::spiderTestJumpInternal @ 0x10040dd7e
//
// 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 PlayerObject::rotateGameplayObject(PlayerObject *a1, GameObject *a2)
{
std::unordered_map *p_m_rotateObjectsRelated; // r12
unsigned __int64 value; // rdi
unsigned __int64 m_uniqueID; // rcx
unsigned __int64 v7; // r9
__int64 v8; // rsi
std::__hash_node_base, void *> *> *v9; // rax
std::__hash_node_base, void *> *>::__next_pointer next; // r8
unsigned __int64 v11; // rdi
std::__hash_node_base, void *> *>::__next_pointer v12; // rax
unsigned __int64 v13; // rax
double v14; // xmm0_8
double *v15; // rax
__m128 v16; // xmm1
__m128 v17; // xmm2
__m128 v18; // xmm4
__m128 v19; // xmm4
unsigned __int64 *LastPosition; // r15
unsigned __int64 v21; // [rsp+8h] [rbp-88h] BYREF
__m128d v22; // [rsp+10h] [rbp-80h]
__m128 v23; // [rsp+20h] [rbp-70h]
__m128d v24; // [rsp+30h] [rbp-60h] BYREF
unsigned __int64 v25; // [rsp+48h] [rbp-48h] BYREF
unsigned __int64 v26; // [rsp+50h] [rbp-40h] BYREF
int *p_m_uniqueID; // [rsp+58h] [rbp-38h]
double v28[6]; // [rsp+60h] [rbp-30h] BYREF
p_m_rotateObjectsRelated = &a1->m_rotateObjectsRelated;
value = a1->m_rotateObjectsRelated.__table_.__bucket_list_.__ptr_.__value_.__data_.__value_;
if ( !value )
goto LABEL_28;
m_uniqueID = a2->m_uniqueID;
v7 = (0x101010101010101LL
* ((((value - ((value >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((value - ((value >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((value - ((value >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((value - ((value >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v7 > 1 )
{
v8 = a2->m_uniqueID;
if ( value <= m_uniqueID )
{
if ( !((value | m_uniqueID) >> 32) )
{
v8 = (unsigned int)m_uniqueID % (unsigned int)value;
v9 = p_m_rotateObjectsRelated->__table_.__bucket_list_.__ptr_.__value_[v8];
if ( !v9 )
goto LABEL_28;
goto LABEL_9;
}
v8 = m_uniqueID % value;
}
v9 = p_m_rotateObjectsRelated->__table_.__bucket_list_.__ptr_.__value_[v8];
if ( !v9 )
goto LABEL_28;
goto LABEL_9;
}
v8 = m_uniqueID & (value - 1);
v9 = p_m_rotateObjectsRelated->__table_.__bucket_list_.__ptr_.__value_[v8];
if ( !v9 )
goto LABEL_28;
LABEL_9:
next = v9->__next_;
if ( v9->__next_ )
{
if ( (unsigned int)v7 < 2 )
{
v11 = value - 1;
while ( 1 )
{
v12 = next[1].__next_;
if ( v12 == (std::__hash_node_base, void *> *>::__next_pointer)m_uniqueID )
{
if ( LODWORD(next[2].__next_) == (_DWORD)m_uniqueID )
return;
}
else if ( (v11 & (unsigned __int64)v12) != v8 )
{
goto LABEL_28;
}
next = next->__next_;
if ( !next )
goto LABEL_28;
}
}
while ( 1 )
{
v13 = (unsigned __int64)next[1].__next_;
if ( v13 == m_uniqueID )
{
if ( LODWORD(next[2].__next_) == (_DWORD)m_uniqueID )
return;
goto LABEL_18;
}
if ( v13 < value )
goto LABEL_23;
if ( (value | v13) >> 32 )
break;
if ( (unsigned int)v13 % (unsigned int)value != v8 )
goto LABEL_28;
LABEL_18:
next = next->__next_;
if ( !next )
goto LABEL_28;
}
v13 %= value;
LABEL_23:
if ( v13 != v8 )
goto LABEL_28;
goto LABEL_18;
}
LABEL_28:
p_m_uniqueID = &a2->m_uniqueID;
((void (__fastcall *)(double *, GameObject *))a2->getRealPosition)(v28, a2);
v14 = sub_10028CC60(&v25, v28);
v15 = (double *)((__int64 (__fastcall *)(PlayerObject *, double))a1->getPosition)(a1, v14);
sub_10028CC60(&v26, v15);
v16 = _mm_sub_ps((__m128)*(unsigned __int64 *)&v28[0], (__m128)v26);
v17 = _mm_movehdup_ps(v16);
v18 = v16;
v18.f32[0] = (float)(v16.f32[0] * -0.000000043711388) - v17.f32[0];
v17.f32[0] = (float)(v17.f32[0] * -0.000000043711388) + v16.f32[0];
v19 = _mm_add_ps(_mm_insert_ps(v18, v17, 16), (__m128)v26);
_mm_storel_ps(v28, v19);
v23 = _mm_sub_ps(v19, (__m128)v25);
v22 = _mm_cvtps_pd(v23);
GameObject::addToTempOffset(a2, v22.f64[0], _mm_unpackhi_pd(v22, v22).f64[0]);
LastPosition = (unsigned __int64 *)GameObject::getLastPosition(a2);
sub_10028CBE0((float *)&v21, v23.f32[0], _mm_movehdup_ps(v23).f32[0]);
sub_10028CCE0(v24.f64, LastPosition, &v21);
GameObject::setLastPosition(a2, (const cocos2d::CCPoint *)&v24);
_mm_storel_ps(
(double *)&a2->m_startRotationX,
_mm_add_ps((__m128)*(unsigned __int64 *)&a2->m_startRotationX, (__m128)xmmword_10081B7F0));
((void (__fastcall *)(GameObject *, double))a2->setRRotation)(a2, 0.0);
((void (__fastcall *)(GameObject *, __int64))a2->setObjectRectDirty)(a2, 1);
if ( ((unsigned int (__fastcall *)(GameObject *))a2->getType)(a2) == 25 )
GameObject::determineSlopeDirection(a2);
v24 = v22;
sub_10041ECF0(p_m_rotateObjectsRelated, p_m_uniqueID, &v24);
}