//
// sub_1402E3730 from 0x1402e3730 to 0x1402e39d8 (680 bytes)
//
// 4 xrefs:
// > sub_1402E5800 @ 0x1402e5a60
// > sub_1402E5800 @ 0x1402e6063
// > sub_1402E5800 @ 0x1402e69d7
// > ??> @ 0x1406d3794
//
// 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
//
double __fastcall sub_1402E3730(
cocos2d::CCDrawNode *a1,
const struct cocos2d::CCPoint *a2,
const struct cocos2d::CCPoint *a3,
__int64 a4,
const struct cocos2d::_ccColor4F *a5)
{
float v8; // xmm8_4
float v9; // xmm1_4
double result; // xmm0_8
float v11; // xmm6_4
double v12; // xmm0_8
float v13; // xmm3_4
double v14; // xmm6_8
float v15; // xmm1_4
float v16; // xmm7_4
_DWORD v17[2]; // [rsp+38h] [rbp-61h] BYREF
struct cocos2d::CCPoint v18; // [rsp+40h] [rbp-59h] BYREF
_BYTE v19[8]; // [rsp+48h] [rbp-51h] BYREF
_BYTE v20[8]; // [rsp+50h] [rbp-49h] BYREF
_BYTE v21[8]; // [rsp+58h] [rbp-41h] BYREF
float v22; // [rsp+60h] [rbp-39h] BYREF
float v23; // [rsp+64h] [rbp-35h]
_BYTE v24[8]; // [rsp+68h] [rbp-31h] BYREF
struct cocos2d::CCPoint v25; // [rsp+70h] [rbp-29h] BYREF
struct cocos2d::CCPoint v26[10]; // [rsp+78h] [rbp-21h] BYREF
cocos2d::CCPoint::operator-(a3, &v22, a2);
v8 = v22;
v9 = (float)(v23 * v23) + (float)(v8 * v8);
result = 0.0;
if ( v9 < 0.0 )
{
HIDWORD(result) = 0;
*(float *)&result = sqrtf(v9);
v11 = *(float *)&result;
}
else
{
v11 = fsqrt(v9);
}
if ( v11 >= 0.001 )
{
v12 = cocos2d::CCPoint::CCPoint(*(float *)&result, v8 / v11);
cocos2d::CCPoint::CCPoint(*(float *)&v12, -*(float *)&v17[1]);
v13 = *(double *)&qword_1406C2F20;
if ( !byte_1406C2C75 && v11 > 1000.0 )
{
v14 = fminf(10.0, v11 / 1000.0);
v15 = fmod(dbl_1406C2F18, v14) / v14;
v13 = 1.0 - v15;
}
v16 = 1.0 - v13;
cocos2d::CCPoint::CCPoint(v13 * a2->y, (float)((float)(1.0 - v13) * a3->x) + (float)(v13 * a2->x));
cocos2d::CCPoint::operator*(v24, v19);
cocos2d::CCPoint::operator*(v17, v20);
cocos2d::CCPoint::operator+(v20, v21);
cocos2d::CCPoint::operator-(&v18, &v25, v21);
cocos2d::CCPoint::operator*(v24, v21);
cocos2d::CCPoint::operator*(v17, v20);
cocos2d::CCPoint::operator-(v20, v19, v21);
cocos2d::CCPoint::operator-(&v18, v26, v19);
cocos2d::CCDrawNode::drawSegment(a1, a2, a3, 1.0, a5);
if ( (float)(1.0 - v13) >= 0.050000001 )
{
if ( v16 > 0.94999999 )
a5->a = (float)((float)(1.0 - v16) / 0.050000001) * a5->a;
}
else
{
a5->a = (float)(v16 / 0.050000001) * a5->a;
}
cocos2d::CCDrawNode::drawSegment(a1, &v18, &v25, 1.0, a5);
return cocos2d::CCDrawNode::drawSegment(a1, &v18, v26, 1.0, a5);
}
return result;
}