Rename some simple functions

This commit is contained in:
angie
2022-04-02 01:39:47 -03:00
parent 5650a06575
commit 3dabee79dd
34 changed files with 165 additions and 133 deletions
+1 -1
View File
@@ -2884,7 +2884,7 @@ extern f32 D_801E0134;
extern f32 D_801E0138;
extern f32 D_801E013C;
extern f32 D_801E0140;
extern f32 Math3D_AngleBetweenVectors_min_length;
extern f32 Math3D_CosOut_min_length;
extern f32 D_801E0148;
extern f32 D_801E014C;
extern f32 Math3D_UnitNormalVector_min_length;
+11 -11
View File
@@ -179,33 +179,33 @@ f32 Math_Acot2F(f32 adjacent, f32 opposite);
f32 Math3D_Normalize(Vec3f* vec);
s32 Math3D_PlaneVsLineSegClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, Vec3f* linePointA, Vec3f* linePointB, Vec3f* closestPoint);
s32 func_80179798(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3, Vec3f* param_4, Vec3f* param_5, Vec3f* param_6);
// void func_80179A44(void);
f32 Math3D_LineClosestToPoint(Linef* line, Vec3f* pos, Vec3f* closestPoint);
void func_80179B34(float fParm1, f32 fParm2, f32 fParm5, f32 fParm6, f32 param_5, f32 param_6, f32 param_7, float* param_8, float* param_9);
s32 func_80179B94(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, InfiniteLine* intersect);
// void func_80179D74(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10);
void Math3D_ScaleAndAdd(Vec3f* a, Vec3f* b, f32 scale, Vec3f* dst);
void Math3D_Lerp(Vec3f* a, Vec3f* b, f32 t, Vec3f* dst);
f32 Math3D_Parallel(Vec3f* a, Vec3f* b);
s32 Math3D_AngleBetweenVectors(Vec3f* a, Vec3f* b, f32* angle);
f32 Math3D_Cos(Vec3f* a, Vec3f* b);
s32 Math3D_CosOut(Vec3f* a, Vec3f* b, f32* angle);
void func_80179F64(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3);
s32 Math3D_XZBoundCheck(f32 xMin, f32 xMax, f32 zMin, f32 zMax, f32 x, f32 z);
// void func_8017A09C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6);
// void func_8017A1D0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6);
s32 func_8017A304(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 z, f32 x, f32 chkDist);
// UNK_TYPE4 func_8017A438(Vec3f* pfParm1, Vec3f* pfParm2, Vec3f* pfParm3, Vec3f* pfParm4, f32 param_5);
f32 Math3D_XZLengthSquared(f32 x, f32 z);
f32 Math3D_XZLength(f32 x, f32 z);
f32 Math3D_XZDistanceSquared(f32 x1, f32 x2, f32 z1, f32 z2);
f32 Math3D_XZDistance(f32 x1, f32 x2, f32 z1, f32 z2);
f32 Math3D_LengthSquared(Vec3f* vec);
f32 Math3D_Dist1DSq(f32 x, f32 z);
f32 Math3D_Dist1D(f32 x, f32 z);
f32 Math3D_Dist2DSq(f32 x1, f32 x2, f32 z1, f32 z2);
f32 Math3D_Dist2D(f32 x1, f32 x2, f32 z1, f32 z2);
f32 Math3D_Vec3fMagnitudeSq(Vec3f* vec);
f32 Math3D_Vec3fMagnitude(Vec3f* vec);
f32 Math3D_Vec3fDistSq(Vec3f* a, Vec3f* b);
f32 Math3D_Distance(Vec3f* a, Vec3f* b);
f32 Math3D_DistanceS(Vec3s* s, Vec3f* f);
f32 Math3D_Vec3f_DistXYZ(Vec3f* a, Vec3f* b);
f32 Math3D_DistXYZ16toF(Vec3s* s, Vec3f* f);
f32 Math3D_Vec3fDiff_CrossZ(Vec3f* a, Vec3f* b, f32 dx, f32 dy);
f32 Math3D_Vec3fDiff_CrossX(Vec3f* a, Vec3f* b, f32 dy, f32 dz);
f32 Math3D_Vec3fDiff_CrossY(Vec3f* a, Vec3f* b, f32 dz, f32 dx);
void Math3D_CrossProduct(Vec3f* a, Vec3f* b, Vec3f* res);
void Math3D_Vec3f_Cross(Vec3f* a, Vec3f* b, Vec3f* res);
void Math3D_SurfaceNorm(Vec3f* a, Vec3f* b, Vec3f* c, Vec3f* res);
s32 Math3D_PointRelativeToCubeFaces(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3);
s32 Math3D_PointRelativeToCubeEdges(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3);
+38 -20
View File
@@ -2,9 +2,9 @@
#include "libc/stdbool.h"
#include "libc/math.h"
#define Math3D_FindPointOnPlaneIntersect func_80179B34
#define Math3D_PlaneVsPlaneNewLine func_80179B94
#define Math3D_LineSegMakePerpLineSeg func_80179798
#define Math3D_Vec3f_Cross Math3D_CrossProduct
#define Math3D_Plane func_8017B9D8
#define Math3D_TriLineIntersect func_8017D404
#define Math3D_CylOutsideCylDist Math3D_ColCylinderCylinderAmountAndDistance
@@ -22,18 +22,8 @@
#define Math3D_LineSplitRatio Math3D_Lerp
#define Math3D_PlaneVsPlaneVsLineClosestPoint func_80179D74
#define Math3D_PointInCyl func_8017E294
#define Math3D_Cos Math3D_Parallel
#define Math3D_CosOut Math3D_AngleBetweenVectors
#define Math3D_Vec3fReflect func_80179F64
#define Math3D_PointInSquare2D Math3D_XZBoundCheck
#define Math3D_Dist1DSq Math3D_XZLengthSquared
#define Math3D_Dist1D Math3D_XZLength
#define Math3D_Dist2DSq Math3D_XZDistanceSquared
#define Math3D_Dist2D Math3D_XZDistance
#define Math3D_Vec3fMagnitudeSq Math3D_LengthSquared
#define Math3D_Vec3fDistSq Math3D_Vec3fDistSq
#define Math3D_Vec3f_DistXYZ Math3D_Distance
#define Math3D_DistXYZ16toF Math3D_DistanceS
#define Math3D_RotateXZPlane func_8017B7F8
#define Math3D_DefPlane Math3D_UnitNormalVector
#define Math3D_PlaneF Math3D_SignedDistanceFromPlane
@@ -59,8 +49,8 @@
#define Math3D_TriNorm Math3D_TriSetCoords
#define Math3D_PointInSph Math3D_IsPointInSphere
#define Math3D_PointDistToLine2D_ func_8017D814
#define Math3D_Vec3fMagnitudeSq Math3D_LengthSquared
#define Math3D_LineClosestToPoint func_80179A44
#define Math3D_TriVsTriIntersect Math3d_ColTriTri
#define Math3D_GetSphVsTriIntersectPoint func_8017DD34
f32 Math3D_Normalize(Vec3f* vec) {
f32 magnitude = Math3D_Vec3fMagnitude(vec);
@@ -82,7 +72,6 @@ s32 Math3D_PlaneVsLineSegClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32
Vec3f* closestPoint) {
static InfiniteLine planeIntersectLine;
static Linef planeIntersectSeg;
Vec3f sp34; // unused
if (!Math3D_PlaneVsPlaneNewLine(planeAA, planeAB, planeAC, planeADist, planeBA, planeBB, planeBC, planeBDist,
@@ -175,12 +164,17 @@ s32 Math3D_LineSegMakePerpLineSeg(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f*
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_80179798.s")
#endif
/**
* Determines the closest point on the line `line` to `pos`, by forming a line perpendicular from
* `point` to `line` closest point is placed in `closestPoint`
*/
f32 Math3D_LineClosestToPoint(Linef* line, Vec3f* pos, Vec3f* closestPoint) {
f32 dirVectorSize = Math3D_Vec3fMagnitudeSq(&line->b);
f32 t;
if (IS_ZERO(dirVectorSize)) {
Math_Vec3f_Copy(closestPoint, pos);
//! @bug Missing early return
}
t = (((pos->x - line->a.x) * line->b.x) + ((pos->y - line->a.y) * line->b.y) + ((pos->z - line->a.z) * line->b.z)) /
@@ -192,7 +186,6 @@ f32 Math3D_LineClosestToPoint(Linef* line, Vec3f* pos, Vec3f* closestPoint) {
return t;
}
#define Math3D_FindPointOnPlaneIntersect func_80179B34
void Math3D_FindPointOnPlaneIntersect(f32 planeAAxis1Norm, f32 planeAAxis2Norm, f32 planeBAxis1Norm,
f32 planeBAxis2Norm, f32 axis3Direction, f32 planeADist, f32 planeBDist,
f32* axis1Point, f32* axis2Point) {
@@ -200,7 +193,6 @@ void Math3D_FindPointOnPlaneIntersect(f32 planeAAxis1Norm, f32 planeAAxis2Norm,
*axis2Point = ((planeBAxis1Norm * planeADist) - (planeAAxis1Norm * planeBDist)) / axis3Direction;
}
#define Math3D_PlaneVsPlaneNewLine func_80179B94
s32 Math3D_PlaneVsPlaneNewLine(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB,
f32 planeBC, f32 planeBDist, InfiniteLine* intersect) {
char pad[4];
@@ -510,30 +502,51 @@ s32 func_8017A438(Vec3f* arg0, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4)
return 1;
}
/**
* Returns the distance squared between `a` and `b` on a single axis
*/
f32 Math3D_Dist1DSq(f32 a, f32 b) {
return SQ(a) + SQ(b);
}
/**
* Returns the distance between `a` and `b` on a single axis
*/
f32 Math3D_Dist1D(f32 a, f32 b) {
return sqrtf(Math3D_Dist1DSq(a, b));
}
/**
* Returns the distance squared between (`x0`,`y0`) and (`x1`,`x2`)
*/
f32 Math3D_Dist2DSq(f32 x0, f32 y0, f32 x1, f32 y1) {
return Math3D_Dist1DSq(x0 - x1, y0 - y1);
}
/**
* Returns the distance between points (`x0`,`y0`) and (`x1`,`y1`)
*/
f32 Math3D_Dist2D(f32 x0, f32 y0, f32 x1, f32 y1) {
return sqrtf(Math3D_Dist2DSq(x0, y0, x1, y1));
}
/**
* Returns the magntiude (length) squared of `vec`
*/
f32 Math3D_Vec3fMagnitudeSq(Vec3f* vec) {
return SQ(vec->x) + SQ(vec->y) + SQ(vec->z);
}
/**
* Returns the magnitude(length) of `vec`
*/
f32 Math3D_Vec3fMagnitude(Vec3f* vec) {
return sqrtf(Math3D_Vec3fMagnitudeSq(vec));
}
/**
* Returns the distance between `a` and `b` squared.
*/
f32 Math3D_Vec3fDistSq(Vec3f* a, Vec3f* b) {
Vec3f diff;
@@ -542,10 +555,16 @@ f32 Math3D_Vec3fDistSq(Vec3f* a, Vec3f* b) {
return Math3D_Vec3fMagnitudeSq(&diff);
}
/*
* Calculates the distance between points `a` and `b`
*/
f32 Math3D_Vec3f_DistXYZ(Vec3f* a, Vec3f* b) {
return Math_Vec3f_DistXYZ(a, b);
}
/*
* Calculates the distance between `a` and `b`.
*/
f32 Math3D_DistXYZ16toF(Vec3s* a, Vec3f* b) {
Vec3f diff;
@@ -577,6 +596,9 @@ f32 Math3D_Vec3fDiff_CrossY(Vec3f* a, Vec3f* b, f32 dz, f32 dx) {
return ((a->z - dz) * (b->x - dx)) - ((a->x - dx) * (b->z - dz));
}
/**
* Gets the Cross Product of vectors `a` and `b` and places the result in `ret`
*/
void Math3D_Vec3f_Cross(Vec3f* a, Vec3f* b, Vec3f* ret) {
ret->x = (a->y * b->z) - (a->z * b->y);
ret->y = (a->z * b->x) - (a->x * b->z);
@@ -1576,9 +1598,6 @@ s32 func_8017DA24(f32 z0, f32 x0, Vec3f* p1, Vec3f* p2, f32* lineLenSq) {
return ret;
}
#define Math3D_TriVsSphIntersect Math3D_ColSphereTri
#define Math3D_GetSphVsTriIntersectPoint func_8017DD34
#ifdef NON_MATCHING
// in-function static bss
s32 Math3D_LineVsSph(Sphere16* sphere, Linef* line) {
@@ -2176,7 +2195,6 @@ s32 Math3D_CylOutsideCylDist(Cylinder16* ca, Cylinder16* cb, f32* deadSpace, f32
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_ColCylinderCylinderAmountAndDistance.s")
#endif
#define Math3D_TriVsTriIntersect Math3d_ColTriTri
s32 Math3D_TriVsTriIntersect(TriNorm* ta, TriNorm* tb, Vec3f* intersect) {
f32 dist0 = Math3D_Plane(&ta->plane, &tb->vtx[0]);
f32 dist1 = Math3D_Plane(&ta->plane, &tb->vtx[1]);
+2 -2
View File
@@ -3937,7 +3937,7 @@ void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3
// Find the point closest to srcPos
for (pointIndex = 0; pointIndex < numPoints; pointIndex++) {
distSq = Math3D_XZDistanceSquared(srcPos->x, srcPos->z, points[pointIndex].x, points[pointIndex].z);
distSq = Math3D_Dist2DSq(srcPos->x, srcPos->z, points[pointIndex].x, points[pointIndex].z);
if (distSq < closestPointDistSq) {
closestPointDistSq = distSq;
closestPointIndex = pointIndex;
@@ -3998,7 +3998,7 @@ void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3
for (i = 0; i < ARRAY_COUNT(loopDistSq); i++) {
if (useAdjacentLines[i]) {
// Get distSq from srcPos to closestPos
loopDistSq[i] = Math3D_XZDistanceSquared(srcPos->x, srcPos->z, closestPos[i].x, closestPos[i].z);
loopDistSq[i] = Math3D_Dist2DSq(srcPos->x, srcPos->z, closestPos[i].x, closestPos[i].z);
} else {
// The closest Pos is not contained within the line-segment
loopDistSq[i] = SQ(40000.0f);
+2 -2
View File
@@ -290,8 +290,8 @@ void EffectBlure_UpdateFlags(EffectBlureElement* elem) {
Math_Vec3s_DiffToVec3f(&sp4C, &next->p1, &elem->p1);
Math_Vec3s_DiffToVec3f(&sp40, &next->p2, &elem->p2);
if (Math3D_AngleBetweenVectors(&sp64, &sp4C, &sp34) || Math3D_AngleBetweenVectors(&sp58, &sp40, &sp30) ||
Math3D_AngleBetweenVectors(&sp4C, &sp40, &sp2C)) {
if (Math3D_CosOut(&sp64, &sp4C, &sp34) || Math3D_CosOut(&sp58, &sp40, &sp30) ||
Math3D_CosOut(&sp4C, &sp40, &sp2C)) {
elem->flags &= ~3;
elem->flags |= 0;
} else if ((sp34 <= -0.5f) || (sp30 <= -0.5f) || (sp2C <= 0.7071f)) {
+1 -1
View File
@@ -120,7 +120,7 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) {
}
if ((fire->flags & 2) && (player->itemActionParam == PLAYER_AP_STICK)) {
Math_Vec3f_Diff(&player->swordInfo[0].tip, &fire->position, &dist);
if (Math3D_LengthSquared(&dist) < 400.0f) {
if (Math3D_Vec3fMagnitudeSq(&dist) < 400.0f) {
sp40 = true;
}
}
+2 -2
View File
@@ -557,8 +557,8 @@ void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing*
diff.x = actorPath->curPoint.x - actorPath->worldPos->x;
diff.y = actorPath->curPoint.y - actorPath->worldPos->y;
diff.z = actorPath->curPoint.z - actorPath->worldPos->z;
actorPath->distSqToCurPointXZ = Math3D_XZLengthSquared(diff.x, diff.z);
actorPath->distSqToCurPoint = Math3D_LengthSquared(&diff);
actorPath->distSqToCurPointXZ = Math3D_Dist1DSq(diff.x, diff.z);
actorPath->distSqToCurPoint = Math3D_Vec3fMagnitudeSq(&diff);
actorPath->rotToCurPoint.y = Math_FAtan2F(diff.z, diff.x);
actorPath->rotToCurPoint.x = Math_FAtan2F(sqrtf(actorPath->distSqToCurPointXZ), -diff.y);
actorPath->rotToCurPoint.z = 0;
@@ -61,7 +61,7 @@ Color_RGBA8 D_80B8539C = { 200, 255, 255, 255 };
Color_RGBA8 D_80B853A0 = { 200, 200, 200, 0 };
s32 func_80B83C80(Vec3f* arg0, Vec3f* arg1) {
f32 temp_f0 = Math3D_LengthSquared(arg0);
f32 temp_f0 = Math3D_Vec3fMagnitudeSq(arg0);
f32 temp_f2;
if (temp_f0 < 0.0000010000001f) {
@@ -484,12 +484,12 @@ void func_80A9BD24(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU
}
if (unkStruct->unk_0000[i].unk_34 == 2) {
if (Math3D_XZLengthSquared(unkStruct->unk_0000[i].unk_14.x, unkStruct->unk_0000[i].unk_14.z) >
if (Math3D_Dist1DSq(unkStruct->unk_0000[i].unk_14.x, unkStruct->unk_0000[i].unk_14.z) >
SQ(440.0f) + 0.02f) {
unkStruct->unk_0000[i].unk_34 = 3;
}
} else if (unkStruct->unk_0000[i].unk_34 == 3) {
if (Math3D_XZLengthSquared(unkStruct->unk_0000[i].unk_14.x, unkStruct->unk_0000[i].unk_14.z) > 278784.03f) {
if (Math3D_Dist1DSq(unkStruct->unk_0000[i].unk_14.x, unkStruct->unk_0000[i].unk_14.z) > 278784.03f) {
func_80A9B554(this, globalCtx, unkStruct, &unkStruct->unk_0000[i]);
func_8019F128(NA_SE_EV_GLASSBROKEN_IMPACT);
unkStruct->unk_0000[i].unk_34 = 4;
@@ -540,7 +540,7 @@ void func_80A9C18C(BgHakuginPost* this, GlobalContext* globalCtx) {
Camera* activeCam = GET_ACTIVE_CAM(globalCtx);
s16 quake;
func_8013ECE0(Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z,
func_8013ECE0(Math3D_Dist2DSq(player->actor.world.pos.x, player->actor.world.pos.z,
this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.z),
255, 20, 150);
quake = Quake_Add(activeCam, 3);
@@ -572,7 +572,7 @@ void func_80A9C228(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU
spB8.x = Math_SinS(temp_s0) * temp_f20 + spC8->unk_14.x;
spB8.z = Math_CosS(temp_s0) * temp_f20 + spC8->unk_14.z;
if (Math3D_XZLengthSquared(spB8.x, spB8.z) < SQ(550.0f) + 0.03f) {
if (Math3D_Dist1DSq(spB8.x, spB8.z) < SQ(550.0f) + 0.03f) {
spB8.x += this->dyna.actor.home.pos.x;
spB8.y = spC8->unk_14.y + this->unk_16C + 20.0f;
spB8.z += this->dyna.actor.home.pos.z;
@@ -248,7 +248,7 @@ void func_8088A894(EnArrow* this, GlobalContext* globalCtx) {
return;
}
temp_f0 = Math3D_LengthSquared(&sp68);
temp_f0 = Math3D_Vec3fMagnitudeSq(&sp68);
if (temp_f0 < 1.0f) {
return;
}
@@ -447,7 +447,7 @@ void EnBigslime_UpdateSurfaceNorm(EnBigslime* this) {
vecTriEdge2.y = dynamicVtx12->n.ob[1] - dynamicVtx0->n.ob[1];
vecTriEdge2.z = dynamicVtx12->n.ob[2] - dynamicVtx0->n.ob[2];
Math3D_CrossProduct(&vecTriEdge1, &vecTriEdge2, &vecTriNorm);
Math3D_Vec3f_Cross(&vecTriEdge1, &vecTriEdge2, &vecTriNorm);
EnBigslime_Vec3fNormalize(&vecTriNorm);
Math_Vec3f_Sum(&vtxNorm[sEnbigslimeTri[i].v[0]], &vecTriNorm, &vtxNorm[sEnbigslimeTri[i].v[0]]);
@@ -126,7 +126,7 @@ s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalCon
return false;
}
Math3D_CrossProduct(&this->axisUp, &normal, &vec);
Math3D_Vec3f_Cross(&this->axisUp, &normal, &vec);
magnitude = Math3D_Vec3fMagnitude(&vec);
@@ -139,7 +139,7 @@ s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalCon
Matrix_InsertRotationAroundUnitVector_f(angle, &vec, MTXMODE_NEW);
Matrix_MultiplyVector3fByState(&this->axisLeft, &vec);
Math_Vec3f_Copy(&this->axisLeft, &vec);
Math3D_CrossProduct(&this->axisLeft, &normal, &this->axisForwards);
Math3D_Vec3f_Cross(&this->axisLeft, &normal, &this->axisForwards);
magnitude = Math3D_Vec3fMagnitude(&this->axisForwards);
if (magnitude < 0.001f) {
@@ -229,7 +229,7 @@ void func_8091C794(EnButte* this, GlobalContext* globalCtx) {
EnButteStruct* sp4C = &D_8091D324[this->unk_24E];
f32 distSq;
Player* player = GET_PLAYER(globalCtx);
f32 distFromHomeSq = Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z,
f32 distFromHomeSq = Math3D_Dist2DSq(this->actor.world.pos.x, this->actor.world.pos.z,
this->actor.home.pos.x, this->actor.home.pos.z);
f32 playSpeed;
f32 sp38;
@@ -285,7 +285,7 @@ void func_8091C794(EnButte* this, GlobalContext* globalCtx) {
}
if ((ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) && (player->itemActionParam == 7) && (this->unk_252 <= 0) &&
((Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, this->actor.home.pos.x,
((Math3D_Dist2DSq(player->actor.world.pos.x, player->actor.world.pos.z, this->actor.home.pos.x,
this->actor.home.pos.z) < SQ(120.0f)) ||
(this->actor.xzDistToPlayer < 60.0f))) {
func_8091CB68(this);
@@ -350,13 +350,13 @@ void func_8091CBB4(EnButte* this, GlobalContext* globalCtx) {
D_8091D3F0 = -D_8091D3F0;
}
distSq = Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x,
distSq = Math3D_Dist2DSq(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x,
this->actor.home.pos.z);
if ((player->itemActionParam != 7) || !(fabsf(player->actor.speedXZ) < 1.8f) || (this->unk_252 > 0) ||
!(distSq < SQ(320.0f))) {
func_8091C748(this);
} else if ((distSq > SQ(240.0f)) &&
(Math3D_XZDistanceSquared(player->swordInfo[0].tip.x, player->swordInfo[0].tip.z,
(Math3D_Dist2DSq(player->swordInfo[0].tip.x, player->swordInfo[0].tip.z,
this->actor.world.pos.x, this->actor.world.pos.z) < SQ(60.0f))) {
func_8091CF64(this);
}
@@ -199,7 +199,7 @@ f32 func_8093EB74(EnGoroiwa* this, GlobalContext* globalCtx) {
for (i = 1; i < temp_s4; i++) {
Math_Vec3f_Copy(&sp54, &sp48);
Math_Vec3s_ToVec3f(&sp48, &this->unk_1D0[i]);
temp_f20 += Math3D_Distance(&sp54, &sp48);
temp_f20 += Math3D_Vec3f_DistXYZ(&sp54, &sp48);
}
return temp_f20;
@@ -539,7 +539,7 @@ void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) {
if (this->unk_1E5 & 0x10) {
sp7C = this->unk_1C0;
} else {
temp = Math3D_Distance(&this->actor.world.pos, &this->actor.prevPos);
temp = Math3D_Vec3f_DistXYZ(&this->actor.world.pos, &this->actor.prevPos);
tmp2 = temp / this->unk_1DC;
this->unk_1C0 = tmp2;
sp7C = this->unk_1C0;
@@ -547,12 +547,12 @@ void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) {
sp7C *= this->unk_1C4;
if (!(this->unk_1E5 & 0x10)) {
if (Math3D_LengthSquared(&this->actor.velocity) > 0.1f) {
if (Math3D_Vec3fMagnitudeSq(&this->actor.velocity) > 0.1f) {
Math_Vec3f_Copy(&this->unk_1A8, &this->actor.velocity);
}
}
Math3D_CrossProduct(&D_80942E60, &this->unk_1A8, &sp70);
Math3D_Vec3f_Cross(&D_80942E60, &this->unk_1A8, &sp70);
if (func_8093EAD4(&sp64, &sp70)) {
this->unk_1B4 = sp64;
@@ -1360,7 +1360,7 @@ void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx) {
temp_f20 = this->unk_1DC * 0.9f;
if (spB8.y > 0.0f) {
if (Math3D_AngleBetweenVectors(&D_80942E60, &spB8, &spAC)) {
if (Math3D_CosOut(&D_80942E60, &spB8, &spAC)) {
phi_f12 = 1.0f;
} else {
phi_f12 = 1.0f - SQ(spAC);
+12 -12
View File
@@ -364,7 +364,7 @@ void func_8087B7C0(EnHorse* this, GlobalContext* globalCtx, Path* path) {
for (i = sp68; i < sp60; i++) {
Math_Vec3s_ToVec3f(&sp50, &spA0[i]);
temp_f0 = Math3D_Distance(&this->actor.world.pos, &sp50);
temp_f0 = Math3D_Vec3f_DistXYZ(&this->actor.world.pos, &sp50);
if (temp_f0 < sp64) {
sp64 = temp_f0;
sp68 = i;
@@ -537,7 +537,7 @@ s32 func_8087C38C(GlobalContext* globalCtx, EnHorse* this, Vec3f* arg2) {
return false;
}
eyeDist = Math3D_Distance(arg2, &globalCtx->view.eye);
eyeDist = Math3D_Vec3f_DistXYZ(arg2, &globalCtx->view.eye);
return func_8087C2B8(globalCtx, this, &sp24, sp20) || (eyeDist < 100.0f);
}
@@ -588,7 +588,7 @@ s32 EnHorse_Spawn(EnHorse* this, GlobalContext* globalCtx) {
spawnPos.x = pathPoints[i].x;
spawnPos.y = pathPoints[i].y;
spawnPos.z = pathPoints[i].z;
dist = Math3D_Distance(&player->actor.world.pos, &spawnPos);
dist = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &spawnPos);
if ((minDist < dist) || func_8087C38C(globalCtx, this, &spawnPos)) {
continue;
@@ -614,7 +614,7 @@ s32 EnHorse_Spawn(EnHorse* this, GlobalContext* globalCtx) {
spawnPos.x = pathPoints[i].x;
spawnPos.y = pathPoints[i].y;
spawnPos.z = pathPoints[i].z;
dist = Math3D_Distance(&player->actor.world.pos, &spawnPos);
dist = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &spawnPos);
if (minDist < dist) {
continue;
@@ -2484,7 +2484,7 @@ void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAc
endPos.y = action->endPos.y;
endPos.z = action->endPos.z;
if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) {
if (Math3D_Vec3f_DistXYZ(&endPos, &this->actor.world.pos) > 8.0f) {
EnHorse_RotateToPoint(this, globalCtx, &endPos, 0x320);
this->actor.speedXZ = 8.0f;
this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f;
@@ -2665,7 +2665,7 @@ void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdAct
endPos.y = action->endPos.y;
endPos.z = action->endPos.z;
if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) {
if (Math3D_Vec3f_DistXYZ(&endPos, &this->actor.world.pos) > 8.0f) {
EnHorse_RotateToPoint(this, globalCtx, &endPos, 0x320);
this->actor.speedXZ = 8.0f;
this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f;
@@ -2801,7 +2801,7 @@ s32 EnHorse_UpdateHbaRaceInfo(EnHorse* this, GlobalContext* globalCtx, RaceInfo*
func_8017B7F8(&pos, raceInfo->waypoints[this->curRaceWaypoint].angle, &px, &pz, &d);
if ((this->curRaceWaypoint >= (raceInfo->numWaypoints - 1)) &&
(Math3D_Distance(&pos, &this->actor.world.pos) < DREG(8))) {
(Math3D_Vec3f_DistXYZ(&pos, &this->actor.world.pos) < DREG(8))) {
this->hbaFlags |= 2;
}
@@ -2971,9 +2971,9 @@ void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) {
}
}
distToHome = Math3D_Distance(&this->actor.home.pos, &this->actor.world.pos);
playerDistToHome = Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos);
distToPlayer = Math3D_Distance(&player->actor.world.pos, &this->actor.world.pos);
distToHome = Math3D_Vec3f_DistXYZ(&this->actor.home.pos, &this->actor.world.pos);
playerDistToHome = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &this->actor.home.pos);
distToPlayer = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &this->actor.world.pos);
if (playerDistToHome > 300.0f) {
if (distToHome > 150.0f) {
@@ -3330,7 +3330,7 @@ void func_808848C8(EnHorse* this, GlobalContext* globalCtx) {
func_800F415C(&this->actor, &sp24, 2000);
this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f;
SkelAnime_Update(&this->skin.skelAnime);
if (Math3D_Distance(&sp24, &this->actor.world.pos) < 30.0f) {
if (Math3D_Vec3f_DistXYZ(&sp24, &this->actor.world.pos) < 30.0f) {
this->stateFlags &= ~ENHORSE_UNRIDEABLE;
EnHorse_StartIdleRidable(this);
}
@@ -3425,7 +3425,7 @@ void func_80884E0C(EnHorse* this, GlobalContext* globalCtx) {
this->actor.world.pos.x = this->unk_570.x;
this->actor.world.pos.z = this->unk_570.z;
this->unk_56C = Math3D_Distance(&this->actor.world.pos, &this->actor.prevPos);
this->unk_56C = Math3D_Vec3f_DistXYZ(&this->actor.world.pos, &this->actor.prevPos);
if (((this->unk_550 == 5) || (this->unk_550 == 7)) && (Player_GetMask(globalCtx) != PLAYER_MASK_CIRCUS_LEADER)) {
this->rider->unk488 = 7;
} else {
@@ -790,7 +790,7 @@ f32 EnInvadepoh_GetTotalPathLength(EnInvadepoh* this) {
for (i = 1; i < temp_s4; i++) {
Math_Vec3f_Copy(&sp54, &pathPointF);
Math_Vec3s_ToVec3f(&pathPointF, pathPoint);
distance = Math3D_Distance(&sp54, &pathPointF);
distance = Math3D_Vec3f_DistXYZ(&sp54, &pathPointF);
pathPoint++;
totalDistance += distance;
}
@@ -841,7 +841,7 @@ s32 func_80B440B8(EnInvadepoh* this, f32 arg1, f32 arg2) {
}
temp_f12_2 = (sp2C * sp38) + (sp30 * sp34);
new_var = Math3D_XZLength(sp40, sp3C);
new_var = Math3D_Dist1D(sp40, sp3C);
if ((temp_f12_2 < 0.0f) || (new_var < temp_f12_2)) {
return false;
@@ -913,7 +913,7 @@ void func_80B443A0(EnInvadepoh* this) {
for (i = 1; i < temp_s5; i++, phi_s1++, phi_s0++) {
Math_Vec3f_Copy(&sp70, &sp64);
Math_Vec3s_ToVec3f(&sp64, phi_s1);
phi_f20 += Math3D_Distance(&sp70, &sp64);
phi_f20 += Math3D_Vec3f_DistXYZ(&sp70, &sp64);
*phi_s0 = phi_f20 * pathTotalDistInv;
if (*phi_s0 < 0.0f) {
*phi_s0 = 0.0f;
@@ -1153,7 +1153,7 @@ s32 func_80B44C80(EnInvadepoh* this, GlobalContext* globalCtx) {
temp_f0_2 = temp_f2 - this->actor.world.pos.z;
if (this->actor.speedXZ > 0.0f) {
if (Math3D_AngleBetweenVectors(&sp6C, &sp60, &sp44) != 0) {
if (Math3D_CosOut(&sp6C, &sp60, &sp44) != 0) {
sp40 = 1;
} else if (sp44 <= 0.0f) {
sp40 = 1;
@@ -1231,7 +1231,7 @@ void func_80B45080(void) {
s32 func_80B450C0(f32* x1, f32* z1, f32 x2, f32 z2, f32 speed) {
f32 deltaX = x2 - *x1;
f32 deltaZ = z2 - *z1;
f32 temp_f0 = Math3D_XZLength(deltaX, deltaZ);
f32 temp_f0 = Math3D_Dist1D(deltaX, deltaZ);
if (speed < temp_f0) {
f32 temp_f2 = speed / temp_f0;
+1 -1
View File
@@ -314,7 +314,7 @@ void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) {
Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY);
Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY);
Matrix_GetStateTranslationAndScaledY(1.0f, &sp30);
sp2C = Math3D_Parallel(&sp30, &D_8095F778);
sp2C = Math3D_Cos(&sp30, &D_8095F778);
if (sp2C < 0.707f) {
temp_v1_2 = Math_FAtan2F(sp30.z, sp30.x) - sp3C->world.rot.y;
if (ABS_ALT(temp_v1_2) > 0x4000) {
@@ -511,7 +511,7 @@ void func_80A5C410(EnKusa2UnkBssStruct* arg0, EnKusa2UnkBssSubStruct2* arg1, Vec
s32 phi_s2 = true;
Math_Vec3f_Diff(&arg1->unk_04, &s->unk_00, &sp98);
temp_f0 = Math3D_LengthSquared(&sp98);
temp_f0 = Math3D_Vec3fMagnitudeSq(&sp98);
phi_v0 = false;
if (temp_f0 <= s->unk_4C) {
@@ -917,7 +917,7 @@ void func_80A5D62C(EnKusa2* this, GlobalContext* globalCtx) {
if (this->unk_1BE != 0) {
func_80A5B490(this, globalCtx);
func_80A5D754(this);
} else if (Math3D_XZLengthSquared(this->actor.projectedPos.x, this->actor.projectedPos.z) < SQ(1600.0f)) {
} else if (Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z) < SQ(1600.0f)) {
func_80A5B160(this, globalCtx);
func_80A5D6B0(this);
}
@@ -932,7 +932,7 @@ void func_80A5D6C4(EnKusa2* this, GlobalContext* globalCtx) {
if (this->unk_1BE != 0) {
func_80A5B490(this, globalCtx);
func_80A5D754(this);
} else if (Math3D_XZLengthSquared(this->actor.projectedPos.x, this->actor.projectedPos.z) > SQ(1750.0f)) {
} else if (Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z) > SQ(1750.0f)) {
func_80A5B334(this, globalCtx);
func_80A5D618(this);
}
@@ -151,7 +151,7 @@ s32 func_80A68910(EnMushi2* this, GlobalContext* globalCtx) {
params = OBJBEAN_GET_C000(bean);
if (((params == ENOBJBEAN_GET_C000_1) || (params == ENOBJBEAN_GET_C000_2)) &&
(bean->room == this->actor.room)) {
temp_f0 = Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, bean->world.pos.x,
temp_f0 = Math3D_Dist2DSq(this->actor.world.pos.x, this->actor.world.pos.z, bean->world.pos.x,
bean->world.pos.z);
temp_f2 = bean->world.pos.y - this->actor.world.pos.y;
if ((temp_f0 < minDistSq) && (temp_f2 < 100.0f) && (temp_f2 > -50.0f)) {
@@ -234,7 +234,7 @@ s32 func_80A68CE4(Vec3f* arg0, Vec3f* arg1, f32 arg2) {
f32 temp_f2;
Math_Vec3f_Diff(arg1, arg0, &sp34);
temp_f0 = Math3D_LengthSquared(&sp34);
temp_f0 = Math3D_Vec3fMagnitudeSq(&sp34);
temp_f2 = arg2 + 0.01f;
if (temp_f0 <= SQ(temp_f2)) {
Math_Vec3f_Copy(arg0, arg1);
@@ -266,7 +266,7 @@ s32 func_80A68DD4(EnMushi2* this, GlobalContext* globalCtx) {
player = GET_PLAYER(globalCtx);
sp2E = BINANG_ROT180(this->actor.yawTowardsPlayer);
sp24 = Math_SinS(sp2E);
if (Math3D_XZDistanceSquared((sp24 * 16.0f) + player->actor.world.pos.x,
if (Math3D_Dist2DSq((sp24 * 16.0f) + player->actor.world.pos.x,
(Math_CosS(sp2E) * 16.0f) + player->actor.world.pos.z, this->actor.world.pos.x,
this->actor.world.pos.z) < SQ(20.0f)) {
return true;
@@ -408,8 +408,8 @@ s32 func_80A691EC(EnMushi2* this, CollisionPoly* floorPoly, f32 arg2) {
sp30 = 1;
}
Math3D_CrossProduct(&this->unk_310, &sp4C, &sp40);
Math3D_CrossProduct(&sp4C, &sp40, &sp64);
Math3D_Vec3f_Cross(&this->unk_310, &sp4C, &sp40);
Math3D_Vec3f_Cross(&sp4C, &sp40, &sp64);
if (func_80A68C5C(&sp64, &sp58) && func_80A68C5C(&sp40, &sp34)) {
Math_Vec3f_Copy(&this->unk_31C, &sp4C);
@@ -610,7 +610,7 @@ void func_80A69ADC(Actor* thisx) {
this->unk_328.x, this->unk_328.y, this->unk_328.z,
func_80A69AA8(this->unk_328.x, this->unk_328.y, this->unk_328.z, &this->actor.world.pos),
&bean->dyna.actor.world.pos);
sp3C = Math3D_XZLength(sp44, sp40);
sp3C = Math3D_Dist1D(sp44, sp40);
if (fabsf(sp3C) > 0.1f) {
this->unk_360 = (Rand_ZeroOne() * 3000.0f * (this->unk_358 - 1.0f)) + (((sp40 / sp3C) - 1.0f) * -1500.0f);
@@ -656,7 +656,7 @@ void func_80A69D3C(EnMushi2* this) {
this->unk_328.x, this->unk_328.y, this->unk_328.z,
func_80A69AA8(this->unk_328.x, this->unk_328.y, this->unk_328.z, &this->actor.world.pos),
&this->unk_34C->dyna.actor.world.pos);
sp38 = Math3D_XZLengthSquared(sp40, sp3C);
sp38 = Math3D_Dist1DSq(sp40, sp3C);
if (fabsf(sp38) > 0.010000001f) {
s16 temp_v0 = Math_FAtan2F(sp3C, sp40);
+1 -1
View File
@@ -856,7 +856,7 @@ s32 EnOt_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* ac
sp44.y = actorPath->curPoint.y - actorPath->prevPoint.y;
sp44.z = actorPath->curPoint.z - actorPath->prevPoint.z;
temp = Math3D_Parallel(&sp50, &sp44);
temp = Math3D_Cos(&sp50, &sp44);
if ((actorPath->distSqToCurPointXZ < SQ(thisx->speedXZ)) || (temp <= 0.0f)) {
ret = true;
} else {

Some files were not shown because too many files have changed in this diff Show More