Merge branch 'sys_math3d_bss' of https://github.com/Decompollaborate/mm into zret

This commit is contained in:
RevoSucks
2023-10-31 19:16:20 -04:00
76 changed files with 3184 additions and 983 deletions
-95
View File
@@ -1114,101 +1114,6 @@ void CmpDma_LoadAllFiles(uintptr_t segmentVrom, void* dst, size_t size);
void Check_ExpansionPak(void);
void Check_RegionIsSupported(void);
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);
f32 func_80179A44(Vec3f* arg0, PosRot* arg1, Vec3f* arg2);
void func_80179B34(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32* arg7, f32* arg8);
// UNK_TYPE4 func_80179B94(f32 fParm1, f32 fParm2, f32 fParm5, f32 param_4, f32 param_5, f32 param_6, f32 param_7, f32 param_8, Vec3f* param_9);
// 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);
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_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 func_8017A7B8(f32* param_1, f32* param_2, f32 param_3, f32 param_4);
f32 func_8017A7F8(f32* param_1, f32* param_2, f32 param_3, f32 param_4);
f32 func_8017A838(f32* param_1, f32* param_2, f32 param_3, f32 param_4);
void Math3D_CrossProduct(Vec3f* a, Vec3f* b, Vec3f* res);
void Math3D_SurfaceNorm(Vec3f* a, Vec3f* b, Vec3f* c, Vec3f* res);
u32 Math3D_PointRelativeToCubeFaces(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3);
u32 Math3D_PointRelativeToCubeEdges(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3);
u32 Math3D_PointRelativeToCubeVertices(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3);
s32 Math3D_LineVsCube(Vec3f* min, Vec3f* max, Vec3f* a, Vec3f* b);
// void func_8017B68C(void);
void func_8017B7F8(Vec3f* arg0, s16 arg1, f32* arg2, f32* arg3, f32* arg4);
void Math3D_UnitNormalVector(Vec3f* a, Vec3f* b, Vec3f* c, f32* normX, f32* normY, f32* normZ, f32* param_7);
f32 Math3D_SignedDistanceFromPlane(f32 normX, f32 normY, f32 normZ, f32 d, Vec3f* position);
// void func_8017B9D8(void);
f32 Math3D_UDistPlaneToPos(f32 normX, f32 normY, f32 normZ, f32 d, Vec3f* position);
f32 Math3D_DistPlaneToPos(f32 normX, f32 normY, f32 normZ, f32 d, Vec3f* position);
s32 Math3D_TriChkPointParaYDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 y, f32 z, f32 unk, f32 chkDist, f32 ny);
// void func_8017BD98(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);
// void func_8017BDE0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
s32 Math3D_TriChkPointParaYIntersectDist(Vec3f* a, Vec3f* b, Vec3f* c, f32 nx, f32 ny, f32 nz, f32 dist, f32 z, f32 x, f32* yIntersect, f32 chkDist);
s32 Math3D_TriChkPointParaYIntersectInsideTri(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist);
// void func_8017BF8C(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 Math3D_TriChkLineSegParaYIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 y0, f32 y1);
// void func_8017C17C(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);
// void func_8017C1F0(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);
s32 Math3D_TriChkPointParaYIntersectInsideTri2(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist);
s32 Math3D_TriChkPointParaXDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 y, f32 z, f32 unk, f32 chkDist, f32 nx);
// void func_8017C808(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);
s32 Math3D_TriChkPointParaXIntersect(Vec3f* a, Vec3f* b, Vec3f* c, f32 nx, f32 ny, f32 nz, f32 dist, f32 y, f32 z, f32* xIntersect);
// void func_8017C904(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 Math3D_TriChkLineSegParaXIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, f32 z, f32* xIntersect, f32 x0, f32 x1);
// void func_8017CB08(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);
s32 Math3D_TriChkLineSegParaZDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 y, f32 z, f32 unk, f32 chkDist, f32 nz);
// void func_8017CEA8(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);
s32 Math3D_TriChkPointParaZIntersect(Vec3f* a, Vec3f* b, Vec3f* c, f32 nx, f32 ny, f32 nz, f32 dist, f32 x, f32 y, f32* zIntersect);
// void func_8017CFA4(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 Math3D_TriChkLineSegParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, f32 y, f32* zIntersect, f32 z0, f32 z1);
// void func_8017D1AC(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);
// void func_8017D220(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
s32 Math3D_LineSegVsPlane(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect, s32 fromFront);
// void func_8017D404(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, UNK_TYPE4 param_11);
void Math3D_TriSetCoords(TriNorm* tri, Vec3f* pointA, Vec3f* pointB, Vec3f* pointC);
u32 Math3D_IsPointInSphere(Sphere16* sphere, Vec3f* point);
s32 Math3D_PointDistToLine2D(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32* arg6, f32* arg7, f32* arg8); // returns boolean
s32 func_8017D7C0(f32 x0, f32 y0, f32 x1, f32 y1, f32 x2, f32 y2, f32* lineLenSq);
// void func_8017D814(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
// void func_8017D91C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
// void func_8017DA24(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
s32 Math3D_LineVsSph(Sphere16* sphere, LineSegment* line);
void func_8017DD34(Sphere16* sphere, TriNorm* tri, Vec3f* pfParm3);
s32 Math3D_ColSphereTri(Sphere16* sphere, TriNorm* tri, Vec3f* uParm3);
// void func_8017E294(void);
UNK_TYPE func_8017E350(UNK_PTR, Vec3f*, Vec3f*, Vec3f*, Vec3f*);
s32 Math3D_ColCylinderTri(Cylinder16* cylinder, TriNorm* tri, Vec3f* pzParm3);
// void func_8017F1A0(void);
s32 Math3D_SphVsSph(Sphere16* sphere1, Sphere16* sphere2);
s32 Math3D_ColSphereSphereIntersect(Sphere16* sphere1, Sphere16* sphere2, f32* intersectAmount);
s32 Math3D_ColSphereSphereIntersectAndDistance(Sphere16* sphere1, Sphere16* sphere2, f32* intersectAmount, f32* dist);
s32 Math3D_ColSphereCylinderDistance(Sphere16* sphere, Cylinder16* cylinder, f32* dist);
s32 Math3D_ColSphereCylinderDistanceAndAmount(Sphere16* sphere, Cylinder16* cylinder, f32* dist, f32* intersectAmount);
s32 Math3D_ColCylinderCylinderAmount(Cylinder16* cylinder1, Cylinder16* cylinder2, f32* intersectAmount);
s32 Math3D_ColCylinderCylinderAmountAndDistance(Cylinder16* cylinder1, Cylinder16* cylinder2, f32* intersectAmount, f32* dist);
s32 Math3d_ColTriTri(TriNorm* tri1, TriNorm* tri2, Vec3f* uParm3);
s32 Math3D_XZInSphere(Sphere16* sphere, f32 x, f32 z);
s32 Math3D_XYInSphere(Sphere16* sphere, f32 x, f32 y);
s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z);
// void func_8017FB1C(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, UNK_TYPE4 param_11);
// void func_8017FD44(void);
u64* SysUcode_GetUCodeBoot(void);
size_t SysUcode_GetUCodeBootSize(void);
u64* SysUcode_GetUCode(void);
-3
View File
@@ -84,9 +84,6 @@
#define VTX_T(x, y, z, s, t, cr, cg, cb, a) \
{ { x, y, z }, 0, { s, t }, { cr, cg, cb, a }, }
#define SQ(x) ((x) * (x))
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define ABS_ALT(x) ((x) < 0 ? -(x) : (x))
#define DECR(x) ((x) == 0 ? 0 : --(x))
//! checks min first
+2 -74
View File
@@ -1617,14 +1617,14 @@ extern Vec3f D_801EDE20;
extern Vec3f D_801EDE30;
extern TriNorm D_801EDE40;
extern TriNorm D_801EDE78;
extern LineSegment D_801EDEB0;
extern Linef D_801EDEB0;
extern TriNorm D_801EDEC8;
extern TriNorm D_801EDF00;
extern Vec3f D_801EDF38;
extern Vec3f D_801EDF48;
extern TriNorm D_801EDF58;
extern TriNorm D_801EDF90;
extern LineSegment D_801EDFC8;
extern Linef D_801EDFC8;
extern Vec3f D_801EDFE0;
extern Vec3f D_801EDFF0;
extern TriNorm D_801EE000;
@@ -1691,78 +1691,6 @@ extern GfxMasterList* gGfxMasterDL;
extern u64* gAudioSPDataPtr;
extern u32 gAudioSPDataSize;
extern Vec3f D_801FBBF0;
extern LineSegment Math3D_ColSphereTri_line;
extern Vec3f Math3D_ColSphereTri_point;
// extern UNK_TYPE1 D_801FBC28;
// extern UNK_TYPE1 D_801FBC2C;
// extern UNK_TYPE1 D_801FBC30;
// extern UNK_TYPE1 D_801FBC38;
// extern UNK_TYPE1 D_801FBC3A;
// extern UNK_TYPE1 D_801FBC3C;
// extern UNK_TYPE1 D_801FBC3E;
// extern UNK_TYPE1 D_801FBC40;
// extern UNK_TYPE1 D_801FBC42;
// extern UNK_TYPE1 D_801FBC44;
// extern UNK_TYPE1 D_801FBC46;
// extern UNK_TYPE1 D_801FBC48;
// extern UNK_TYPE1 D_801FBC58;
extern Vec3f Math3D_NormalVector_temp1;
extern Vec3f Math3D_NormalVector_temp2;
extern f32 D_801FBC8C;
extern f32 D_801FBC90;
extern f32 D_801FBC98;
extern f32 D_801FBCA4;
extern f32 D_801FBCAC;
extern f32 D_801FBCB0;
extern f32 D_801FBCB4;
extern f32 D_801FBCB8;
extern f32 D_801FBCBC;
extern f32 D_801FBCC0;
extern f32 D_801FBCC4;
extern f32 D_801FBCC8;
extern f32 D_801FBCCC;
extern f32 D_801FBCD0;
extern f32 D_801FBCD4;
extern f32 D_801FBCD8;
extern f32 D_801FBCDC;
// extern UNK_TYPE1 D_801FBCE0;
// extern UNK_TYPE1 D_801FBCE4;
// extern UNK_TYPE1 D_801FBCE8;
// extern UNK_TYPE1 D_801FBCF0;
// extern UNK_TYPE1 D_801FBCF4;
// extern UNK_TYPE1 D_801FBCF8;
// extern UNK_TYPE1 D_801FBD00;
// extern UNK_TYPE1 D_801FBD04;
// extern UNK_TYPE1 D_801FBD08;
// extern UNK_TYPE1 D_801FBD10;
// extern UNK_TYPE1 D_801FBD20;
// extern UNK_TYPE1 D_801FBD24;
// extern UNK_TYPE1 D_801FBD28;
// extern UNK_TYPE1 D_801FBD30;
// extern UNK_TYPE1 D_801FBD34;
// extern UNK_TYPE1 D_801FBD38;
// extern UNK_TYPE1 D_801FBD40;
// extern UNK_TYPE1 D_801FBD44;
// extern UNK_TYPE1 D_801FBD48;
// extern UNK_TYPE1 D_801FBD50;
// extern UNK_TYPE1 D_801FBD54;
// extern UNK_TYPE1 D_801FBD58;
extern Vec3f Math3D_UnitNormalVector_temp;
// extern UNK_TYPE1 D_801FBD70;
// extern UNK_TYPE1 D_801FBD74;
// extern UNK_TYPE1 D_801FBD78;
extern Vec3f D_801FBD80[2];
extern Vec3f D_801FBD98;
extern Vec3f D_801FBDA4;
// extern UNK_TYPE1 D_801FBDB0;
// extern UNK_TYPE1 D_801FBDB4;
// extern UNK_TYPE1 D_801FBDB8;
// extern UNK_TYPE1 D_801FBDC0;
// extern UNK_TYPE1 D_801FBDD8;
// extern UNK_TYPE1 D_801FBDDC;
// extern UNK_TYPE1 D_801FBDE0;
extern Vec3f D_801FBDE8;
extern MtxF* sMatrixStack;
extern MtxF* sCurrentMatrix;
+2 -2
View File
@@ -2,6 +2,7 @@
#define Z64CAMERA_H
#include "ultra64.h"
#include "z64math.h"
#include "z64actor.h"
#include "z64save.h"
#include "unk.h"
@@ -1193,8 +1194,7 @@ typedef struct {
/* 0x00 */ Vec3f unk_00;
/* 0x0C */ Vec3f unk_0C;
/* 0x18 */ f32 unk_18;
/* 0x1C */ Vec3f unk_1C;
/* 0x28 */ Vec3f unk_28;
/* 0x1C */ InfiniteLine unk_1C;
/* 0x34 */ Vec3s unk_34;
/* 0x3A */ s16 unk_3A;
/* 0x3C */ s16 timer;
+86 -86
View File
@@ -10,100 +10,100 @@ struct PlayState;
typedef struct {
/* 0x00 */ struct Actor* actor; // Attached actor
/* 0x04 */ struct Actor* at; // Actor attached to what it collided with as an AT collider.
/* 0x08 */ struct Actor* ac; // Actor attached to what it collided with as an AC collider.
/* 0x0C */ struct Actor* oc; // Actor attached to what it collided with as an OC collider.
/* 0x10 */ u8 atFlags; // Information flags for AT collisions.
/* 0x11 */ u8 acFlags; // Information flags for AC collisions.
/* 0x12 */ u8 ocFlags1; // Information flags for OC collisions.
/* 0x13 */ u8 ocFlags2; // Flags related to which colliders it can OC collide with.
/* 0x14 */ u8 colType; // Determines hitmarks and sound effects during AC collisions.
/* 0x15 */ u8 shape; // JntSph, Cylinder, Tris, or Quad
/* 0x04 */ struct Actor* at; // Actor attached to what it collided with as an AT collider.
/* 0x08 */ struct Actor* ac; // Actor attached to what it collided with as an AC collider.
/* 0x0C */ struct Actor* oc; // Actor attached to what it collided with as an OC collider.
/* 0x10 */ u8 atFlags; // Information flags for AT collisions.
/* 0x11 */ u8 acFlags; // Information flags for AC collisions.
/* 0x12 */ u8 ocFlags1; // Information flags for OC collisions.
/* 0x13 */ u8 ocFlags2; // Flags related to which colliders it can OC collide with.
/* 0x14 */ u8 colType; // Determines hitmarks and sound effects during AC collisions.
/* 0x15 */ u8 shape; // JntSph, Cylinder, Tris, or Quad
} Collider; // size = 0x18
typedef struct {
/* 0x0 */ u8 colType; // Determines hitmarks and sound effects during AC collisions.
/* 0x1 */ u8 atFlags; // Information flags for AT collisions.
/* 0x2 */ u8 acFlags; // Information flags for OC collisions.
/* 0x0 */ u8 colType; // Determines hitmarks and sound effects during AC collisions.
/* 0x1 */ u8 atFlags; // Information flags for AT collisions.
/* 0x2 */ u8 acFlags; // Information flags for OC collisions.
/* 0x3 */ u8 ocFlags1; // Information flags for OC collisions.
/* 0x4 */ u8 ocFlags2; // Flags related to which colliders it can OC collide with.
/* 0x5 */ u8 shape; // JntSph, Cylinder, Tris, or Quad
/* 0x5 */ u8 shape; // JntSph, Cylinder, Tris, or Quad
} ColliderInit; // size = 0x6
typedef struct {
/* 0x0 */ u8 colType; // Determines hitmarks and sound effects during AC collisions.
/* 0x1 */ u8 atFlags; // Information flags for AT collisions.
/* 0x2 */ u8 acFlags; // Information flags for AC collisions.
/* 0x0 */ u8 colType; // Determines hitmarks and sound effects during AC collisions.
/* 0x1 */ u8 atFlags; // Information flags for AT collisions.
/* 0x2 */ u8 acFlags; // Information flags for AC collisions.
/* 0x3 */ u8 ocFlags1; // Information flags for OC collisions.
/* 0x4 */ u8 shape; // JntSph, Cylinder, Tris, or Quad
/* 0x4 */ u8 shape; // JntSph, Cylinder, Tris, or Quad
} ColliderInitType1; // size = 0x5
typedef struct {
/* 0x0 */ struct Actor* actor; // Attached actor
/* 0x4 */ u8 atFlags; // Information flags for AT collisions.
/* 0x5 */ u8 acFlags; // Information flags for AC collisions.
/* 0x6 */ u8 ocFlags1; // Information flags for OC collisions.
/* 0x7 */ u8 shape; // JntSph, Cylinder, Tris, or Quad
/* 0x4 */ u8 atFlags; // Information flags for AT collisions.
/* 0x5 */ u8 acFlags; // Information flags for AC collisions.
/* 0x6 */ u8 ocFlags1; // Information flags for OC collisions.
/* 0x7 */ u8 shape; // JntSph, Cylinder, Tris, or Quad
} ColliderInitToActor; // size = 0x8
typedef struct {
/* 0x0 */ u32 dmgFlags; // Toucher damage type flags.
/* 0x4 */ u8 effect; // Damage Effect (Knockback, Fire, etc.)
/* 0x5 */ u8 damage; // Damage or Stun Timer
/* 0x0 */ u32 dmgFlags; // Toucher damage type flags.
/* 0x4 */ u8 effect; // Damage Effect (Knockback, Fire, etc.)
/* 0x5 */ u8 damage; // Damage or Stun Timer
} ColliderTouch; // size = 0x8
typedef struct {
/* 0x0 */ u32 dmgFlags; // Toucher damage type flags.
/* 0x4 */ u8 effect; // Damage Effect (Knockback, Fire, etc.)
/* 0x5 */ u8 damage; // Damage or Stun Timer
/* 0x0 */ u32 dmgFlags; // Toucher damage type flags.
/* 0x4 */ u8 effect; // Damage Effect (Knockback, Fire, etc.)
/* 0x5 */ u8 damage; // Damage or Stun Timer
} ColliderTouchInit; // size = 0x8
typedef struct {
/* 0x0 */ u32 dmgFlags; // Bumper damage type flags.
/* 0x4 */ u8 effect; // Damage Effect (Knockback, Fire, etc.)
/* 0x5 */ u8 defense; // Damage Resistance
/* 0x6 */ Vec3s hitPos; // Point of contact
/* 0x0 */ u32 dmgFlags; // Bumper damage type flags.
/* 0x4 */ u8 effect; // Damage Effect (Knockback, Fire, etc.)
/* 0x5 */ u8 defense; // Damage Resistance
/* 0x6 */ Vec3s hitPos; // Point of contact
} ColliderBump; // size = 0xC
typedef struct {
/* 0x0 */ u32 dmgFlags; // Bumper exclusion mask
/* 0x4 */ u8 effect; // Damage Effect (Knockback, Fire, etc.)
/* 0x5 */ u8 defense; // Damage Resistance
/* 0x0 */ u32 dmgFlags; // Bumper exclusion mask
/* 0x4 */ u8 effect; // Damage Effect (Knockback, Fire, etc.)
/* 0x5 */ u8 defense; // Damage Resistance
} ColliderBumpInit; // size = 0x8
typedef struct ColliderInfo {
/* 0x00 */ ColliderTouch toucher; // Damage properties when acting as an AT collider
/* 0x08 */ ColliderBump bumper; // Damage properties when acting as an AC collider
/* 0x14 */ u8 elemType; // Affects sfx reaction when attacked by Link and hookability. Full purpose unknown.
/* 0x15 */ u8 toucherFlags; // Information flags for AT collisions
/* 0x16 */ u8 bumperFlags; // Information flags for AC collisions
/* 0x17 */ u8 ocElemFlags; // Information flags for OC collisions
/* 0x18 */ Collider* atHit; // object touching this element's AT collider
/* 0x1C */ Collider* acHit; // object touching this element's AC collider
/* 0x20 */ struct ColliderInfo* atHitInfo; // element that hit the AT collider
/* 0x24 */ struct ColliderInfo* acHitInfo; // element that hit the AC collider
/* 0x00 */ ColliderTouch toucher; // Damage properties when acting as an AT collider
/* 0x08 */ ColliderBump bumper; // Damage properties when acting as an AC collider
/* 0x14 */ u8 elemType; // Affects sfx reaction when attacked by Link and hookability. Full purpose unknown.
/* 0x15 */ u8 toucherFlags; // Information flags for AT collisions
/* 0x16 */ u8 bumperFlags; // Information flags for AC collisions
/* 0x17 */ u8 ocElemFlags; // Information flags for OC collisions
/* 0x18 */ Collider* atHit; // object touching this element's AT collider
/* 0x1C */ Collider* acHit; // object touching this element's AC collider
/* 0x20 */ struct ColliderInfo* atHitInfo; // element that hit the AT collider
/* 0x24 */ struct ColliderInfo* acHitInfo; // element that hit the AC collider
} ColliderInfo; // size = 0x28
typedef struct {
/* 0x00 */ u8 elemType; // Affects sfx reaction when attacked by Link and hookability. Full purpose unknown.
/* 0x04 */ ColliderTouchInit toucher; // Damage properties when acting as an AT collider
/* 0x0C */ ColliderBumpInit bumper; // Damage properties when acting as an AC collider
/* 0x14 */ u8 toucherFlags; // Information flags for AT collisions
/* 0x15 */ u8 bumperFlags; // Information flags for AC collisions
/* 0x16 */ u8 ocElemFlags; // Information flags for OC collisions
/* 0x00 */ u8 elemType; // Affects sfx reaction when attacked by Link and hookability. Full purpose unknown.
/* 0x04 */ ColliderTouchInit toucher; // Damage properties when acting as an AT collider
/* 0x0C */ ColliderBumpInit bumper; // Damage properties when acting as an AC collider
/* 0x14 */ u8 toucherFlags; // Information flags for AT collisions
/* 0x15 */ u8 bumperFlags; // Information flags for AC collisions
/* 0x16 */ u8 ocElemFlags; // Information flags for OC collisions
} ColliderInfoInit; // size = 0x18
typedef struct {
/* 0x00 */ Sphere16 modelSphere; // model space sphere
/* 0x08 */ Sphere16 worldSphere; // world space sphere
/* 0x10 */ f32 scale; // worldsphere = modelsphere * scale * 0.01
/* 0x14 */ u8 limb; // attached limb
/* 0x00 */ Sphere16 modelSphere; // model space sphere
/* 0x08 */ Sphere16 worldSphere; // world space sphere
/* 0x10 */ f32 scale; // worldsphere = modelsphere * scale * 0.01
/* 0x14 */ u8 limb; // attached limb
} ColliderJntSphElementDim; // size = 0x18
typedef struct {
/* 0x0 */ u8 limb; // attached limb
/* 0x2 */ Sphere16 modelSphere; // model space sphere
/* 0xA */ s16 scale; // world space sphere = model * scale * 0.01
/* 0x0 */ u8 limb; // attached limb
/* 0x2 */ Sphere16 modelSphere; // model space sphere
/* 0xA */ s16 scale; // world space sphere = model * scale * 0.01
} ColliderJntSphElementDimInit; // size = 0xC
typedef struct {
@@ -141,27 +141,27 @@ typedef struct {
} ColliderJntSphInitToActor; // size = 0x10
typedef struct {
/* 0x00 */ Collider base;
/* 0x00 */ Collider base;
/* 0x18 */ ColliderInfo info;
/* 0x40 */ Cylinder16 dim;
/* 0x40 */ Cylinder16 dim;
} ColliderCylinder; // size = 0x4C
typedef struct {
/* 0x00 */ ColliderInit base;
/* 0x00 */ ColliderInit base;
/* 0x08 */ ColliderInfoInit info;
/* 0x20 */ Cylinder16 dim;
/* 0x20 */ Cylinder16 dim;
} ColliderCylinderInit; // size = 0x2C
typedef struct {
/* 0x00 */ ColliderInitType1 base;
/* 0x08 */ ColliderInfoInit info;
/* 0x20 */ Cylinder16 dim;
/* 0x08 */ ColliderInfoInit info;
/* 0x20 */ Cylinder16 dim;
} ColliderCylinderInitType1; // size = 0x2C
typedef struct {
/* 0x00 */ ColliderInitToActor base;
/* 0x08 */ ColliderInfoInit info;
/* 0x20 */ Cylinder16 dim;
/* 0x08 */ ColliderInfoInit info;
/* 0x20 */ Cylinder16 dim;
} ColliderCylinderInitToActor; // size = 0x2C
typedef struct {
@@ -170,7 +170,7 @@ typedef struct {
typedef struct {
/* 0x00 */ ColliderInfo info;
/* 0x28 */ TriNorm dim;
/* 0x28 */ TriNorm dim;
} ColliderTrisElement; // size = 0x5C
typedef struct {
@@ -198,9 +198,9 @@ typedef struct {
typedef struct {
/* 0x00 */ Vec3f quad[4];
/* 0x30 */ Vec3s dcMid; // midpoint of vectors d, c
/* 0x36 */ Vec3s baMid; // midpoint of vectors b, a
/* 0x3C */ f32 acDist; // distance to nearest AC collision this frame.
/* 0x30 */ Vec3s dcMid; // midpoint of vectors d, c
/* 0x36 */ Vec3s baMid; // midpoint of vectors b, a
/* 0x3C */ f32 acDist; // distance to nearest AC collision this frame.
} ColliderQuadDim; // size = 0x40
typedef struct {
@@ -208,50 +208,50 @@ typedef struct {
} ColliderQuadDimInit; // size = 0x30
typedef struct {
/* 0x00 */ Collider base;
/* 0x18 */ ColliderInfo info;
/* 0x00 */ Collider base;
/* 0x18 */ ColliderInfo info;
/* 0x40 */ ColliderQuadDim dim;
} ColliderQuad; // size = 0x80
typedef struct {
/* 0x00 */ ColliderInit base;
/* 0x08 */ ColliderInfoInit info;
/* 0x00 */ ColliderInit base;
/* 0x08 */ ColliderInfoInit info;
/* 0x20 */ ColliderQuadDimInit dim;
} ColliderQuadInit; // size = 0x50
typedef struct {
/* 0x00 */ ColliderInitType1 base;
/* 0x08 */ ColliderInfoInit info;
/* 0x00 */ ColliderInitType1 base;
/* 0x08 */ ColliderInfoInit info;
/* 0x20 */ ColliderQuadDimInit dim;
} ColliderQuadInitType1; // size = 0x50
typedef struct {
/* 0x00 */ Collider base;
/* 0x00 */ Collider base;
/* 0x18 */ ColliderInfo info;
/* 0x40 */ ColliderJntSphElementDim dim;
} ColliderSphere; // size = 0x58
typedef struct {
/* 0x00 */ ColliderInit base;
/* 0x00 */ ColliderInit base;
/* 0x08 */ ColliderInfoInit info;
/* 0x20 */ ColliderJntSphElementDimInit dim;
} ColliderSphereInit; // size = 0x2C
typedef struct {
/* 0x00 */ LineSegment line;
/* 0x18 */ u16 ocFlags;
/* 0x00 */ Linef line;
/* 0x18 */ u16 ocFlags;
} OcLine; // size = 0x1C
typedef struct {
/* 0x000 */ s16 colATCount;
/* 0x002 */ u16 sacFlags; // Controls whether new collidors can be added or removed, or only swapped
/* 0x000 */ s16 colATCount;
/* 0x002 */ u16 sacFlags; // Controls whether new collidors can be added or removed, or only swapped
/* 0x004 */ Collider* colAT[50];
/* 0x0CC */ s32 colACCount;
/* 0x0CC */ s32 colACCount;
/* 0x0D0 */ Collider* colAC[60];
/* 0x1C0 */ s32 colOCCount;
/* 0x1C0 */ s32 colOCCount;
/* 0x1C4 */ Collider* colOC[50];
/* 0x28C */ s32 colLineCount;
/* 0x290 */ OcLine* colLine[3];
/* 0x28C */ s32 colLineCount;
/* 0x290 */ OcLine* colLine[3];
} CollisionCheckContext; // size = 0x29C
typedef struct {
@@ -626,7 +626,7 @@ void CollisionCheck_SetHitEffects(struct PlayState* play, CollisionCheckContext*
void CollisionCheck_AC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT);
void CollisionCheck_AT(struct PlayState* play, CollisionCheckContext* colCtxt);
s32 CollisionCheck_GetMassType(u8 mass);
void CollisionCheck_SetOCvsOC(struct PlayState* play, Collider* left, ColliderInfo* leftInfo, Vec3f* leftPos, Collider* right, ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlap);
void CollisionCheck_SetOCvsOC(struct PlayState* play, Collider* left, ColliderInfo* leftInfo, Vec3f* leftPos, Collider* right, ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlapSize);
void CollisionCheck_OC_JntSphVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r);
void CollisionCheck_OC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r);
void CollisionCheck_OC_JntSphVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r);
+101 -2
View File
@@ -1,7 +1,7 @@
#ifndef Z64MATH_H
#define Z64MATH_H
#include "ultra64.h"
#include "PR/ultratypes.h"
#define VEC_SET(V,X,Y,Z) V.x=X;V.y=Y;V.z=Z
@@ -90,7 +90,7 @@ typedef struct {
typedef struct {
/* 0x00 */ Vec3f a;
/* 0x0C */ Vec3f b;
} LineSegment; // size = 0x18
} Linef; // size = 0x18
typedef struct {
/* 0x0 */ f32 r; // radius
@@ -153,6 +153,10 @@ typedef union {
#define IS_ZERO(f) (fabsf(f) < 0.008f)
#define SQ(x) ((x) * (x))
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define ABS_ALT(x) ((x) < 0 ? -(x) : (x))
// Casting a float to an integer, when the float value is larger than what the integer type can hold,
// leads to undefined behavior. For example (f32)0x8000 doesn't fit in a s16, so it cannot be cast to s16.
// This isn't an issue with IDO, but is one with for example GCC.
@@ -258,4 +262,99 @@ f32 Math_Atan2F(f32 y, f32 x);
s16 Math_Atan2S_XY(f32 x, f32 y);
f32 Math_Atan2F_XY(f32 x, f32 y);
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 Math3D_LineSegMakePerpLineSeg(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB, Vec3f* lineAClosestToB, Vec3f* lineBClosestToA);
f32 Math3D_LineClosestToPoint(InfiniteLine* line, Vec3f* pos, Vec3f* closestPoint);
void Math3D_FindPointOnPlaneIntersect(float planeAAxis1Norm, f32 planeAAxis2Norm, f32 planeBAxis1Norm, f32 planeBAxis2Norm, f32 axis3Direction, f32 planeADist, f32 planeBDist, float* axis1Point, float* axis2Point);
s32 Math3D_PlaneVsPlaneNewLine(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, InfiniteLine* intersect);
s32 Math3D_PlaneVsPlaneVsLineClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, Vec3f* point, Vec3f* closestPoint);
void Math3D_PointOnDirectedLine(Vec3f* v0, Vec3f* dir, f32 scale, Vec3f* ret);
void Math3D_LineSplitRatio(Vec3f* v0, Vec3f* v1, f32 ratio, Vec3f* ret);
f32 Math3D_Cos(Vec3f* a, Vec3f* b);
s32 Math3D_CosOut(Vec3f* a, Vec3f* b, f32* dst);
void Math3D_Vec3fReflect(Vec3f* vec, Vec3f* normal, Vec3f* reflVec);
s32 Math3D_PointInSquare2D(f32 upperLeftX, f32 lowerRightX, f32 upperLeftY, f32 lowerRightY, f32 x, f32 y);
s32 Math3D_CirSquareVsTriSquareXY(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 centerX, f32 centerY, f32 radius);
s32 Math3D_CirSquareVsTriSquareYZ(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 centerY, f32 centerZ, f32 radius);
s32 Math3D_CirSquareVsTriSquareZX(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 centerZ, f32 centerX, f32 radius);
s32 Math3D_SphCubeVsTriCube(Vec3f* v0, Vec3f* v1, Vec3f* v2, Vec3f* center, f32 radius);
f32 Math3D_Dist1DSq(f32 a, f32 b);
f32 Math3D_Dist1D(f32 a, f32 b);
f32 Math3D_Dist2DSq(f32 x0, f32 y0, f32 x1, f32 y1);
f32 Math3D_Dist2D(f32 x0, f32 y0, f32 x1, f32 y1);
f32 Math3D_Vec3fMagnitudeSq(Vec3f* vec);
f32 Math3D_Vec3fMagnitude(Vec3f* vec);
f32 Math3D_Vec3fDistSq(Vec3f* a, Vec3f* b);
f32 Math3D_Vec3f_DistXYZ(Vec3f* a, Vec3f* b);
f32 Math3D_DistXYZ16toF(Vec3s* a, Vec3f* b);
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_Vec3f_Cross(Vec3f* a, Vec3f* b, Vec3f* ret);
void Math3D_SurfaceNorm(Vec3f* va, Vec3f* vb, Vec3f* vc, Vec3f* normal);
s32 Math3D_PointRelativeToCubeFaces(Vec3f* point, Vec3f* min, Vec3f* max);
s32 Math3D_PointRelativeToCubeEdges(Vec3f* point, Vec3f* min, Vec3f* max);
s32 Math3D_PointRelativeToCubeVertices(Vec3f* point, Vec3f* min, Vec3f* max);
s32 Math3D_LineVsCube(Vec3f* min, Vec3f* max, Vec3f* a, Vec3f* b);
s32 Math3D_LineVsCubeShort(Vec3s* min, Vec3s* max, Vec3s* a, Vec3s* b);
void Math3D_RotateXZPlane(Vec3f* pointOnPlane, s16 angle, f32* a, f32* c, f32* d);
void Math3D_DefPlane(Vec3f* va, Vec3f* vb, Vec3f* vc, f32* nx, f32* ny, f32* nz, f32* originDist);
f32 Math3D_PlaneF(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* pointOnPlane);
f32 Math3D_Plane(Plane* plane, Vec3f* pointOnPlane);
f32 Math3D_UDistPlaneToPos(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* p);
f32 Math3D_DistPlaneToPos(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* p);
s32 Math3D_TriChkPointParaYImpl(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 z, f32 x, f32 detMax, f32 chkDist, f32 ny);
s32 Math3D_TriChkPointParaYDeterminate(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 z, f32 x, f32 detMax, f32 ny);
s32 Math3D_TriChkPointParaYSlopedY(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 z, f32 x);
s32 Math3D_TriChkPointParaYIntersectDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist);
s32 Math3D_TriChkPointParaYIntersectInsideTri(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist);
s32 Math3D_TriChkPointParaY(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 ny, f32 z, f32 x);
s32 Math3D_TriChkLineSegParaYIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 y0, f32 y1);
s32 Math3D_TriChkPointParaYDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, Plane* plane, f32 z, f32 x, f32 chkDist);
s32 Math3D_TriChkPointParaYImplNoCheckRange(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 z, f32 x, f32 detMax, f32 chkDist, f32 ny);
s32 Math3D_TriChkPointParaYNoRangeCheckIntersectInsideTri(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist);
s32 Math3D_TriChkPointParaXImpl(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 y, f32 z, f32 detMax, f32 chkDist, f32 ny);
s32 Math3D_TriChkPointParaXDeterminate(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 y, f32 z, f32 detMax, f32 nx);
s32 Math3D_TriChkPointParaXIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, f32 z, f32* xIntersect);
s32 Math3D_TriChkPointParaX(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 y, f32 z);
s32 Math3D_TriChkLineSegParaXIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, f32 z, f32* xIntersect, f32 x0, f32 x1);
s32 Math3D_TriChkLineSegParaXDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, Plane* plane, f32 y, f32 z, f32 chkDist);
s32 Math3D_TriChkPointParaZImpl(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 x, f32 y, f32 detMax, f32 chkDist, f32 nz);
s32 Math3D_TriChkPointParaZDeterminate(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 y, f32 z, f32 detMax, f32 nx);
s32 Math3D_TriChkPointParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, f32 y, f32* zIntersect);
s32 Math3D_TriChkPointParaZ(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 y, f32 z);
s32 Math3D_TriChkLineSegParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, f32 y, f32* zIntersect, f32 z0, f32 z1);
s32 Math3D_TriChkLineSegParaZDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, Plane* plane, f32 x, f32 y, f32 chkDist);
s32 Math3D_LineSegFindPlaneIntersect(f32 pointADist, f32 pointBDist, Vec3f* pointA, Vec3f* pointB, Vec3f* intersect);
s32 Math3D_LineSegVsPlane(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect, s32 fromFront);
s32 Math3D_TriLineIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect, s32 fromFront) ;
void Math3D_TriNorm(TriNorm* tri, Vec3f* va, Vec3f* vb, Vec3f* vc);
s32 Math3D_PointInSph(Sphere16* sphere, Vec3f* point);
s32 Math3D_PointDistSqToLine2DImpl(f32 x0, f32 y0, f32 x1, f32 y1, f32 x2, f32 y2, f32* perpXOut, f32* perpYOut, f32* lineLenSq); // returns boolean
s32 Math3D_PointDistSqToLine2D(f32 x0, f32 y0, f32 x1, f32 y1, f32 x2, f32 y2, f32* lineLenSq);
s32 Math3D_PointDistSqToLineXY(f32 x0, f32 y0, Vec3f* p1, Vec3f* p2, f32* lineLenSq);
s32 Math3D_PointDistSqToLineYZ(f32 y0, f32 z0, Vec3f* p1, Vec3f* p2, f32* lineLenSq);
s32 Math3D_PointDistSqToLineZX(f32 z0, f32 x0, Vec3f* p1, Vec3f* p2, f32* lineLenSq);
s32 Math3D_LineVsSph(Sphere16* sphere, Linef* line);
void Math3D_GetSphVsTriIntersectPoint(Sphere16* sphere, TriNorm* tri, Vec3f* intersectPoint);
s32 Math3D_TriVsSphIntersect(Sphere16* sphere, TriNorm* tri, Vec3f* intersectPoint);
s32 Math3D_PointInCyl(Cylinder16* cyl, Vec3f* point);
s32 Math3D_CylVsLineSeg(Cylinder16* cyl, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersectA, Vec3f* intersectB);
s32 Math3D_CylTriVsIntersect(Cylinder16* cyl, TriNorm* tri, Vec3f* intersect);
s32 Math3D_CylVsTri(Cylinder16* cyl, TriNorm* tri);
s32 Math3D_SphVsSph(Sphere16* sphereA, Sphere16* sphereB);
s32 Math3D_SphVsSphOverlap(Sphere16* sphereA, Sphere16* sphereB, f32* overlapSize);
s32 Math3D_SphVsSphOverlapCenterDist(Sphere16* sphereA, Sphere16* sphereB, f32* overlapSize, f32* centerDist);
s32 Math3D_SphVsCylOverlap(Sphere16* sph, Cylinder16* cyl, f32* overlapSize);
s32 Math3D_SphVsCylOverlapCenterDist(Sphere16* sph, Cylinder16* cyl, f32* overlapSize, f32* centerDist);
s32 Math3D_CylVsCylOverlap(Cylinder16* ca, Cylinder16* cb, f32* overlapSize);
s32 Math3D_CylVsCylOverlapCenterDist(Cylinder16* ca, Cylinder16* cb, f32* overlapSize, f32* centerDist);
s32 Math3D_TriVsTriIntersect(TriNorm* ta, TriNorm* tb, Vec3f* intersect);
s32 Math3D_XZInSphere(Sphere16* sphere, f32 x, f32 z);
s32 Math3D_XYInSphere(Sphere16* sphere, f32 x, f32 y);
s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z);
s32 Math3D_CircleLineIntersections(f32 centreX, f32 centerY, f32 radius, f32 pointX, f32 pointY, f32 dirX, f32 dirY, f32* intersectAX, f32* intersectAY, f32* intersectBX, f32* intersectBY);
void func_8017FD44(Vec3f* arg0, Vec3f* arg1, Vec3f* dst, f32 arg3);
#endif
-1
View File
@@ -561,7 +561,6 @@ beginseg
include "build/src/code/sys_initial_check.o"
include "build/src/code/sys_math.o"
include "build/src/code/sys_math3d.o"
include "build/data/code/sys_math3d.bss.o"
include "build/data/code/code_801D15B0.data.o"
include "build/src/code/sys_math_atan.o"
include "build/src/code/sys_matrix.o"
+2456 -189
View File
File diff suppressed because it is too large Load Diff
+9 -9
View File
@@ -4110,7 +4110,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;
@@ -4135,8 +4135,8 @@ void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3
if ((closestPointIndex != 0) || isPathLoop) {
// Use the adjacent line
useAdjacentLines[0] =
Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPointPrev.x, closestPointPrev.z, closestPoint.x,
closestPoint.z, &closestPos[0].x, &closestPos[0].z, &distSq);
Math3D_PointDistSqToLine2DImpl(srcPos->x, srcPos->z, closestPointPrev.x, closestPointPrev.z, closestPoint.x,
closestPoint.z, &closestPos[0].x, &closestPos[0].z, &distSq);
}
// Analyze point on path immediately next to the closest point
@@ -4152,8 +4152,8 @@ void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3
}
if ((closestPointIndex + 1 != numPoints) || isPathLoop) {
useAdjacentLines[1] =
Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPoint.x, closestPoint.z, closestPointNext.x,
closestPointNext.z, &closestPos[1].x, &closestPos[1].z, &distSq);
Math3D_PointDistSqToLine2DImpl(srcPos->x, srcPos->z, closestPoint.x, closestPoint.z, closestPointNext.x,
closestPointNext.z, &closestPos[1].x, &closestPos[1].z, &distSq);
}
/**
@@ -4171,7 +4171,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);
@@ -4190,9 +4190,9 @@ void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3
// srcPos is somewhere withing the bend of the path
if (!isRightSideOfAdjacentLines[0] && !isRightSideOfAdjacentLines[1]) {
// srcPos is not inside a loop
if (!Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPos[0].x, closestPos[0].z, closestPos[1].x,
closestPos[1].z, &dstPos->x, &dstPos->z, &distSq)) {
// The dstPos calculated in Math3D_PointDistToLine2D was not valid.
if (!Math3D_PointDistSqToLine2DImpl(srcPos->x, srcPos->z, closestPos[0].x, closestPos[0].z, closestPos[1].x,
closestPos[1].z, &dstPos->x, &dstPos->z, &distSq)) {
// The dstPos calculated in Math3D_PointDistSqToLine2DImpl was not valid.
// Take the midpoint of the two closest ponits instead
dstPos->x = (closestPos[1].x + closestPos[0].x) * 0.5f;
dstPos->z = (closestPos[1].z + closestPos[0].z) * 0.5f;
+10 -10
View File
@@ -352,14 +352,14 @@ s32 CollisionPoly_CheckYIntersect(CollisionPoly* poly, Vec3s* vtxList, f32 x, f3
D_801EDA18[2].y = sVerts->y;
D_801EDA18[2].z = sVerts->z;
if (!func_8017A304(&D_801EDA18[0], &D_801EDA18[1], &D_801EDA18[2], z, x, checkDist)) {
if (!Math3D_CirSquareVsTriSquareZX(&D_801EDA18[0], &D_801EDA18[1], &D_801EDA18[2], z, x, checkDist)) {
return 0;
}
nx = COLPOLY_GET_NORMAL(poly->normal.x);
ny = COLPOLY_GET_NORMAL(poly->normal.y);
nz = COLPOLY_GET_NORMAL(poly->normal.z);
return Math3D_TriChkPointParaYIntersectInsideTri2(&D_801EDA18[0], &D_801EDA18[1], &D_801EDA18[2], nx, ny, nz,
poly->dist, z, x, yIntersect, checkDist);
return Math3D_TriChkPointParaYNoRangeCheckIntersectInsideTri(&D_801EDA18[0], &D_801EDA18[1], &D_801EDA18[2], nx, ny,
nz, poly->dist, z, x, yIntersect, checkDist);
}
s32 CollisionPoly_CheckYIntersectApprox2(CollisionPoly* poly, Vec3s* vtxList, f32 x, f32 z, f32* yIntersect) {
@@ -422,17 +422,17 @@ s32 CollisionPoly_LineVsPoly(BgLineVsPolyTest* a0) {
CollisionPoly_GetNormalF(a0->poly, &sPlane.normal.x, &sPlane.normal.y, &sPlane.normal.z);
CollisionPoly_GetVertices(a0->poly, a0->vtxList, sPolyVerts);
Math3D_Lerp(a0->posA, a0->posB, planeDistA / (planeDistA - planeDistB), a0->planeIntersect);
Math3D_LineSplitRatio(a0->posA, a0->posB, planeDistA / (planeDistA - planeDistB), a0->planeIntersect);
if (((fabsf(sPlane.normal.x) > 0.5f) &&
Math3D_TriChkPointParaXDist(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->y,
Math3D_TriChkPointParaXImpl(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->y,
a0->planeIntersect->z, 0.0f, a0->checkDist, sPlane.normal.x)) ||
((fabsf(sPlane.normal.y) > 0.5f) &&
Math3D_TriChkPointParaYDist(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->z,
Math3D_TriChkPointParaYImpl(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->z,
a0->planeIntersect->x, 0.0f, a0->checkDist, sPlane.normal.y)) ||
((fabsf(sPlane.normal.z) > 0.5f) &&
Math3D_TriChkLineSegParaZDist(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->x,
a0->planeIntersect->y, 0.0f, a0->checkDist, sPlane.normal.z))) {
Math3D_TriChkPointParaZImpl(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->x,
a0->planeIntersect->y, 0.0f, a0->checkDist, sPlane.normal.z))) {
return true;
}
return false;
@@ -450,7 +450,7 @@ s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center,
sSphere.center.y = center->y;
sSphere.center.z = center->z;
sSphere.radius = radius;
return Math3D_ColSphereTri(&sSphere, &sTri, &intersect);
return Math3D_TriVsSphIntersect(&sSphere, &sTri, &intersect);
}
/**
@@ -3822,7 +3822,7 @@ s32 BgCheck_CheckLineAgainstDyna(CollisionContext* colCtx, u16 xpFlags, Vec3f* p
s32 pad;
s32 i;
s32 result = false;
LineSegment line;
Linef line;
f32 ay;
f32 by;
+11 -13
View File
@@ -1257,7 +1257,7 @@ s32 func_800CD44C(Camera* camera, VecGeo* diffGeo, CameraCollision* camEyeCollis
// different bgIds for at->eye[Next] and eye[Next]->at
ret = 3;
} else {
cosEyeAt = Math3D_Parallel(&camEyeCollision->norm, &camAtCollision->norm);
cosEyeAt = Math3D_Cos(&camEyeCollision->norm, &camAtCollision->norm);
if (cosEyeAt < -0.5f) {
ret = 6;
} else if ((cosEyeAt > 0.5f) || (checkEye & 2)) {
@@ -1846,20 +1846,18 @@ void Camera_CalcDefaultSwing(Camera* camera, VecGeo* arg1, VecGeo* arg2, f32 arg
if (swing->unk_64 == 1) {
if (arg3 < (sp88 = OLib_Vec3fDist(at, &swing->collisionClosePoint))) {
swing->unk_64 = 0;
} else if ((sp88 = Math3D_SignedDistanceFromPlane(swing->eyeAtColChk.norm.x, swing->eyeAtColChk.norm.y,
swing->eyeAtColChk.norm.z, swing->eyeAtColChk.poly->dist,
at)) > 0.0f) {
} else if ((sp88 = Math3D_PlaneF(swing->eyeAtColChk.norm.x, swing->eyeAtColChk.norm.y,
swing->eyeAtColChk.norm.z, swing->eyeAtColChk.poly->dist, at)) > 0.0f) {
swing->unk_64 = 0;
} else if ((sp88 = OLib_Vec3fDist(eye, &swing->eyeAtColChk.pos)) < 10.0f) {
swing->unk_64 = 0;
} else if ((sp88 = Math3D_SignedDistanceFromPlane(swing->atEyeColChk.norm.x, swing->atEyeColChk.norm.y,
swing->atEyeColChk.norm.z, swing->atEyeColChk.poly->dist,
eye)) > 0.0f) {
} else if ((sp88 = Math3D_PlaneF(swing->atEyeColChk.norm.x, swing->atEyeColChk.norm.y,
swing->atEyeColChk.norm.z, swing->atEyeColChk.poly->dist, eye)) > 0.0f) {
swing->unk_64 = 0;
} else if (swing->atEyeColChk.norm.y > 0.50f) {
swing->unk_64 = 0;
} else {
Math3D_AngleBetweenVectors(&camera->unk_0F0, &swing->eyeAtColChk.norm, &sp88);
Math3D_CosOut(&camera->unk_0F0, &swing->eyeAtColChk.norm, &sp88);
if (sp88 > 0.0f) {
swing->unk_64 = 0;
}
@@ -5471,8 +5469,8 @@ s32 Camera_Unique0(Camera* camera) {
switch (camera->animState) {
case 0:
bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamOrActorCsCamFuncData(camera, camera->bgCamIndex);
Camera_Vec3sToVec3f(&rwData->unk_1C, &bgCamFuncData->pos);
camera->eye = camera->eyeNext = rwData->unk_1C;
Camera_Vec3sToVec3f(&rwData->unk_1C.point, &bgCamFuncData->pos);
camera->eye = camera->eyeNext = rwData->unk_1C.point;
rwData->unk_34 = bgCamFuncData->rot;
temp_v1 = bgCamFuncData->fov;
@@ -5503,7 +5501,7 @@ s32 Camera_Unique0(Camera* camera) {
}
rwData->unk_3A = camera->focalActor->world.rot.y;
rwData->unk_3E = 0;
camera->eye = camera->eyeNext = rwData->unk_1C;
camera->eye = camera->eyeNext = rwData->unk_1C.point;
Camera_UnsetStateFlag(camera, CAM_STATE_2);
camera->animState++;
// fallthrough
@@ -5511,8 +5509,8 @@ s32 Camera_Unique0(Camera* camera) {
sp84.r = OLib_Vec3fDist(&sp8C, &camera->eye);
sp84.yaw = rwData->unk_34.y;
sp84.pitch = -rwData->unk_34.x;
OLib_VecGeoToVec3f(&rwData->unk_28, &sp84);
func_80179A44(&rwData->unk_1C, focalActorPosRot, &rwData->unk_0C);
OLib_VecGeoToVec3f(&rwData->unk_1C.dir, &sp84);
Math3D_LineClosestToPoint(&rwData->unk_1C, &focalActorPosRot->pos, &rwData->unk_0C);
camera->at = rwData->unk_0C;
if (player->stateFlags1 & PLAYER_STATE1_20000000) {
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -278,8 +278,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)) {
+2 -2
View File
@@ -57,8 +57,8 @@ void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f
sp48.y = spB8.y;
sp48.z = spB8.z;
if ((func_80179798(&sp84, &sp90, &sp54, &sp60, &sp6C, &sp30) != 0) &&
(func_80179798(&sp84, &sp90, &sp3C, &sp48, &sp78, &sp30) != 0)) {
if (Math3D_LineSegMakePerpLineSeg(&sp84, &sp90, &sp54, &sp60, &sp6C, &sp30) &&
Math3D_LineSegMakePerpLineSeg(&sp84, &sp90, &sp3C, &sp48, &sp78, &sp30)) {
if (!(spAC->flags & 2)) {
spAC->flags |= 1;
}
+1 -1
View File
@@ -114,7 +114,7 @@ void FireObj_UpdateStateTransitions(PlayState* play, FireObj* fire) {
}
if ((fire->flags & FIRE_FLAG_INTERACT_STICK) && (player->heldItemAction == PLAYER_IA_DEKU_STICK)) {
Math_Vec3f_Diff(&player->meleeWeaponInfo[0].tip, &fire->position, &dist);
if (Math3D_LengthSquared(&dist) < SQ(20.0f)) {
if (Math3D_Vec3fMagnitudeSq(&dist) < SQ(20.0f)) {
sp40 = true;
}
}
+1 -1
View File
@@ -1874,7 +1874,7 @@ void Environment_DrawLensFlare(PlayState* play, EnvironmentContext* envCtx, View
OPEN_DISPS(gfxCtx);
dist = Math3D_Distance(&pos, &view->eye) / 12.0f;
dist = Math3D_Vec3f_DistXYZ(&pos, &view->eye) / 12.0f;
// compute a unit vector in the look direction
tempX = view->at.x - view->eye.x;
+1
View File
@@ -1,3 +1,4 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "z64horse.h"
#include "z64shrink_window.h"
+2 -2
View File
@@ -1695,7 +1695,7 @@ s32 Play_SetCameraAtEye(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye) {
successfullySet <<= 1;
successfullySet |= Camera_SetViewParam(camera, CAM_VIEW_EYE, eye);
camera->dist = Math3D_Distance(at, eye);
camera->dist = Math3D_Vec3f_DistXYZ(at, eye);
if (camera->focalActor != NULL) {
camera->focalActorAtOffset.x = at->x - camera->focalActor->world.pos.x;
@@ -1724,7 +1724,7 @@ s32 Play_SetCameraAtEyeUp(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye, Vec
successfullySet <<= 1;
successfullySet |= Camera_SetViewParam(camera, CAM_VIEW_UP, up);
camera->dist = Math3D_Distance(at, eye);
camera->dist = Math3D_Vec3f_DistXYZ(at, eye);
if (camera->focalActor != NULL) {
camera->focalActorAtOffset.x = at->x - camera->focalActor->world.pos.x;
+3 -3
View File
@@ -577,7 +577,7 @@ s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) {
diffZ = points[index + 1].z - points[index - 1].z;
}
func_8017B7F8(&point, RAD_TO_BINANG(Math_FAtan2F(diffX, diffZ)), &px, &pz, &d);
Math3D_RotateXZPlane(&point, RAD_TO_BINANG(Math_FAtan2F(diffX, diffZ)), &px, &pz, &d);
if (((px * actor->world.pos.x) + (pz * actor->world.pos.z) + d) > 0.0f) {
reached = true;
}
@@ -1323,8 +1323,8 @@ void SubS_ActorPathing_ComputePointInfo(PlayState* play, ActorPathing* actorPath
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_Atan2S_XY(diff.z, diff.x);
actorPath->rotToCurPoint.x = Math_Atan2S_XY(sqrtf(actorPath->distSqToCurPointXZ), -diff.y);
actorPath->rotToCurPoint.z = 0;
+2 -1
View File
@@ -1,5 +1,6 @@
#include "libc/math.h"
#include "macros.h"
#include "ultra64.h"
#include "z64math.h"
#pragma weak cosf = __cosf

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