//
// GJBaseGameLayer::convertToClosestDirection from 0x14022e8b0 to 0x14022e94b (155 bytes)
//
// 9 xrefs:
// > GJBaseGameLayer::teleportPlayer @ 0x140210674
// > sub_14021EFB0 @ 0x14021f299
// > GJBaseGameLayer::processAdvancedFollowAction @ 0x14022fc10
// > GJBaseGameLayer::processAdvancedFollowAction @ 0x140230138
// > GJBaseGameLayer::processAdvancedFollowAction @ 0x1402301ca
// > GJBaseGameLayer::updateScreenRotation @ 0x140235ed0
// > GJBaseGameLayer::updateScreenRotation @ 0x140235ee8
// > PlayerObject::redirectPlayerForce @ 0x14039fcff
// > ??> @ 0x1406cdd7c
//
// 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
//
float GJBaseGameLayer::convertToClosestDirection(float a1, float a2)
{
float v2; // xmm6_4
float v3; // xmm0_4
float v4; // xmm0_4
v2 = a1;
if ( (float)-a2 <= a1 )
{
if ( a1 > a2 )
{
v4 = floorf(fabs(a1) / a2);
return v2 - (float)(ceilf(v4 * 0.5) * (float)(a2 + a2));
}
}
else
{
v3 = floorf(fabs(a1) / a2);
return (float)(ceilf(v3 * 0.5) * (float)(a2 + a2)) + v2;
}
return a1;
}