Skip to content

Commit

Permalink
Move sqrtf to std:: namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Aug 8, 2024
1 parent 707fcec commit a25d265
Show file tree
Hide file tree
Showing 40 changed files with 100 additions and 99 deletions.
8 changes: 4 additions & 4 deletions include/SSystem/SComponent/c_xyz.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ struct cXyz : Vec {
cXyz tmp2(other.x, 0, other.z);
return tmp.abs2(tmp2);
}
f32 abs() const { return sqrtf(this->abs2()); }
f32 abs(const Vec& other) const { return sqrtf(this->abs2(other)); }
f32 absXZ() const { return sqrtf(this->abs2XZ()); }
f32 absXZ(const Vec& other) const { return sqrtf(this->abs2XZ(other)); }
f32 abs() const { return std::sqrtf(this->abs2()); }
f32 abs(const Vec& other) const { return std::sqrtf(this->abs2(other)); }
f32 absXZ() const { return std::sqrtf(this->abs2XZ()); }
f32 absXZ(const Vec& other) const { return std::sqrtf(this->abs2XZ(other)); }
f32 getMagXZ() const { return cXyz(this->x, 0, this->z).getSquareMag(); }

f32 getDotProduct(const Vec& other) const { return VECDotProduct(this, &other); }
Expand Down
2 changes: 1 addition & 1 deletion src/JAZelAudio/JAIZelBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,7 @@ int JAIZelBasic::checkOnOuterSea(f32* r4) {
f32 f6 = sp0C.field_0x0 - (mAudioCamera->field_0x0->x - islandX * 100000.0f);
f32 f0 = sp0C.field_0x8 - (mAudioCamera->field_0x0->z - islandY * 100000.0f);
*r4 = f6*f6 + f0*f0;
*r4 = sqrtf(*r4);
*r4 = std::sqrtf(*r4);

if (*r4 <= sp0C.field_0xC) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/JSystem/J3DGraphAnimator/J3DCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void J3DDeformer::deform(J3DVertexBuffer* vtx, u16 idx, f32* weightList) {

/* 802F3FA8-802F4064 .text normalize__11J3DDeformerFPf */
void J3DDeformer::normalize(f32* vec) {
f32 inv = 1.0f / sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
f32 inv = 1.0f / std::sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
vec[0] *= inv;
vec[1] *= inv;
vec[2] *= inv;
Expand Down
12 changes: 6 additions & 6 deletions src/JSystem/J3DGraphBase/J3DTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ f32 J3DCalcZValue(MtxP m, Vec v) {

/* 802DA120-802DA2E0 .text J3DCalcBBoardMtx__FPA4_f */
void J3DCalcBBoardMtx(Mtx mtx) {
f32 sx = sqrtf(mtx[0][0]*mtx[0][0] + mtx[1][0]*mtx[1][0] + mtx[2][0]*mtx[2][0]);
f32 sy = sqrtf(mtx[0][1]*mtx[0][1] + mtx[1][1]*mtx[1][1] + mtx[2][1]*mtx[2][1]);
f32 sz = sqrtf(mtx[0][2]*mtx[0][2] + mtx[1][2]*mtx[1][2] + mtx[2][2]*mtx[2][2]);
f32 sx = std::sqrtf(mtx[0][0]*mtx[0][0] + mtx[1][0]*mtx[1][0] + mtx[2][0]*mtx[2][0]);
f32 sy = std::sqrtf(mtx[0][1]*mtx[0][1] + mtx[1][1]*mtx[1][1] + mtx[2][1]*mtx[2][1]);
f32 sz = std::sqrtf(mtx[0][2]*mtx[0][2] + mtx[1][2]*mtx[1][2] + mtx[2][2]*mtx[2][2]);

mtx[0][0] = sx;
mtx[0][1] = 0.0f;
Expand All @@ -53,9 +53,9 @@ void J3DCalcBBoardMtx(Mtx mtx) {
/* 802DA2E0-802DA584 .text J3DCalcYBBoardMtx__FPA4_f */
void J3DCalcYBBoardMtx(Mtx mtx) {
/* Nonmatching */
f32 sx = sqrtf(mtx[0][0]*mtx[0][0] + mtx[1][0]*mtx[1][0] + mtx[2][0]*mtx[2][0]);
f32 sy = sqrtf(mtx[0][1]*mtx[0][1] + mtx[1][1]*mtx[1][1] + mtx[2][1]*mtx[2][1]);
f32 sz = sqrtf(mtx[0][2]*mtx[0][2] + mtx[1][2]*mtx[1][2] + mtx[2][2]*mtx[2][2]);
f32 sx = std::sqrtf(mtx[0][0]*mtx[0][0] + mtx[1][0]*mtx[1][0] + mtx[2][0]*mtx[2][0]);
f32 sy = std::sqrtf(mtx[0][1]*mtx[0][1] + mtx[1][1]*mtx[1][1] + mtx[2][1]*mtx[2][1]);
f32 sz = std::sqrtf(mtx[0][2]*mtx[0][2] + mtx[1][2]*mtx[1][2] + mtx[2][2]*mtx[2][2]);

Vec axisX, axisY, axisZ;

Expand Down
2 changes: 1 addition & 1 deletion src/JSystem/JUtility/JUTGamePad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ u32 JUTGamePad::CStick::update(s8 x_val, s8 y_val, EStickMode mode, EWhichStick
field_0xf = y_val;
mPosX = (f32)x_val / (f32)clamp;
mPosY = (f32)y_val / (f32)clamp;
mValue = sqrtf((mPosX * mPosX) + (mPosY * mPosY));
mValue = std::sqrtf((mPosX * mPosX) + (mPosY * mPosY));

if (mValue > 1.0f) {
if (mode == STICK_MODE_1) {
Expand Down
31 changes: 16 additions & 15 deletions src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,6 @@ inline double sqrt_step(double tmpd, float mag) {
return tmpd * 0.5 * (3.0 - mag * (tmpd * tmpd));
}

extern inline float sqrtf(float x) {
const double _half = .5;
const double _three = 3.0;
volatile float y;
if (x > 0.0f) {
double guess = __frsqrte((double)x); // returns an approximation to
guess = _half * guess * (_three - guess * guess * x); // now have 12 sig bits
guess = _half * guess * (_three - guess * guess * x); // now have 24 sig bits
guess = _half * guess * (_three - guess * guess * x); // now have 32 sig bits
y = (float)(x * guess);
return y;
}
return x;
}

extern inline double sqrt(double x) {
if(x > 0.0)
{
Expand Down Expand Up @@ -93,6 +78,22 @@ inline float fmodf(float x, float y) { return fmod(x, y); }
inline float atan2f(float y, float x) { return (float)atan2(y, x); }
inline float sinf(float x) { return sin(x); }
inline float cosf(float x) { return cos(x); }

extern inline float sqrtf(float x) {
const double _half = .5;
const double _three = 3.0;
volatile float y;
if (x > 0.0f) {
double guess = __frsqrte((double)x); // returns an approximation to
guess = _half * guess * (_three - guess * guess * x); // now have 12 sig bits
guess = _half * guess * (_three - guess * guess * x); // now have 24 sig bits
guess = _half * guess * (_three - guess * guess * x); // now have 32 sig bits
y = (float)(x * guess);
return y;
}
return x;
}

}; // namespace std
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/SSystem/SComponent/c_cc_s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,12 @@ void cCcS::SetPosCorrect(cCcD_Obj* obj1, cXyz* ppos1, cCcD_Obj* obj2, cXyz* ppos
objsDist.x = ppos2->x - ppos1->x;
objsDist.y = ppos2->y - ppos1->y;
objsDist.z = ppos2->z - ppos1->z;
objDistLen = sqrtf(objsDist.x*objsDist.x + objsDist.y*objsDist.y + objsDist.z*objsDist.z);
objDistLen = std::sqrtf(objsDist.x*objsDist.x + objsDist.y*objsDist.y + objsDist.z*objsDist.z);
} else {
objsDist.x = ppos2->x - ppos1->x;
objsDist.y = 0.0f;
objsDist.z = ppos2->z - ppos1->z;
objDistLen = sqrtf(objsDist.x*objsDist.x + objsDist.z*objsDist.z);
objDistLen = std::sqrtf(objsDist.x*objsDist.x + objsDist.z*objsDist.z);
}
if (!cM3d_IsZero(objDistLen)) {
if (correctY) {
Expand Down
4 changes: 2 additions & 2 deletions src/SSystem/SComponent/c_m2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ void cM2d_CrossCirLin(cM2dGCir& circle, f32 x0, f32 y0, f32 x1, f32 y1, f32* pDs
if (dVar10 < 0.0f) {
} else {
f32 fVar2 = 1.0f / (2.0f * dVar13);
f32 fVar15 = sqrtf(dVar10);
f32 fVar15 = std::sqrtf(dVar10);
fVar15 = fVar2 * (-dVar14 + fVar15);
f32 fVar16 = sqrtf(dVar10);
f32 fVar16 = std::sqrtf(dVar10);
f32 fVar4 = fVar2 * (-dVar14 - fVar16);
if (fVar15 > fVar4) {
t = fVar15;
Expand Down
8 changes: 4 additions & 4 deletions src/SSystem/SComponent/c_m2d_g_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ f32 cM2dGBox::GetLen(const cXy& p) const {
// Diagonally above and to the left of the box.
distX = p.x - mP0.x;
distY = p.y - mP0.y;
return sqrtf(distX * distX + distY * distY);
return std::sqrtf(distX * distX + distY * distY);
} else {
// Diagonally below and to the left of the box.
distX = p.x - mP0.x;
distY = p.y - mP1.y;
return sqrtf(distX * distX + distY * distY);
return std::sqrtf(distX * distX + distY * distY);
}
} else {
f32 distY;
Expand All @@ -60,12 +60,12 @@ f32 cM2dGBox::GetLen(const cXy& p) const {
// Diagonally above and to the right of the box.
distX = p.x - mP1.x;
distY = p.y - mP0.y;
return sqrtf(distX * distX + distY * distY);
return std::sqrtf(distX * distX + distY * distY);
} else {
// Diagonally below and to the right of the box.
distX = p.x - mP1.x;
distY = p.y - mP1.y;
return sqrtf(distX * distX + distY * distY);
return std::sqrtf(distX * distX + distY * distY);
}
}
}
4 changes: 2 additions & 2 deletions src/SSystem/SComponent/c_m3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ bool cM3d_Cross_CpsSph(const cM3dGCps& param_1, const cM3dGSph& param_2, Vec* pa
}
Vec auStack_34;
if (cM3d_Len3dSqPntAndSegLine(&param_1, param_2.GetCP(), &auStack_34, &local_38) != 0) {
if (sqrtf(local_38) < param_1.GetR() + param_2.GetR()) {
if (std::sqrtf(local_38) < param_1.GetR() + param_2.GetR()) {
cM3d_Cross_CpsSph_CrossPos(param_1, param_2, auStack_34, param_3);
return true;
}
Expand Down Expand Up @@ -635,7 +635,7 @@ void cM3d_CalcVecAngle(const Vec& vec, s16* a, s16* b) {

/* 80251560-80251634 .text cM3d_CalcVecZAngle__FRC3VecP5csXyz */
void cM3d_CalcVecZAngle(const Vec& param_0, csXyz* param_1) {
param_1->x = -cM_atan2s(param_0.y, sqrtf(param_0.x * param_0.x + param_0.z * param_0.z));;
param_1->x = -cM_atan2s(param_0.y, std::sqrtf(param_0.x * param_0.x + param_0.z * param_0.z));;
param_1->y = cM_atan2s(param_0.x, param_0.z);
param_1->z = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/c/c_damagereaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ void enemy_fire(enemyfire* ef) {

ef->mDirection.y = 0.2f + REG0_F(11);

f32 speed = sqrtf(vel.x * vel.x + vel.y * vel.y + vel.z * vel.z);
f32 speed = std::sqrtf(vel.x * vel.x + vel.y * vel.y + vel.z * vel.z);
speed = (0.03f + REG0_F(12)) * speed + 1.0f;
if (speed > 1.5f + REG0_F(13)) {
speed = 1.5f + REG0_F(13);
Expand Down
10 changes: 5 additions & 5 deletions src/d/actor/d_a_am.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ static void medama_move(am_class* i_this) {
i_this->mTargetEyeRot.y = 0x71C;
}

i_this->mTargetEyeRot.x = cM_atan2s(diffY, sqrtf(diffX*diffX + diffZ*diffZ));
i_this->mTargetEyeRot.x = cM_atan2s(diffY, std::sqrtf(diffX*diffX + diffZ*diffZ));
if (i_this->mTargetEyeRot.x < -0x38E) {
i_this->mTargetEyeRot.x = -0x38E;
} else if (i_this->mTargetEyeRot.x > 0x38E) {
Expand Down Expand Up @@ -487,7 +487,7 @@ static void action_dousa(am_class* i_this) {
fopAcM_OnStatus(i_this, fopAcStts_SHOWMAP_e);
if (fopAcM_searchPlayerDistance(i_this) < 1000.0f) {
f32 yDist = player->current.pos.y - i_this->current.pos.y;
yDist = sqrtf(yDist*yDist); // ???
yDist = std::sqrtf(yDist*yDist); // ???
if (yDist > 300.0f) {
break;
}
Expand Down Expand Up @@ -532,7 +532,7 @@ static void action_dousa(am_class* i_this) {
if (i_this->mType & 1) {
f32 xDist = i_this->current.pos.x - i_this->mSpawnPos.x;
f32 zDist = i_this->current.pos.z - i_this->mSpawnPos.z;
f32 xzDist = sqrtf(xDist*xDist + zDist*zDist);
f32 xzDist = std::sqrtf(xDist*xDist + zDist*zDist);
if (xzDist > i_this->mAreaRadius) {
i_this->mAction = ACTION_MODORU_MOVE;
i_this->mState = 0x14;
Expand All @@ -544,7 +544,7 @@ static void action_dousa(am_class* i_this) {
break;
}
f32 yDist = player->current.pos.y - i_this->current.pos.y;
yDist = sqrtf(yDist*yDist); // ???
yDist = std::sqrtf(yDist*yDist); // ???
if (yDist > 300.0f) {
i_this->mState = 9;
break;
Expand Down Expand Up @@ -690,7 +690,7 @@ static void action_modoru_move(am_class* i_this) {
i_this->mTargetAngleY = cM_atan2s(xDistToSpawn, zDistToSpawn);
}

f32 xzDist = sqrtf(xDistToSpawn*xDistToSpawn + zDistToSpawn*zDistToSpawn);
f32 xzDist = std::sqrtf(xDistToSpawn*xDistToSpawn + zDistToSpawn*zDistToSpawn);
if (xzDist < 20.0f) {
i_this->mTargetAngleY = i_this->mSpawnRotY;
i_this->speedF = 0.0f;
Expand Down
18 changes: 9 additions & 9 deletions src/d/actor/d_a_bk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ static fpc_ProcID search_wepon(bk_class* i_this) {
sp18.x = r25->current.pos.x - i_this->eyePos.x;
sp18.y = 50.0f + r25->current.pos.y - i_this->eyePos.y;
sp18.z = r25->current.pos.z - i_this->eyePos.z;
f32 f4 = sqrtf(sp18.x*sp18.x + sp18.z*sp18.z);
f32 f4 = std::sqrtf(sp18.x*sp18.x + sp18.z*sp18.z);
if (f4 < f29 && !daBk_other_bg_check(i_this, r25)) {
if (std::fabsf(r25->current.pos.y + 50.0f - i_this->eyePos.y) <= l_bkHIO.m038) {
s16 angleDiff = i_this->m0330 - cM_atan2s(sp18.x, sp18.z);
Expand Down Expand Up @@ -774,8 +774,8 @@ static fopAc_ac_c* search_bomb(bk_class* i_this, BOOL r26) {
cXyz sp1C;
sp1C.x = r24->current.pos.x - i_this->current.pos.x;
sp1C.z = r24->current.pos.z - i_this->current.pos.z;
f32 f0 = sqrtf(sp28.x*sp28.x + sp28.z*sp28.z);
f32 f5 = sqrtf(sp1C.x*sp1C.x + sp1C.z*sp1C.z);
f32 f0 = std::sqrtf(sp28.x*sp28.x + sp28.z*sp28.z);
f32 f5 = std::sqrtf(sp1C.x*sp1C.x + sp1C.z*sp1C.z);
if (f0 < f29 && !(f5 > 30.0f + i_this->mPlayerDistance) &&
!(daBk_other_bg_check(i_this, r24) && r26)
) {
Expand Down Expand Up @@ -999,7 +999,7 @@ static void path_check(bk_class* i_this, u8 r19) {
f32 distX = i_this->current.pos.x - pnt->mPos.x;
f32 distY = i_this->current.pos.y - pnt->mPos.y;
f32 distZ = i_this->current.pos.z - pnt->mPos.z;
if (sqrtf(distX*distX + distY*distY + distZ*distZ) < f0) {
if (std::sqrtf(distX*distX + distY*distY + distZ*distZ) < f0) {
if (r19) {
i_this->m1216 = j;
} else {
Expand Down Expand Up @@ -1101,15 +1101,15 @@ static void jyunkai(bk_class* i_this) {
i_this->dr.m4D0 = cM_atan2s(sp10.x, sp10.z);

if (i_this->m1215 != 0 && (i_this->m0B30 != 0 || i_this->m11F3 != 0)) {
if (sqrtf(sp10.x*sp10.x + sp10.z*sp10.z) < f31 * 0.25f * 2.0f) {
if (std::sqrtf(sp10.x*sp10.x + sp10.z*sp10.z) < f31 * 0.25f * 2.0f) {
if (i_this->ppd->mpPnt[i_this->m1216].mArg3 == 3) {
wait_set(i_this);
i_this->dr.m004 = 2;
} else {
i_this->dr.m004 = -1;
}
}
} else if (sqrtf(sp10.x*sp10.x + sp10.z*sp10.z) < f31 * 0.25f * 2.0f ||
} else if (std::sqrtf(sp10.x*sp10.x + sp10.z*sp10.z) < f31 * 0.25f * 2.0f ||
(
i_this->m0300[2] == 0 && (
i_this->dr.mAcch.ChkWallHit() ||
Expand Down Expand Up @@ -1331,7 +1331,7 @@ static void stand(bk_class* i_this) {
case 0x34:
sp28 = i_this->home.pos - i_this->current.pos;
i_this->dr.m4D0 = cM_atan2s(sp28.x, sp28.z);
if (sqrtf(sp28.x*sp28.x + sp28.z*sp28.z) < l_bkHIO.m054 * 0.25f * 5.0f) {
if (std::sqrtf(sp28.x*sp28.x + sp28.z*sp28.z) < l_bkHIO.m054 * 0.25f * 5.0f) {
i_this->dr.m004 = 0;
}
cLib_addCalcAngleS2(&i_this->current.angle.y, i_this->dr.m4D0, 4, 0x1000);
Expand Down Expand Up @@ -1546,7 +1546,7 @@ static void stand2(bk_class* i_this) {
sp24 = i_this->home.pos - i_this->current.pos;
temp_568:
i_this->dr.m4D0 = cM_atan2s(sp24.x, sp24.z);
if (sqrtf(sp24.x*sp24.x + sp24.z*sp24.z) < l_bkHIO.m054 * 0.25f * 5.0f) {
if (std::sqrtf(sp24.x*sp24.x + sp24.z*sp24.z) < l_bkHIO.m054 * 0.25f * 5.0f) {
if (i_this->dr.m004 == 0x3C) {
i_this->dr.m004 = 0;
} else if (i_this->m1216 == 0) {
Expand Down Expand Up @@ -1623,7 +1623,7 @@ static void path_run(bk_class* i_this) {
sp0C.z = z - i_this->current.pos.z;
i_this->dr.m4D0 = cM_atan2s(sp0C.x, sp0C.z);

if (sqrtf(sp0C.x*sp0C.x + sp0C.z*sp0C.z) < 100.0f) {
if (std::sqrtf(sp0C.x*sp0C.x + sp0C.z*sp0C.z) < 100.0f) {
i_this->m1216 += i_this->m1217;
if (i_this->m1216 >= (s8)i_this->ppd->m_num) {
i_this->m1216 = i_this->ppd->m_num - 1;
Expand Down
2 changes: 1 addition & 1 deletion src/d/actor/d_a_bomb2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ namespace daBomb2 {
cXyz sp48 = *mSph.GetTgRVecP();
f32 f31 = sp48.abs2();
if (f31 > f30*f30) {
sp48 *= f30 / sqrtf(f31);;
sp48 *= f30 / std::sqrtf(f31);;
}
cCcD_ShapeAttr* hitShapeAttr = hitObj->GetShapeAttr();
cXyz hitNormal = cXyz::Zero;
Expand Down
2 changes: 1 addition & 1 deletion src/d/actor/d_a_bomb3.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ void daBomb_c::set_wind_vec() {
cXyz sp48 = *mSph.GetTgRVecP();
f32 f31 = sp48.abs2();
if (f31 > 180.0f*180.0f) {
sp48 *= 180.0f / sqrtf(f31);;
sp48 *= 180.0f / std::sqrtf(f31);;
}
cCcD_ShapeAttr* hitShapeAttr = hitObj->GetShapeAttr();
cXyz hitNormal = cXyz::Zero;
Expand Down
2 changes: 1 addition & 1 deletion src/d/actor/d_a_bwdg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static void wave_cont(bwdg_class* i_this, u8 r4) {
sp24.x = posVtx->x - sp30.x;
sp24.z = posVtx->z - sp30.z;

f32 f0 = sqrtf(sp24.x*sp24.x + sp24.z*sp24.z);
f32 f0 = std::sqrtf(sp24.x*sp24.x + sp24.z*sp24.z);
f32 f1 = 3000.0f - f0;
f32 f3;
f32 f4 = f1;
Expand Down
8 changes: 4 additions & 4 deletions src/d/actor/d_a_kt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ void kotori_move(kt_class* i_this) {

f32 dx = player->current.pos.x - *(r28 = &i_this->current.pos.x);
f32 dz = player->current.pos.z - *(r27 = &i_this->current.pos.z);
f32 dist_xz = sqrtf(dx*dx + dz*dz);
f32 dist_xz = std::sqrtf(dx*dx + dz*dz);
cLib_addCalcAngleS2(&i_this->mAngleRoll, 0, 2, REG0_S(4) + 0x1000);

f32 vx = i_this->mTargetPos.x - *r28;
f32 vy = i_this->mTargetPos.y - *(r26 = &i_this->current.pos.y);
f32 vz = i_this->mTargetPos.z - *r27;
s16 angleX = cM_atan2s(vx, vz);
s16 angleY = -cM_atan2s(vy, sqrtf(vx*vx + vz*vz));
s16 angleY = -cM_atan2s(vy, std::sqrtf(vx*vx + vz*vz));

cXyz offs;
cXyz pt;
Expand Down Expand Up @@ -115,7 +115,7 @@ void kotori_move(kt_class* i_this) {
cLib_addCalc2(&i_this->mSpeedLerp, 1.0f, 1.0f, 0.1f);
goto calc_012;
case 1:
dist = sqrtf(vx*vx + vy*vy + vz*vz);
dist = std::sqrtf(vx*vx + vy*vy + vz*vz);
if (dist < REG0_F(1) * 10.0f + 800.0f) {
i_this->mState = 8;
}
Expand Down Expand Up @@ -161,7 +161,7 @@ void kotori_move(kt_class* i_this) {
case 2:
i_this->mTargetPos = headTopPos;
i_this->mTargetPos.y += 200.0f;
dist = sqrtf(vx*vx + vy*vy + vz*vz);
dist = std::sqrtf(vx*vx + vy*vy + vz*vz);
if (dist < REG0_F(1) * 10.0f + 800.0f) {
i_this->mState = 9;
}
Expand Down
2 changes: 1 addition & 1 deletion src/d/actor/d_a_kytag02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dPath* get_nearpos_rail(kytag02_class* i_this, dPath* i_path, cXyz* pos, int* i_
for (s32 i = 0; i < path->m_num; i++) {
f32 dx = path->mpPnt[i].mPos.x - pos->x;
f32 dz = path->mpPnt[i].mPos.z - pos->z;
f32 dist = sqrtf(dx*dx + dz*dz);
f32 dist = std::sqrtf(dx*dx + dz*dz);
if (best > dist) {
bestPath = path;
bestIdx = i;
Expand Down
2 changes: 1 addition & 1 deletion src/d/actor/d_a_msw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void chain_Draw(msw_class* i_this) {
angle1 = -cM_atan2s(tmp.y, tmp.z);

// TODO: std::sqrtf(float)
angle2 = cM_atan2s(tmp.x, sqrtf(tmp.y * tmp.y + tmp.z * tmp.z));
angle2 = cM_atan2s(tmp.x, std::sqrtf(tmp.y * tmp.y + tmp.z * tmp.z));

MtxTrans(i_this->m2E0[i].x, i_this->m2E0[i].y, i_this->m2E0[i].z, false);

Expand Down
Loading

0 comments on commit a25d265

Please sign in to comment.