From 24086dc67b76c6eb389fc9a67f6d9e61f3574e81 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 19 Sep 2024 20:49:01 -0700 Subject: [PATCH] Colliders Sync General Clean (#1693) * General cleanup * General colliders --- include/z64collision_check.h | 218 +++---- src/code/z_collision_check.c | 1153 ++++++++++++++++++---------------- 2 files changed, 731 insertions(+), 640 deletions(-) diff --git a/include/z64collision_check.h b/include/z64collision_check.h index 02289deec1..a7027c6b59 100644 --- a/include/z64collision_check.h +++ b/include/z64collision_check.h @@ -17,25 +17,25 @@ typedef struct { /* 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 + /* 0x14 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. See `ColliderType` enum + /* 0x15 */ u8 shape; // See `ColliderShape` enum } 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. - /* 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 -} ColliderInit; // size = 0x6 - -typedef struct { - /* 0x0 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. + /* 0x0 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. See `ColliderType` enum /* 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 ocFlags2; // Flags related to which colliders it can OC collide with. + /* 0x5 */ u8 shape; // See `ColliderShape` enum +} ColliderInit; // size = 0x6 + +typedef struct { + /* 0x0 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. See `ColliderType` enum + /* 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; // See `ColliderShape` enum } ColliderInitType1; // size = 0x5 typedef struct { @@ -43,7 +43,7 @@ typedef struct { /* 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 + /* 0x7 */ u8 shape; // See `ColliderShape` enum } ColliderInitToActor; // size = 0x8 typedef struct { @@ -465,17 +465,17 @@ typedef struct CollisionCheckInfo { DamageTable* DamageTable_Get(s32 index); void DamageTable_Clear(DamageTable* damageTable); -f32 CollisionCheck_GetDamageAndEffectOnBumper(Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, u32* effect); +f32 CollisionCheck_GetDamageAndEffectOnBumper(Collider* atCol, ColliderInfo* atInfo, Collider* acCol, ColliderInfo* acInfo, u32* effect); f32 CollisionCheck_ApplyBumperDefense(f32 damage, ColliderInfo* ac); -s32 CollisionCheck_GetToucherDamage(Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo); -s32 Collider_InitBase(struct PlayState* play, Collider* collider); +s32 CollisionCheck_GetToucherDamage(Collider* atCol, ColliderInfo* atInfo, Collider* acCol, ColliderInfo* acInfo); +s32 Collider_InitBase(struct PlayState* play, Collider* col); s32 Collider_DestroyBase(struct PlayState* play, Collider* collider); -s32 Collider_SetBaseToActor(struct PlayState* play, Collider* collider, ColliderInitToActor* src); -s32 Collider_SetBaseType1(struct PlayState* play, Collider* collider, struct Actor* actor, ColliderInitType1* src); -s32 Collider_SetBase(struct PlayState* play, Collider* collider, struct Actor* actor, ColliderInit* src); -void Collider_ResetATBase(struct PlayState* play, Collider* collider); -void Collider_ResetACBase(struct PlayState* play, Collider* collider); -void Collider_ResetOCBase(struct PlayState* play, Collider* collider); +s32 Collider_SetBaseToActor(struct PlayState* play, Collider* col, ColliderInitToActor* src); +s32 Collider_SetBaseType1(struct PlayState* play, Collider* col, struct Actor* actor, ColliderInitType1* src); +s32 Collider_SetBase(struct PlayState* play, Collider* col, struct Actor* actor, ColliderInit* src); +void Collider_ResetATBase(struct PlayState* play, Collider* col); +void Collider_ResetACBase(struct PlayState* play, Collider* col); +void Collider_ResetOCBase(struct PlayState* play, Collider* col); s32 Collider_InitTouch(struct PlayState* play, ColliderTouch* touch); s32 Collider_DestroyTouch(struct PlayState* play, ColliderTouch* touch); s32 Collider_SetTouch(struct PlayState* play, ColliderTouch* touch, ColliderTouchInit* src); @@ -505,9 +505,9 @@ s32 Collider_SetJntSphToActor(struct PlayState* play, ColliderJntSph* collider, s32 Collider_SetJntSphAllocType1(struct PlayState* play, ColliderJntSph* sphereGroup, struct Actor* actor, ColliderJntSphInitType1* src); s32 Collider_SetJntSph(struct PlayState* play, ColliderJntSph* sphereGroup, struct Actor* actor, ColliderJntSphInit* src, ColliderJntSphElement* elements); s32 Collider_InitAndSetJntSph(struct PlayState* play, ColliderJntSph* sphereGroup, struct Actor* actor, ColliderJntSphInit* src, ColliderJntSphElement* elements); -s32 Collider_ResetJntSphAT(struct PlayState* play, Collider* collider); -s32 Collider_ResetJntSphAC(struct PlayState* play, Collider* collider); -s32 Collider_ResetJntSphOC(struct PlayState* play, Collider* collider); +s32 Collider_ResetJntSphAT(struct PlayState* play, Collider* col); +s32 Collider_ResetJntSphAC(struct PlayState* play, Collider* col); +s32 Collider_ResetJntSphOC(struct PlayState* play, Collider* col); s32 Collider_InitCylinderDim(struct PlayState* play, Cylinder16* dim); s32 Collider_DestroyCylinderDim(struct PlayState* play, Cylinder16* dim); s32 Collider_SetCylinderDim(struct PlayState* play, Cylinder16* dim, Cylinder16* src); @@ -517,9 +517,9 @@ s32 Collider_SetCylinderToActor(struct PlayState* play, ColliderCylinder* collid s32 Collider_SetCylinderType1(struct PlayState* play, ColliderCylinder* collider, struct Actor* actor, ColliderCylinderInitType1* src); s32 Collider_SetCylinder(struct PlayState* play, ColliderCylinder* collider, struct Actor* actor, ColliderCylinderInit* src); s32 Collider_InitAndSetCylinder(struct PlayState* play, ColliderCylinder* collider, struct Actor* actor, ColliderCylinderInit* src); -s32 Collider_ResetCylinderAT(struct PlayState* play, Collider* collider); -s32 Collider_ResetCylinderAC(struct PlayState* play, Collider* collider); -s32 Collider_ResetCylinderOC(struct PlayState* play, Collider* collider); +s32 Collider_ResetCylinderAT(struct PlayState* play, Collider* col); +s32 Collider_ResetCylinderAC(struct PlayState* play, Collider* col); +s32 Collider_ResetCylinderOC(struct PlayState* play, Collider* col); s32 Collider_InitTrisElementDim(struct PlayState* play, TriNorm* dim); s32 Collider_DestroyTrisElementDim(struct PlayState* play, TriNorm* dim); s32 Collider_SetTrisElementDim(struct PlayState* play, TriNorm* dim, ColliderTrisElementDimInit* src); @@ -535,9 +535,9 @@ s32 Collider_DestroyTris(struct PlayState* play, ColliderTris* tris); s32 Collider_SetTrisAllocType1(struct PlayState* play, ColliderTris* tris, struct Actor* actor, ColliderTrisInitType1* src); s32 Collider_SetTris(struct PlayState* play, ColliderTris* triGroup, struct Actor* actor, ColliderTrisInit* src, ColliderTrisElement* tris); s32 Collider_InitAndSetTris(struct PlayState* play, ColliderTris* tris, struct Actor* actor, ColliderTrisInit* src, ColliderTrisElement* elements); -s32 Collider_ResetTrisAT(struct PlayState* play, Collider* collider); -s32 Collider_ResetTrisAC(struct PlayState* play, Collider* collider); -s32 Collider_ResetTrisOC(struct PlayState* play, Collider* collider); +s32 Collider_ResetTrisAT(struct PlayState* play, Collider* col); +s32 Collider_ResetTrisAC(struct PlayState* play, Collider* col); +s32 Collider_ResetTrisOC(struct PlayState* play, Collider* col); s32 Collider_InitQuadDim(struct PlayState* play, ColliderQuadDim* dim); s32 Collider_DestroyQuadDim(struct PlayState* play, ColliderQuadDim* dim); s32 Collider_ResetQuadACDist(struct PlayState* play, ColliderQuadDim* dim); @@ -548,34 +548,34 @@ s32 Collider_DestroyQuad(struct PlayState* play, ColliderQuad* collider); s32 Collider_SetQuadType1(struct PlayState* play, ColliderQuad* collider, struct Actor* actor, ColliderQuadInitType1* src); s32 Collider_SetQuad(struct PlayState* play, ColliderQuad* collider, struct Actor* actor, ColliderQuadInit* src); s32 Collider_InitAndSetQuad(struct PlayState* play, ColliderQuad* collider, struct Actor* actor, ColliderQuadInit* src); -s32 Collider_ResetQuadAT(struct PlayState* play, Collider* collider); -s32 Collider_ResetQuadAC(struct PlayState* play, Collider* collider); -s32 Collider_ResetQuadOC(struct PlayState* play, Collider* collider); +s32 Collider_ResetQuadAT(struct PlayState* play, Collider* col); +s32 Collider_ResetQuadAC(struct PlayState* play, Collider* col); +s32 Collider_ResetQuadOC(struct PlayState* play, Collider* col); s32 Collider_QuadSetNearestAC(struct PlayState* play, ColliderQuad* quad, Vec3f* hitPos); s32 Collider_InitSphere(struct PlayState* play, ColliderSphere* collider); s32 Collider_DestroySphere(struct PlayState* play, ColliderSphere* collider); s32 Collider_SetSphere(struct PlayState* play, ColliderSphere* collider, struct Actor* actor, ColliderSphereInit* src); s32 Collider_InitAndSetSphere(struct PlayState* play, ColliderSphere* collider, struct Actor* actor, ColliderSphereInit* src); -s32 Collider_ResetSphereAT(struct PlayState* play, Collider* collider); -s32 Collider_ResetSphereAC(struct PlayState* play, Collider* collider); -s32 Collider_ResetSphereOC(struct PlayState* play, Collider* collider); +s32 Collider_ResetSphereAT(struct PlayState* play, Collider* col); +s32 Collider_ResetSphereAC(struct PlayState* play, Collider* col); +s32 Collider_ResetSphereOC(struct PlayState* play, Collider* col); s32 Collider_InitLine(struct PlayState* play, OcLine* line); s32 Collider_DestroyLine(struct PlayState* play, OcLine* line); s32 Collider_SetLinePoints(struct PlayState* play, OcLine* line, Vec3f* a, Vec3f* b); s32 Collider_SetLine(struct PlayState* play, OcLine* line, OcLine* src); s32 Collider_ResetLineOC(struct PlayState* play, OcLine* line); -void CollisionCheck_InitContext(struct PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_InitContext(struct PlayState* play, CollisionCheckContext* colChkCtx); void CollisionCheck_DestroyContext(struct PlayState* play, CollisionCheckContext* colCtxt); -void CollisionCheck_ClearContext(struct PlayState* play, CollisionCheckContext* colCtxt); -void CollisionCheck_EnableSAC(struct PlayState* play, CollisionCheckContext* colCtxt); -void CollisionCheck_DisableSAC(struct PlayState* play, CollisionCheckContext* colCtxt); -s32 CollisionCheck_SetAT(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -s32 CollisionCheck_SetAT_SAC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index); -s32 CollisionCheck_SetAC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -s32 CollisionCheck_SetAC_SAC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index); -s32 CollisionCheck_SetOC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -s32 CollisionCheck_SetOC_SAC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index); -s32 CollisionCheck_SetOCLine(struct PlayState* play, CollisionCheckContext* colCtxt, OcLine* line); +void CollisionCheck_ClearContext(struct PlayState* play, CollisionCheckContext* colChkCtx); +void CollisionCheck_EnableSAC(struct PlayState* play, CollisionCheckContext* colChkCtx); +void CollisionCheck_DisableSAC(struct PlayState* play, CollisionCheckContext* colChkCtx); +s32 CollisionCheck_SetAT(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col); +s32 CollisionCheck_SetAT_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, s32 index); +s32 CollisionCheck_SetAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col); +s32 CollisionCheck_SetAC_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, s32 index); +s32 CollisionCheck_SetOC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col); +s32 CollisionCheck_SetOC_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, s32 index); +s32 CollisionCheck_SetOCLine(struct PlayState* play, CollisionCheckContext* colChkCtx, OcLine* line); s32 CollisionCheck_SkipTouch(ColliderInfo* info); s32 CollisionCheck_SkipBump(ColliderInfo* info); s32 CollisionCheck_NoSharedFlags(ColliderInfo* toucher, ColliderInfo* bumper); @@ -585,79 +585,79 @@ void CollisionCheck_GreenBlood(struct PlayState* play, Collider* collider, Vec3f void CollisionCheck_WaterBurst(struct PlayState* play, Collider* collider, Vec3f* v); void CollisionCheck_RedBlood(struct PlayState* play, Collider* collider, Vec3f* v); void CollisionCheck_RedBloodUnused(struct PlayState* play, Collider* collider, Vec3f* v); -void CollisionCheck_HitSolid(struct PlayState* play, ColliderInfo* info, Collider* collider, Vec3f* hitPos); +void CollisionCheck_HitSolid(struct PlayState* play, ColliderInfo* info, Collider* col, Vec3f* hitPos); s32 CollisionCheck_SwordHitAudio(Collider* at, ColliderInfo* acInfo); void CollisionCheck_HitEffects(struct PlayState* play, Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, Vec3f* hitPos); void CollisionCheck_SetBounce(Collider* at, Collider* ac); -s32 CollisionCheck_SetATvsAC(struct PlayState* play, Collider* at, ColliderInfo* atInfo, Vec3f* atPos, Collider* ac, ColliderInfo* acInfo, Vec3f* acPos, Vec3f* hitPos); +s32 CollisionCheck_SetATvsAC(struct PlayState* play, Collider* atCol, ColliderInfo* atInfo, Vec3f* atPos, Collider* acCol, ColliderInfo* acInfo, Vec3f* acPos, Vec3f* hitPos); void CollisionCheck_TrisAvgPoint(ColliderTrisElement* tri, Vec3f* avg); void CollisionCheck_QuadAvgPoint(ColliderQuad* quad, Vec3f* avg); -void CollisionCheck_AC_JntSphVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_JntSphVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_JntSphVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_JntSphVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsCylinder(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_SetJntSphHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetCylHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetTrisHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetQuadHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetSphereHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetHitEffects(struct PlayState* play, CollisionCheckContext* colCtxt); -void CollisionCheck_AC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT); -void CollisionCheck_AT(struct PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_AC_JntSphVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_JntSphVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_JntSphVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_JntSphVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_CylVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_CylVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_CylVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_CylVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_CylVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_TrisVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_TrisVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_TrisVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_TrisVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_TrisVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_QuadVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_QuadVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_QuadVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_QuadVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_QuadVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_SphereVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_SphereVsCylinder(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_SphereVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_SphereVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_AC_SphereVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* atCol, Collider* acCol); +void CollisionCheck_SetJntSphHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* col); +void CollisionCheck_SetCylHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* col); +void CollisionCheck_SetTrisHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* col); +void CollisionCheck_SetQuadHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* col); +void CollisionCheck_SetSphereHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* col); +void CollisionCheck_SetHitEffects(struct PlayState* play, CollisionCheckContext* colChkCtx); +void CollisionCheck_AC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol); +void CollisionCheck_AT(struct PlayState* play, CollisionCheckContext* colChkCtx); s32 CollisionCheck_GetMassType(u8 mass); -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); -void CollisionCheck_OC_CylVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_CylVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_CylVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_SphereVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_SphereVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_SphereVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -s32 CollisionCheck_SkipOC(Collider* collider); -s32 CollisionCheck_Incompatible(Collider* left, Collider* right); -void CollisionCheck_OC(struct PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_SetOCvsOC(struct PlayState* play, Collider* leftCol, ColliderInfo* leftInfo, Vec3f* leftPos, Collider* rightCol, ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlapSize); +void CollisionCheck_OC_JntSphVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* leftCol, Collider* rightCol); +void CollisionCheck_OC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* leftCol, Collider* rightCol); +void CollisionCheck_OC_JntSphVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* leftCol, Collider* rightCol); +void CollisionCheck_OC_CylVsJntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* leftCol, Collider* rightCol); +void CollisionCheck_OC_CylVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* leftCol, Collider* rightCol); +void CollisionCheck_OC_CylVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* leftCol, Collider* rightCol); +void CollisionCheck_OC_SphereVsJntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* leftCol, Collider* rightCol); +void CollisionCheck_OC_SphereVsCyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* leftCol, Collider* rightCol); +void CollisionCheck_OC_SphereVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* leftCol, Collider* rightCol); +s32 CollisionCheck_SkipOC(Collider* col); +s32 CollisionCheck_Incompatible(Collider* leftCol, Collider* rightCol); +void CollisionCheck_OC(struct PlayState* play, CollisionCheckContext* colChkCtx); void CollisionCheck_InitInfo(CollisionCheckInfo* info); void CollisionCheck_ResetDamage(CollisionCheckInfo* info); void CollisionCheck_SetInfoNoDamageTable(CollisionCheckInfo* info, CollisionCheckInfoInit* init); void CollisionCheck_SetInfo(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit* init); void CollisionCheck_SetInfo2(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit2* init); void CollisionCheck_SetInfoGetDamageTable(CollisionCheckInfo* info, s32 index, CollisionCheckInfoInit2* init); -void CollisionCheck_ApplyDamage(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, ColliderInfo* info); -void CollisionCheck_ApplyDamageJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_ApplyDamageCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_ApplyDamageTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_ApplyDamageQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_ApplyDamageSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_Damage(struct PlayState* play, CollisionCheckContext* colCtxt); -s32 CollisionCheck_LineOC_JntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); -s32 CollisionCheck_LineOC_Cyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); -s32 CollisionCheck_LineOC_Sphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); +void CollisionCheck_ApplyDamage(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* col, ColliderInfo* info); +void CollisionCheck_ApplyDamageJntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col); +void CollisionCheck_ApplyDamageCyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col); +void CollisionCheck_ApplyDamageTris(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col); +void CollisionCheck_ApplyDamageQuad(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col); +void CollisionCheck_ApplyDamageSphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col); +void CollisionCheck_Damage(struct PlayState* play, CollisionCheckContext* colChkCtx); +s32 CollisionCheck_LineOC_JntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, Vec3f* a, Vec3f* b); +s32 CollisionCheck_LineOC_Cyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, Vec3f* a, Vec3f* b); +s32 CollisionCheck_LineOC_Sphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, Vec3f* a, Vec3f* b); s32 CollisionCheck_LineOC(struct PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, struct Actor** exclusions, s32 numExclusions); -s32 CollisionCheck_LineOCCheckAll(struct PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b); -s32 CollisionCheck_LineOCCheck(struct PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b, struct Actor** exclusions, s32 numExclusions); +s32 CollisionCheck_LineOCCheckAll(struct PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b); +s32 CollisionCheck_LineOCCheck(struct PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, struct Actor** exclusions, s32 numExclusions); void Collider_UpdateCylinder(struct Actor* actor, ColliderCylinder* collider); void Collider_SetCylinderPosition(ColliderCylinder* collider, Vec3s* pos); void Collider_SetQuadVertices(ColliderQuad* collider, Vec3f* a, Vec3f* b, Vec3f* c, Vec3f* d); diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 47eea4f7fa..1c29854b8e 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1,5 +1,7 @@ #include "z64collision_check.h" +#include "stdbool.h" + #include "macros.h" #include "sfx.h" #include "sys_matrix.h" @@ -107,8 +109,8 @@ TriNorm D_801EE188; * Gets the damage and effect that should be applied for the collision between * `at` and `ac`, referring to the ac actor's damage chart if applicable. */ -f32 CollisionCheck_GetDamageAndEffectOnBumper(Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, - u32* effect) { +f32 CollisionCheck_GetDamageAndEffectOnBumper(Collider* atCol, ColliderInfo* atInfo, Collider* acCol, + ColliderInfo* acInfo, u32* effect) { static f32 sDamageMultipliers[] = { 0.0f, 1.0f, 2.0f, 0.5f, 0.25f, 3.0f, 4.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, }; @@ -117,20 +119,20 @@ f32 CollisionCheck_GetDamageAndEffectOnBumper(Collider* at, ColliderInfo* atInfo f32 damage; *effect = 0; - damage = CollisionCheck_GetToucherDamage(at, atInfo, ac, acInfo); + damage = CollisionCheck_GetToucherDamage(atCol, atInfo, acCol, acInfo); - if (ac->actor->colChkInfo.damageTable != NULL) { + if (acCol->actor->colChkInfo.damageTable != NULL) { dmgFlags = atInfo->toucher.dmgFlags; - for (i = 0; i < ARRAY_COUNT(ac->actor->colChkInfo.damageTable->attack); i++) { + for (i = 0; i < ARRAY_COUNT(acCol->actor->colChkInfo.damageTable->attack); i++) { if (dmgFlags == 1) { break; } dmgFlags >>= 1; } - damage *= sDamageMultipliers[ac->actor->colChkInfo.damageTable->attack[i] & 0xF]; - *effect = (ac->actor->colChkInfo.damageTable->attack[i] >> 4) & 0xF; + damage *= sDamageMultipliers[acCol->actor->colChkInfo.damageTable->attack[i] & 0xF]; + *effect = (acCol->actor->colChkInfo.damageTable->attack[i] >> 4) & 0xF; } return damage; } @@ -148,79 +150,79 @@ f32 CollisionCheck_ApplyBumperDefense(f32 damage, ColliderInfo* ac) { * Gets the damage to be inflicted by `at` on `ac`, before applying other * factors such as the ac collider's defense. */ -s32 CollisionCheck_GetToucherDamage(Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo) { - if ((at->actor != NULL) && (at->actor->id == ACTOR_EN_BOM) && (ac->actor != NULL) && - (ac->actor->id == ACTOR_PLAYER)) { +s32 CollisionCheck_GetToucherDamage(Collider* atCol, ColliderInfo* atInfo, Collider* acCol, ColliderInfo* acInfo) { + if ((atCol->actor != NULL) && (atCol->actor->id == ACTOR_EN_BOM) && (acCol->actor != NULL) && + (acCol->actor->id == ACTOR_PLAYER)) { return 8; } return atInfo->toucher.damage; } -s32 Collider_InitBase(struct PlayState* play, Collider* collider) { +s32 Collider_InitBase(struct PlayState* play, Collider* col) { static Collider sDefaultCollider = { NULL, NULL, NULL, NULL, AT_NONE, AC_NONE, OC1_NONE, OC2_NONE, COLTYPE_HIT3, COLSHAPE_MAX, }; - *collider = sDefaultCollider; + *col = sDefaultCollider; return 1; } -s32 Collider_DestroyBase(struct PlayState* play, Collider* collider) { +s32 Collider_DestroyBase(struct PlayState* play, Collider* col) { return 1; } /** * Uses default OC2_TYPE_1 and COLTYPE_HIT0 */ -s32 Collider_SetBaseToActor(struct PlayState* play, Collider* collider, ColliderInitToActor* src) { - collider->actor = src->actor; - collider->atFlags = src->atFlags; - collider->acFlags = src->acFlags; - collider->ocFlags1 = src->ocFlags1; - collider->ocFlags2 = OC2_TYPE_1; - collider->shape = src->shape; +s32 Collider_SetBaseToActor(struct PlayState* play, Collider* col, ColliderInitToActor* src) { + col->actor = src->actor; + col->atFlags = src->atFlags; + col->acFlags = src->acFlags; + col->ocFlags1 = src->ocFlags1; + col->ocFlags2 = OC2_TYPE_1; + col->shape = src->shape; return 1; } /** * Uses default OC2_TYPE_1 */ -s32 Collider_SetBaseType1(struct PlayState* play, Collider* collider, Actor* actor, ColliderInitType1* src) { - collider->actor = actor; - collider->colType = src->colType; - collider->atFlags = src->atFlags; - collider->acFlags = src->acFlags; - collider->ocFlags1 = src->ocFlags1; - collider->ocFlags2 = OC2_TYPE_1; - collider->shape = src->shape; +s32 Collider_SetBaseType1(struct PlayState* play, Collider* col, Actor* actor, ColliderInitType1* src) { + col->actor = actor; + col->colType = src->colType; + col->atFlags = src->atFlags; + col->acFlags = src->acFlags; + col->ocFlags1 = src->ocFlags1; + col->ocFlags2 = OC2_TYPE_1; + col->shape = src->shape; return 1; } -s32 Collider_SetBase(struct PlayState* play, Collider* collider, Actor* actor, ColliderInit* src) { - collider->actor = actor; - collider->colType = src->colType; - collider->atFlags = src->atFlags; - collider->acFlags = src->acFlags; - collider->ocFlags1 = src->ocFlags1; - collider->ocFlags2 = src->ocFlags2; - collider->shape = src->shape; +s32 Collider_SetBase(struct PlayState* play, Collider* col, Actor* actor, ColliderInit* src) { + col->actor = actor; + col->colType = src->colType; + col->atFlags = src->atFlags; + col->acFlags = src->acFlags; + col->ocFlags1 = src->ocFlags1; + col->ocFlags2 = src->ocFlags2; + col->shape = src->shape; return 1; } -void Collider_ResetATBase(struct PlayState* play, Collider* collider) { - collider->at = NULL; - collider->atFlags &= ~(AT_HIT | AT_BOUNCED); +void Collider_ResetATBase(struct PlayState* play, Collider* col) { + col->at = NULL; + col->atFlags &= ~(AT_HIT | AT_BOUNCED); } -void Collider_ResetACBase(struct PlayState* play, Collider* collider) { - collider->ac = NULL; - collider->acFlags &= ~(AC_HIT | AC_BOUNCED); +void Collider_ResetACBase(struct PlayState* play, Collider* col) { + col->ac = NULL; + col->acFlags &= ~(AC_HIT | AC_BOUNCED); } -void Collider_ResetOCBase(struct PlayState* play, Collider* collider) { - collider->oc = NULL; - collider->ocFlags1 &= ~OC1_HIT; - collider->ocFlags2 &= ~OC2_HIT_PLAYER; +void Collider_ResetOCBase(struct PlayState* play, Collider* col) { + col->oc = NULL; + col->ocFlags1 &= ~OC1_HIT; + col->ocFlags2 &= ~OC2_HIT_PLAYER; } s32 Collider_InitTouch(struct PlayState* play, ColliderTouch* touch) { @@ -500,9 +502,9 @@ s32 Collider_InitAndSetJntSph(struct PlayState* play, ColliderJntSph* sphereGrou /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetJntSphAT(struct PlayState* play, Collider* collider) { +s32 Collider_ResetJntSphAT(struct PlayState* play, Collider* col) { ColliderJntSphElement* element; - ColliderJntSph* jntSph = (ColliderJntSph*)collider; + ColliderJntSph* jntSph = (ColliderJntSph*)col; Collider_ResetATBase(play, &jntSph->base); @@ -515,9 +517,9 @@ s32 Collider_ResetJntSphAT(struct PlayState* play, Collider* collider) { /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetJntSphAC(struct PlayState* play, Collider* collider) { +s32 Collider_ResetJntSphAC(struct PlayState* play, Collider* col) { ColliderJntSphElement* element; - ColliderJntSph* jntSph = (ColliderJntSph*)collider; + ColliderJntSph* jntSph = (ColliderJntSph*)col; Collider_ResetACBase(play, &jntSph->base); @@ -530,9 +532,9 @@ s32 Collider_ResetJntSphAC(struct PlayState* play, Collider* collider) { /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetJntSphOC(struct PlayState* play, Collider* collider) { +s32 Collider_ResetJntSphOC(struct PlayState* play, Collider* col) { ColliderJntSphElement* element; - ColliderJntSph* jntSph = (ColliderJntSph*)collider; + ColliderJntSph* jntSph = (ColliderJntSph*)col; Collider_ResetOCBase(play, &jntSph->base); @@ -623,8 +625,8 @@ s32 Collider_InitAndSetCylinder(struct PlayState* play, ColliderCylinder* collid /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetCylinderAT(struct PlayState* play, Collider* collider) { - ColliderCylinder* cylinder = (ColliderCylinder*)collider; +s32 Collider_ResetCylinderAT(struct PlayState* play, Collider* col) { + ColliderCylinder* cylinder = (ColliderCylinder*)col; Collider_ResetATBase(play, &cylinder->base); Collider_ResetATInfo(play, &cylinder->info); @@ -634,8 +636,8 @@ s32 Collider_ResetCylinderAT(struct PlayState* play, Collider* collider) { /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetCylinderAC(struct PlayState* play, Collider* collider) { - ColliderCylinder* cylinder = (ColliderCylinder*)collider; +s32 Collider_ResetCylinderAC(struct PlayState* play, Collider* col) { + ColliderCylinder* cylinder = (ColliderCylinder*)col; Collider_ResetACBase(play, &cylinder->base); Collider_ResetACInfo(play, &cylinder->info); @@ -645,8 +647,8 @@ s32 Collider_ResetCylinderAC(struct PlayState* play, Collider* collider) { /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetCylinderOC(struct PlayState* play, Collider* collider) { - ColliderCylinder* cylinder = (ColliderCylinder*)collider; +s32 Collider_ResetCylinderOC(struct PlayState* play, Collider* col) { + ColliderCylinder* cylinder = (ColliderCylinder*)col; Collider_ResetOCBase(play, &cylinder->base); Collider_ResetOCInfo(play, &cylinder->info); @@ -828,9 +830,9 @@ s32 Collider_InitAndSetTris(struct PlayState* play, ColliderTris* tris, Actor* a /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetTrisAT(struct PlayState* play, Collider* collider) { +s32 Collider_ResetTrisAT(struct PlayState* play, Collider* col) { ColliderTrisElement* element; - ColliderTris* tris = (ColliderTris*)collider; + ColliderTris* tris = (ColliderTris*)col; Collider_ResetATBase(play, &tris->base); @@ -843,9 +845,9 @@ s32 Collider_ResetTrisAT(struct PlayState* play, Collider* collider) { /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetTrisAC(struct PlayState* play, Collider* collider) { +s32 Collider_ResetTrisAC(struct PlayState* play, Collider* col) { ColliderTrisElement* element; - ColliderTris* tris = (ColliderTris*)collider; + ColliderTris* tris = (ColliderTris*)col; Collider_ResetACBase(play, &tris->base); @@ -858,9 +860,9 @@ s32 Collider_ResetTrisAC(struct PlayState* play, Collider* collider) { /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetTrisOC(struct PlayState* play, Collider* collider) { +s32 Collider_ResetTrisOC(struct PlayState* play, Collider* col) { ColliderTrisElement* element; - ColliderTris* tris = (ColliderTris*)collider; + ColliderTris* tris = (ColliderTris*)col; Collider_ResetOCBase(play, &tris->base); @@ -962,8 +964,8 @@ s32 Collider_InitAndSetQuad(struct PlayState* play, ColliderQuad* collider, Acto /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetQuadAT(struct PlayState* play, Collider* collider) { - ColliderQuad* quad = (ColliderQuad*)collider; +s32 Collider_ResetQuadAT(struct PlayState* play, Collider* col) { + ColliderQuad* quad = (ColliderQuad*)col; Collider_ResetATBase(play, &quad->base); Collider_ResetATInfo(play, &quad->info); @@ -974,8 +976,8 @@ s32 Collider_ResetQuadAT(struct PlayState* play, Collider* collider) { /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetQuadAC(struct PlayState* play, Collider* collider) { - ColliderQuad* quad = (ColliderQuad*)collider; +s32 Collider_ResetQuadAC(struct PlayState* play, Collider* col) { + ColliderQuad* quad = (ColliderQuad*)col; Collider_ResetACBase(play, &quad->base); Collider_ResetACInfo(play, &quad->info); @@ -985,8 +987,8 @@ s32 Collider_ResetQuadAC(struct PlayState* play, Collider* collider) { /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetQuadOC(struct PlayState* play, Collider* collider) { - ColliderQuad* quad = (ColliderQuad*)collider; +s32 Collider_ResetQuadOC(struct PlayState* play, Collider* col) { + ColliderQuad* quad = (ColliderQuad*)col; Collider_ResetOCBase(play, &quad->base); Collider_ResetOCInfo(play, &quad->info); @@ -1064,8 +1066,8 @@ s32 Collider_InitAndSetSphere(struct PlayState* play, ColliderSphere* collider, /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetSphereAT(struct PlayState* play, Collider* collider) { - ColliderSphere* sphere = (ColliderSphere*)collider; +s32 Collider_ResetSphereAT(struct PlayState* play, Collider* col) { + ColliderSphere* sphere = (ColliderSphere*)col; Collider_ResetATBase(play, &sphere->base); Collider_ResetATInfo(play, &sphere->info); @@ -1075,8 +1077,8 @@ s32 Collider_ResetSphereAT(struct PlayState* play, Collider* collider) { /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetSphereAC(struct PlayState* play, Collider* collider) { - ColliderSphere* sphere = (ColliderSphere*)collider; +s32 Collider_ResetSphereAC(struct PlayState* play, Collider* col) { + ColliderSphere* sphere = (ColliderSphere*)col; Collider_ResetACBase(play, &sphere->base); Collider_ResetACInfo(play, &sphere->info); @@ -1086,8 +1088,8 @@ s32 Collider_ResetSphereAC(struct PlayState* play, Collider* collider) { /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetSphereOC(struct PlayState* play, Collider* collider) { - ColliderSphere* sphere = (ColliderSphere*)collider; +s32 Collider_ResetSphereOC(struct PlayState* play, Collider* col) { + ColliderSphere* sphere = (ColliderSphere*)col; Collider_ResetOCBase(play, &sphere->base); Collider_ResetOCInfo(play, &sphere->info); @@ -1142,43 +1144,43 @@ s32 Collider_ResetLineOC(struct PlayState* play, OcLine* line) { * Initializes CollisionCheckContext. * Clears all collider arrays, disables SAC, and sets flags for drawing colliders. */ -void CollisionCheck_InitContext(struct PlayState* play, CollisionCheckContext* colCtxt) { - colCtxt->sacFlags = 0; - CollisionCheck_ClearContext(play, colCtxt); +void CollisionCheck_InitContext(struct PlayState* play, CollisionCheckContext* colChkCtx) { + colChkCtx->sacFlags = 0; + CollisionCheck_ClearContext(play, colChkCtx); } -void CollisionCheck_DestroyContext(struct PlayState* play, CollisionCheckContext* colCtxt) { +void CollisionCheck_DestroyContext(struct PlayState* play, CollisionCheckContext* colChkCtx) { } /** * Clears all collider lists in CollisionCheckContext when not in SAC mode. */ -void CollisionCheck_ClearContext(struct PlayState* play, CollisionCheckContext* colCtxt) { - Collider** col; +void CollisionCheck_ClearContext(struct PlayState* play, CollisionCheckContext* colChkCtx) { + Collider** colP; OcLine** line; - if (colCtxt->sacFlags & SAC_ON) { + if (colChkCtx->sacFlags & SAC_ON) { return; } - colCtxt->colATCount = 0; - colCtxt->colACCount = 0; - colCtxt->colOCCount = 0; - colCtxt->colLineCount = 0; + colChkCtx->colATCount = 0; + colChkCtx->colACCount = 0; + colChkCtx->colOCCount = 0; + colChkCtx->colLineCount = 0; - for (col = &colCtxt->colAT[0]; col < &colCtxt->colAT[ARRAY_COUNT(colCtxt->colAT)]; col++) { - *col = NULL; + for (colP = &colChkCtx->colAT[0]; colP < &colChkCtx->colAT[ARRAY_COUNT(colChkCtx->colAT)]; colP++) { + *colP = NULL; } - for (col = &colCtxt->colAC[0]; col < &colCtxt->colAC[ARRAY_COUNT(colCtxt->colAC)]; col++) { - *col = NULL; + for (colP = &colChkCtx->colAC[0]; colP < &colChkCtx->colAC[ARRAY_COUNT(colChkCtx->colAC)]; colP++) { + *colP = NULL; } - for (col = &colCtxt->colOC[0]; col < &colCtxt->colOC[ARRAY_COUNT(colCtxt->colOC)]; col++) { - *col = NULL; + for (colP = &colChkCtx->colOC[0]; colP < &colChkCtx->colOC[ARRAY_COUNT(colChkCtx->colOC)]; colP++) { + *colP = NULL; } - for (line = &colCtxt->colLine[0]; line < &colCtxt->colLine[ARRAY_COUNT(colCtxt->colLine)]; line++) { + for (line = &colChkCtx->colLine[0]; line < &colChkCtx->colLine[ARRAY_COUNT(colChkCtx->colLine)]; line++) { *line = NULL; } } @@ -1186,44 +1188,47 @@ void CollisionCheck_ClearContext(struct PlayState* play, CollisionCheckContext* /** * Enables SAC, an alternate collision check mode that allows direct management of collider lists. */ -void CollisionCheck_EnableSAC(struct PlayState* play, CollisionCheckContext* colCtxt) { - colCtxt->sacFlags |= SAC_ON; +void CollisionCheck_EnableSAC(struct PlayState* play, CollisionCheckContext* colChkCtx) { + colChkCtx->sacFlags |= SAC_ON; } /** * Disables SAC, an alternate collision check mode that allows direct management of collider lists. */ -void CollisionCheck_DisableSAC(struct PlayState* play, CollisionCheckContext* colCtxt) { - colCtxt->sacFlags &= ~SAC_ON; +void CollisionCheck_DisableSAC(struct PlayState* play, CollisionCheckContext* colChkCtx) { + colChkCtx->sacFlags &= ~SAC_ON; } -ColChkResetFunc sATResetFuncs[] = { - Collider_ResetJntSphAT, Collider_ResetCylinderAT, Collider_ResetTrisAT, - Collider_ResetQuadAT, Collider_ResetSphereAT, +ColChkResetFunc sATResetFuncs[COLSHAPE_MAX] = { + Collider_ResetJntSphAT, // COLSHAPE_JNTSPH + Collider_ResetCylinderAT, // COLSHAPE_CYLINDER + Collider_ResetTrisAT, // COLSHAPE_TRIS + Collider_ResetQuadAT, // COLSHAPE_QUAD + Collider_ResetSphereAT, // COLSHAPE_SPHERE }; /** * Sets collider as an AT (attack) for the current frame, which will be checked against ACs (attack colliders) */ -s32 CollisionCheck_SetAT(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { +s32 CollisionCheck_SetAT(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { s32 index; if (FrameAdvance_IsEnabled(play)) { return -1; } - sATResetFuncs[collider->shape](play, collider); + sATResetFuncs[col->shape](play, col); - if ((collider->actor != NULL) && (collider->actor->update == NULL)) { + if ((col->actor != NULL) && (col->actor->update == NULL)) { return -1; } - if (colCtxt->colATCount >= ARRAY_COUNT(colCtxt->colAT)) { + if (colChkCtx->colATCount >= ARRAY_COUNT(colChkCtx->colAT)) { return -1; } - if (colCtxt->sacFlags & SAC_ON) { + if (colChkCtx->sacFlags & SAC_ON) { return -1; } - index = colCtxt->colATCount; - colCtxt->colAT[colCtxt->colATCount++] = collider; + index = colChkCtx->colATCount; + colChkCtx->colAT[colChkCtx->colATCount++] = col; return index; } @@ -1233,57 +1238,60 @@ s32 CollisionCheck_SetAT(struct PlayState* play, CollisionCheckContext* colCtxt, * If CollisionCheck_SAC is enabled, the collider will be inserted into the list at the specified index, otherwise it * will be inserted into the next slot. */ -s32 CollisionCheck_SetAT_SAC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { +s32 CollisionCheck_SetAT_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, s32 index) { if (FrameAdvance_IsEnabled(play)) { return -1; } - sATResetFuncs[collider->shape](play, collider); + sATResetFuncs[col->shape](play, col); - if ((collider->actor != NULL) && (collider->actor->update == NULL)) { + if ((col->actor != NULL) && (col->actor->update == NULL)) { return -1; } - if (colCtxt->sacFlags & SAC_ON) { - if (index >= colCtxt->colATCount) { + if (colChkCtx->sacFlags & SAC_ON) { + if (index >= colChkCtx->colATCount) { return -1; } - colCtxt->colAT[index] = collider; + colChkCtx->colAT[index] = col; } else { - if (colCtxt->colATCount >= ARRAY_COUNT(colCtxt->colAT)) { + if (colChkCtx->colATCount >= ARRAY_COUNT(colChkCtx->colAT)) { return -1; } - index = colCtxt->colATCount; - colCtxt->colAT[colCtxt->colATCount++] = collider; + index = colChkCtx->colATCount; + colChkCtx->colAT[colChkCtx->colATCount++] = col; } return index; } -ColChkResetFunc sACResetFuncs[] = { - Collider_ResetJntSphAC, Collider_ResetCylinderAC, Collider_ResetTrisAC, - Collider_ResetQuadAC, Collider_ResetSphereAC, +ColChkResetFunc sACResetFuncs[COLSHAPE_MAX] = { + Collider_ResetJntSphAC, // COLSHAPE_JNTSPH + Collider_ResetCylinderAC, // COLSHAPE_CYLINDER + Collider_ResetTrisAC, // COLSHAPE_TRIS + Collider_ResetQuadAC, // COLSHAPE_QUAD + Collider_ResetSphereAC, // COLSHAPE_SPHERE }; /** * Sets collider as an AC (attack collider) for the current frame, allowing it to detect ATs (attacks) */ -s32 CollisionCheck_SetAC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { +s32 CollisionCheck_SetAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { s32 index; if (FrameAdvance_IsEnabled(play)) { return -1; } - sACResetFuncs[collider->shape](play, collider); + sACResetFuncs[col->shape](play, col); - if ((collider->actor != NULL) && (collider->actor->update == NULL)) { + if ((col->actor != NULL) && (col->actor->update == NULL)) { return -1; } - if (colCtxt->colACCount >= ARRAY_COUNT(colCtxt->colAC)) { + if (colChkCtx->colACCount >= ARRAY_COUNT(colChkCtx->colAC)) { return -1; } - if (colCtxt->sacFlags & SAC_ON) { + if (colChkCtx->sacFlags & SAC_ON) { return -1; } - index = colCtxt->colACCount; - colCtxt->colAC[colCtxt->colACCount++] = collider; + index = colChkCtx->colACCount; + colChkCtx->colAC[colChkCtx->colACCount++] = col; return index; } @@ -1293,33 +1301,36 @@ s32 CollisionCheck_SetAC(struct PlayState* play, CollisionCheckContext* colCtxt, * If CollisionCheck_SAC is enabled, the collider will be inserted into the list at the specified index, otherwise it * will be inserted into the next slot */ -s32 CollisionCheck_SetAC_SAC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { +s32 CollisionCheck_SetAC_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, s32 index) { if (FrameAdvance_IsEnabled(play)) { return -1; } - sACResetFuncs[collider->shape](play, collider); + sACResetFuncs[col->shape](play, col); - if ((collider->actor != NULL) && (collider->actor->update == NULL)) { + if ((col->actor != NULL) && (col->actor->update == NULL)) { return -1; } - if (colCtxt->sacFlags & SAC_ON) { - if (index >= colCtxt->colACCount) { + if (colChkCtx->sacFlags & SAC_ON) { + if (index >= colChkCtx->colACCount) { return -1; } - colCtxt->colAC[index] = collider; + colChkCtx->colAC[index] = col; } else { - if (colCtxt->colACCount >= ARRAY_COUNT(colCtxt->colAC)) { + if (colChkCtx->colACCount >= ARRAY_COUNT(colChkCtx->colAC)) { return -1; } - index = colCtxt->colACCount; - colCtxt->colAC[colCtxt->colACCount++] = collider; + index = colChkCtx->colACCount; + colChkCtx->colAC[colChkCtx->colACCount++] = col; } return index; } -ColChkResetFunc sOCResetFuncs[] = { - Collider_ResetJntSphOC, Collider_ResetCylinderOC, Collider_ResetTrisOC, - Collider_ResetQuadOC, Collider_ResetSphereOC, +static ColChkResetFunc sOCResetFuncs[COLSHAPE_MAX] = { + Collider_ResetJntSphOC, // COLSHAPE_JNTSPH + Collider_ResetCylinderOC, // COLSHAPE_CYLINDER + Collider_ResetTrisOC, // COLSHAPE_TRIS + Collider_ResetQuadOC, // COLSHAPE_QUAD + Collider_ResetSphereOC, // COLSHAPE_SPHERE }; TriNorm D_801EE6C8; @@ -1328,25 +1339,25 @@ TriNorm D_801EE700; /** * Sets collider as an OC (object collider) for the current frame, allowing it to detect other OCs. */ -s32 CollisionCheck_SetOC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { +s32 CollisionCheck_SetOC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { s32 index; if (FrameAdvance_IsEnabled(play)) { return -1; } - sOCResetFuncs[collider->shape](play, collider); + sOCResetFuncs[col->shape](play, col); - if ((collider->actor != NULL) && (collider->actor->update == NULL)) { + if ((col->actor != NULL) && (col->actor->update == NULL)) { return -1; } - if (colCtxt->colOCCount >= ARRAY_COUNT(colCtxt->colOC)) { + if (colChkCtx->colOCCount >= ARRAY_COUNT(colChkCtx->colOC)) { return -1; } - if (colCtxt->sacFlags & SAC_ON) { + if (colChkCtx->sacFlags & SAC_ON) { return -1; } - index = colCtxt->colOCCount; - colCtxt->colOC[colCtxt->colOCCount++] = collider; + index = colChkCtx->colOCCount; + colChkCtx->colOC[colChkCtx->colOCCount++] = col; return index; } @@ -1356,29 +1367,29 @@ s32 CollisionCheck_SetOC(struct PlayState* play, CollisionCheckContext* colCtxt, * If CollisionCheck_SAC is enabled, the collider will be inserted into the list at the specified index, otherwise it * will be inserted into the next slot. */ -s32 CollisionCheck_SetOC_SAC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { +s32 CollisionCheck_SetOC_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, s32 index) { if (FrameAdvance_IsEnabled(play)) { return -1; } - sOCResetFuncs[collider->shape](play, collider); + sOCResetFuncs[col->shape](play, col); - if ((collider->actor != NULL) && (collider->actor->update == NULL)) { + if ((col->actor != NULL) && (col->actor->update == NULL)) { return -1; } - if (colCtxt->sacFlags & SAC_ON) { - if (index >= colCtxt->colOCCount) { + if (colChkCtx->sacFlags & SAC_ON) { + if (index >= colChkCtx->colOCCount) { return -1; } //! @bug should be colOC - colCtxt->colAT[index] = collider; + colChkCtx->colAT[index] = col; } else { - if (colCtxt->colOCCount >= ARRAY_COUNT(colCtxt->colOC)) { + if (colChkCtx->colOCCount >= ARRAY_COUNT(colChkCtx->colOC)) { return -1; } - index = colCtxt->colOCCount; + index = colChkCtx->colOCCount; - colCtxt->colOC[colCtxt->colOCCount] = collider; - colCtxt->colOCCount++; + colChkCtx->colOC[colChkCtx->colOCCount] = col; + colChkCtx->colOCCount++; } return index; } @@ -1386,7 +1397,7 @@ s32 CollisionCheck_SetOC_SAC(struct PlayState* play, CollisionCheckContext* colC /** * Sets a line as an OC collider for this frame. */ -s32 CollisionCheck_SetOCLine(struct PlayState* play, CollisionCheckContext* colCtxt, OcLine* line) { +s32 CollisionCheck_SetOCLine(struct PlayState* play, CollisionCheckContext* colChkCtx, OcLine* line) { s32 index; if (FrameAdvance_IsEnabled(play)) { @@ -1395,11 +1406,11 @@ s32 CollisionCheck_SetOCLine(struct PlayState* play, CollisionCheckContext* colC Collider_ResetLineOC(play, line); - if (colCtxt->colLineCount >= ARRAY_COUNT(colCtxt->colLine)) { + if (colChkCtx->colLineCount >= ARRAY_COUNT(colChkCtx->colLine)) { return -1; } - index = colCtxt->colLineCount; - colCtxt->colLine[colCtxt->colLineCount++] = line; + index = colChkCtx->colLineCount; + colChkCtx->colLine[colChkCtx->colLineCount++] = line; return index; } @@ -1429,23 +1440,23 @@ s32 CollisionCheck_SkipBump(ColliderInfo* info) { */ s32 CollisionCheck_NoSharedFlags(ColliderInfo* toucher, ColliderInfo* bumper) { if (!(toucher->toucher.dmgFlags & bumper->bumper.dmgFlags)) { - return 1; + return true; } - return 0; + return false; } /** * Spawns no blood drops. * Used by collider types HIT1, HIT3, HIT5, METAL, NONE, WOOD, HARD, and TREE */ -void CollisionCheck_NoBlood(struct PlayState* play, Collider* collider, Vec3f* v) { +void CollisionCheck_NoBlood(struct PlayState* play, Collider* col, Vec3f* v) { } /** * Spawns blue blood drops. * Used by collider types HIT0 and HIT8. */ -void CollisionCheck_BlueBlood(struct PlayState* play, Collider* collider, Vec3f* v) { +void CollisionCheck_BlueBlood(struct PlayState* play, Collider* col, Vec3f* v) { static EffectSparkInit D_801EEC00; s32 effectIndex; @@ -1498,7 +1509,7 @@ void CollisionCheck_BlueBlood(struct PlayState* play, Collider* collider, Vec3f* * Spawns green blood drops. * Used by collider types HIT2 and HIT6. No actor has type HIT2. */ -void CollisionCheck_GreenBlood(struct PlayState* play, Collider* collider, Vec3f* v) { +void CollisionCheck_GreenBlood(struct PlayState* play, Collider* col, Vec3f* v) { static EffectSparkInit D_801EF0C8; s32 effectIndex; @@ -1553,7 +1564,7 @@ TriNorm D_801EF5C8; * Spawns a burst of water. * Used by collider type HIT4. */ -void CollisionCheck_WaterBurst(struct PlayState* play, Collider* collider, Vec3f* v) { +void CollisionCheck_WaterBurst(struct PlayState* play, Collider* col, Vec3f* v) { EffectSsSibuki_SpawnBurst(play, v); CollisionCheck_SpawnWaterDroplets(play, v); } @@ -1562,50 +1573,50 @@ void CollisionCheck_WaterBurst(struct PlayState* play, Collider* collider, Vec3f * Spawns red blood drops. * Used by collider type HIT7. */ -void CollisionCheck_RedBlood(struct PlayState* play, Collider* collider, Vec3f* v) { +void CollisionCheck_RedBlood(struct PlayState* play, Collider* col, Vec3f* v) { CollisionCheck_SpawnRedBlood(play, v); } /** * Spawns red blood drops. */ -void CollisionCheck_RedBloodUnused(struct PlayState* play, Collider* collider, Vec3f* v) { +void CollisionCheck_RedBloodUnused(struct PlayState* play, Collider* col, Vec3f* v) { CollisionCheck_SpawnRedBlood(play, v); } /** * Plays sound effects and displays hitmarks for solid-type AC colliders (METAL, WOOD, HARD, and TREE) */ -void CollisionCheck_HitSolid(struct PlayState* play, ColliderInfo* info, Collider* collider, Vec3f* hitPos) { +void CollisionCheck_HitSolid(struct PlayState* play, ColliderInfo* info, Collider* col, Vec3f* hitPos) { s32 flags = info->toucherFlags & TOUCH_SFX_NONE; - if ((flags == TOUCH_SFX_NORMAL) && (collider->colType != COLTYPE_METAL)) { + if ((flags == TOUCH_SFX_NORMAL) && (col->colType != COLTYPE_METAL)) { EffectSsHitmark_SpawnFixedScale(play, 0, hitPos); - if (collider->actor == NULL) { + if (col->actor == NULL) { Audio_PlaySfx(NA_SE_IT_SHIELD_BOUND); } else { - Audio_PlaySfx_AtPos(&collider->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); + Audio_PlaySfx_AtPos(&col->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); } } else if (flags == TOUCH_SFX_NORMAL) { EffectSsHitmark_SpawnFixedScale(play, 3, hitPos); - if (collider->actor == NULL) { + if (col->actor == NULL) { CollisionCheck_SpawnShieldParticlesMetal(play, hitPos); } else { - CollisionCheck_SpawnShieldParticlesMetalSound(play, hitPos, &collider->actor->projectedPos); + CollisionCheck_SpawnShieldParticlesMetalSound(play, hitPos, &col->actor->projectedPos); } } else if (flags == TOUCH_SFX_HARD) { EffectSsHitmark_SpawnFixedScale(play, 0, hitPos); - if (collider->actor == NULL) { + if (col->actor == NULL) { Audio_PlaySfx(NA_SE_IT_SHIELD_BOUND); } else { - Audio_PlaySfx_AtPos(&collider->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); + Audio_PlaySfx_AtPos(&col->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); } } else if (flags == TOUCH_SFX_WOOD) { EffectSsHitmark_SpawnFixedScale(play, 1, hitPos); - if (collider->actor == NULL) { + if (col->actor == NULL) { Audio_PlaySfx(NA_SE_IT_REFLECTION_WOOD); } else { - Audio_PlaySfx_AtPos(&collider->actor->projectedPos, NA_SE_IT_REFLECTION_WOOD); + Audio_PlaySfx_AtPos(&col->actor->projectedPos, NA_SE_IT_REFLECTION_WOOD); } } } @@ -1693,13 +1704,13 @@ void CollisionCheck_SetBounce(Collider* at, Collider* ac) { /** * Performs the AC collision between the AT element and AC element that collided. */ -s32 CollisionCheck_SetATvsAC(struct PlayState* play, Collider* at, ColliderInfo* atInfo, Vec3f* atPos, Collider* ac, - ColliderInfo* acInfo, Vec3f* acPos, Vec3f* hitPos) { +s32 CollisionCheck_SetATvsAC(struct PlayState* play, Collider* atCol, ColliderInfo* atInfo, Vec3f* atPos, + Collider* acCol, ColliderInfo* acInfo, Vec3f* acPos, Vec3f* hitPos) { f32 damage; u32 effect; - if (CollisionCheck_GetToucherDamage(at, atInfo, ac, acInfo) != 0) { - damage = CollisionCheck_GetDamageAndEffectOnBumper(at, atInfo, ac, acInfo, &effect); + if (CollisionCheck_GetToucherDamage(atCol, atInfo, acCol, acInfo) != 0) { + damage = CollisionCheck_GetDamageAndEffectOnBumper(atCol, atInfo, acCol, acInfo, &effect); if (damage < 1.0f) { if (effect == 0) { return 0; @@ -1708,13 +1719,13 @@ s32 CollisionCheck_SetATvsAC(struct PlayState* play, Collider* at, ColliderInfo* return 0; } } - if ((ac->acFlags & AC_HARD) && (at->actor != NULL) && (ac->actor != NULL)) { - CollisionCheck_SetBounce(at, ac); + if ((acCol->acFlags & AC_HARD) && (atCol->actor != NULL) && (acCol->actor != NULL)) { + CollisionCheck_SetBounce(atCol, acCol); } if (!(acInfo->bumperFlags & BUMP_NO_AT_INFO)) { - at->atFlags |= AT_HIT; - at->at = ac->actor; - atInfo->atHit = ac; + atCol->atFlags |= AT_HIT; + atCol->at = acCol->actor; + atInfo->atHit = acCol; atInfo->toucherFlags |= TOUCH_HIT; atInfo->atHitInfo = acInfo; if (!(atInfo->bumperFlags & BUMP_HIT)) { @@ -1722,28 +1733,28 @@ s32 CollisionCheck_SetATvsAC(struct PlayState* play, Collider* at, ColliderInfo* atInfo->bumper.hitPos.y = hitPos->y; atInfo->bumper.hitPos.z = hitPos->z; } - if (at->actor != NULL) { - at->actor->colChkInfo.atHitEffect = acInfo->bumper.effect; + if (atCol->actor != NULL) { + atCol->actor->colChkInfo.atHitEffect = acInfo->bumper.effect; } } if (!(atInfo->ocElemFlags & OCELEM_UNK2)) { - ac->acFlags |= AC_HIT; - ac->ac = at->actor; - acInfo->acHit = at; + acCol->acFlags |= AC_HIT; + acCol->ac = atCol->actor; + acInfo->acHit = atCol; acInfo->acHitInfo = atInfo; acInfo->bumperFlags |= BUMP_HIT; - if (ac->actor != NULL) { - ac->actor->colChkInfo.acHitEffect = atInfo->toucher.effect; + if (acCol->actor != NULL) { + acCol->actor->colChkInfo.acHitEffect = atInfo->toucher.effect; } acInfo->bumper.hitPos.x = hitPos->x; acInfo->bumper.hitPos.y = hitPos->y; acInfo->bumper.hitPos.z = hitPos->z; } - if (!(atInfo->toucherFlags & TOUCH_AT_HITMARK) && (ac->colType != COLTYPE_METAL) && (ac->colType != COLTYPE_WOOD) && - (ac->colType != COLTYPE_HARD)) { + if (!(atInfo->toucherFlags & TOUCH_AT_HITMARK) && (acCol->colType != COLTYPE_METAL) && + (acCol->colType != COLTYPE_WOOD) && (acCol->colType != COLTYPE_HARD)) { acInfo->bumperFlags |= BUMP_DRAW_HITMARK; } else { - CollisionCheck_HitEffects(play, at, atInfo, ac, acInfo, hitPos); + CollisionCheck_HitEffects(play, atCol, atInfo, acCol, acInfo, hitPos); atInfo->toucherFlags |= TOUCH_DREW_HITMARK; } return 1; @@ -1769,11 +1780,11 @@ TriNorm D_801EF638; /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderJntSph* at = (ColliderJntSph*)colAT; +void CollisionCheck_AC_JntSphVsJntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderJntSph* at = (ColliderJntSph*)atCol; ColliderJntSphElement* atElem; - ColliderJntSph* ac = (ColliderJntSph*)colAC; + ColliderJntSph* ac = (ColliderJntSph*)acCol; ColliderJntSphElement* acElem; f32 overlapSize; f32 centerDist; @@ -1793,7 +1804,7 @@ void CollisionCheck_AC_JntSphVsJntSph(struct PlayState* play, CollisionCheckCont } if (Math3D_SphVsSphOverlapCenterDist(&atElem->dim.worldSphere, &acElem->dim.worldSphere, &overlapSize, - ¢erDist) != 0) { + ¢erDist)) { f32 acToHit; Vec3f hitPos; Vec3f atPos; @@ -1825,11 +1836,11 @@ void CollisionCheck_AC_JntSphVsJntSph(struct PlayState* play, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderJntSph* at = (ColliderJntSph*)colAT; +void CollisionCheck_AC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderJntSph* at = (ColliderJntSph*)atCol; ColliderJntSphElement* atElem; - ColliderCylinder* ac = (ColliderCylinder*)colAC; + ColliderCylinder* ac = (ColliderCylinder*)acCol; f32 overlapSize; f32 centerDist; @@ -1874,11 +1885,11 @@ void CollisionCheck_AC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderJntSph* at = (ColliderJntSph*)colAT; +void CollisionCheck_AC_JntSphVsTris(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderJntSph* at = (ColliderJntSph*)atCol; ColliderJntSphElement* atElem; - ColliderTris* ac = (ColliderTris*)colAC; + ColliderTris* ac = (ColliderTris*)acCol; ColliderTrisElement* acElem; Vec3f hitPos; @@ -1894,7 +1905,7 @@ void CollisionCheck_AC_JntSphVsTris(struct PlayState* play, CollisionCheckContex if (CollisionCheck_NoSharedFlags(&atElem->info, &acElem->info)) { continue; } - if (Math3D_TriVsSphIntersect(&atElem->dim.worldSphere, &acElem->dim, &hitPos) != 0) { + if (Math3D_TriVsSphIntersect(&atElem->dim.worldSphere, &acElem->dim, &hitPos)) { Vec3f atPos; Vec3f acPos; @@ -1912,10 +1923,10 @@ void CollisionCheck_AC_JntSphVsTris(struct PlayState* play, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderJntSph* at = (ColliderJntSph*)colAT; - ColliderQuad* ac = (ColliderQuad*)colAC; +void CollisionCheck_AC_JntSphVsQuad(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderJntSph* at = (ColliderJntSph*)atCol; + ColliderQuad* ac = (ColliderQuad*)acCol; Vec3f hitPos; ColliderJntSphElement* sphElem; @@ -1933,8 +1944,8 @@ void CollisionCheck_AC_JntSphVsQuad(struct PlayState* play, CollisionCheckContex if (CollisionCheck_NoSharedFlags(&sphElem->info, &ac->info)) { continue; } - if (Math3D_TriVsSphIntersect(&sphElem->dim.worldSphere, &D_801EF590, &hitPos) != 0 || - Math3D_TriVsSphIntersect(&sphElem->dim.worldSphere, &D_801EF5C8, &hitPos) != 0) { + if (Math3D_TriVsSphIntersect(&sphElem->dim.worldSphere, &D_801EF590, &hitPos) || + Math3D_TriVsSphIntersect(&sphElem->dim.worldSphere, &D_801EF5C8, &hitPos)) { Vec3f atPos; Vec3f acPos; @@ -1951,10 +1962,10 @@ void CollisionCheck_AC_JntSphVsQuad(struct PlayState* play, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderJntSph* at = (ColliderJntSph*)colAT; - ColliderSphere* ac = (ColliderSphere*)colAC; +void CollisionCheck_AC_JntSphVsSphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderJntSph* at = (ColliderJntSph*)atCol; + ColliderSphere* ac = (ColliderSphere*)acCol; ColliderJntSphElement* sphElem; f32 overlapSize; f32 centerDist; @@ -1971,7 +1982,7 @@ void CollisionCheck_AC_JntSphVsSphere(struct PlayState* play, CollisionCheckCont continue; } if (Math3D_SphVsSphOverlapCenterDist(&sphElem->dim.worldSphere, &ac->dim.worldSphere, &overlapSize, - ¢erDist) != 0) { + ¢erDist)) { f32 acToHit; Vec3f hitPos; Vec3f atPos; @@ -1997,10 +2008,10 @@ void CollisionCheck_AC_JntSphVsSphere(struct PlayState* play, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderCylinder* at = (ColliderCylinder*)colAT; - ColliderJntSph* ac = (ColliderJntSph*)colAC; +void CollisionCheck_AC_CylVsJntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderCylinder* at = (ColliderCylinder*)atCol; + ColliderJntSph* ac = (ColliderJntSph*)acCol; f32 overlapSize; f32 centerDist; ColliderJntSphElement* sphElem; @@ -2016,7 +2027,7 @@ void CollisionCheck_AC_CylVsJntSph(struct PlayState* play, CollisionCheckContext if (CollisionCheck_NoSharedFlags(&at->info, &sphElem->info)) { continue; } - if (Math3D_SphVsCylOverlapCenterDist(&sphElem->dim.worldSphere, &at->dim, &overlapSize, ¢erDist) != 0) { + if (Math3D_SphVsCylOverlapCenterDist(&sphElem->dim.worldSphere, &at->dim, &overlapSize, ¢erDist)) { Vec3f hitPos; Vec3f atPos; Vec3f acPos; @@ -2049,10 +2060,10 @@ void CollisionCheck_AC_CylVsJntSph(struct PlayState* play, CollisionCheckContext /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderCylinder* at = (ColliderCylinder*)colAT; - ColliderCylinder* ac = (ColliderCylinder*)colAC; +void CollisionCheck_AC_CylVsCyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderCylinder* at = (ColliderCylinder*)atCol; + ColliderCylinder* ac = (ColliderCylinder*)acCol; f32 overlapSize; f32 centerDist; @@ -2067,7 +2078,7 @@ void CollisionCheck_AC_CylVsCyl(struct PlayState* play, CollisionCheckContext* c return; } - if (Math3D_CylVsCylOverlapCenterDist(&at->dim, &ac->dim, &overlapSize, ¢erDist) != 0) { + if (Math3D_CylVsCylOverlapCenterDist(&at->dim, &ac->dim, &overlapSize, ¢erDist)) { Vec3f hitPos; Vec3f atPos; Vec3f acPos; @@ -2102,10 +2113,10 @@ void CollisionCheck_AC_CylVsCyl(struct PlayState* play, CollisionCheckContext* c /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderCylinder* at = (ColliderCylinder*)colAT; - ColliderTris* ac = (ColliderTris*)colAC; +void CollisionCheck_AC_CylVsTris(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderCylinder* at = (ColliderCylinder*)atCol; + ColliderTris* ac = (ColliderTris*)acCol; ColliderTrisElement* acElem; Vec3f hitPos; @@ -2122,7 +2133,7 @@ void CollisionCheck_AC_CylVsTris(struct PlayState* play, CollisionCheckContext* continue; } - if (Math3D_CylTriVsIntersect(&at->dim, &acElem->dim, &hitPos) != 0) { + if (Math3D_CylTriVsIntersect(&at->dim, &acElem->dim, &hitPos)) { Vec3f atPos; Vec3f acPos; @@ -2138,10 +2149,10 @@ void CollisionCheck_AC_CylVsTris(struct PlayState* play, CollisionCheckContext* /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderCylinder* at = (ColliderCylinder*)colAT; - ColliderQuad* ac = (ColliderQuad*)colAC; +void CollisionCheck_AC_CylVsQuad(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderCylinder* at = (ColliderCylinder*)atCol; + ColliderQuad* ac = (ColliderQuad*)acCol; if ((at->dim.height > 0) && (at->dim.radius > 0)) { if (CollisionCheck_SkipTouch(&at->info)) { @@ -2156,14 +2167,14 @@ void CollisionCheck_AC_CylVsQuad(struct PlayState* play, CollisionCheckContext* Math3D_TriNorm(&D_801EF600, &ac->dim.quad[2], &ac->dim.quad[3], &ac->dim.quad[1]); Math3D_TriNorm(&D_801EF638, &ac->dim.quad[1], &ac->dim.quad[0], &ac->dim.quad[2]); - if (Math3D_CylTriVsIntersect(&at->dim, &D_801EF600, &D_801EDE00) != 0) { + if (Math3D_CylTriVsIntersect(&at->dim, &D_801EF600, &D_801EDE00)) { Vec3f atPos; Vec3f acPos; Math_Vec3s_ToVec3f(&atPos, &at->dim.pos); CollisionCheck_QuadAvgPoint(ac, &acPos); CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EDE00); - } else if (Math3D_CylTriVsIntersect(&at->dim, &D_801EF638, &D_801EDE00) != 0) { + } else if (Math3D_CylTriVsIntersect(&at->dim, &D_801EF638, &D_801EDE00)) { Vec3f atPos; Vec3f acPos; @@ -2177,10 +2188,10 @@ void CollisionCheck_AC_CylVsQuad(struct PlayState* play, CollisionCheckContext* /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderCylinder* at = (ColliderCylinder*)colAT; - ColliderSphere* ac = (ColliderSphere*)colAC; +void CollisionCheck_AC_CylVsSphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderCylinder* at = (ColliderCylinder*)atCol; + ColliderSphere* ac = (ColliderSphere*)acCol; f32 overlapSize; f32 centerDist; @@ -2195,7 +2206,7 @@ void CollisionCheck_AC_CylVsSphere(struct PlayState* play, CollisionCheckContext return; } - if (Math3D_SphVsCylOverlapCenterDist(&ac->dim.worldSphere, &at->dim, &overlapSize, ¢erDist) != 0) { + if (Math3D_SphVsCylOverlapCenterDist(&ac->dim.worldSphere, &at->dim, &overlapSize, ¢erDist)) { Vec3f hitPos; Vec3f atPos; Vec3f acPos; @@ -2224,11 +2235,11 @@ void CollisionCheck_AC_CylVsSphere(struct PlayState* play, CollisionCheckContext /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderTris* at = (ColliderTris*)colAT; +void CollisionCheck_AC_TrisVsJntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderTris* at = (ColliderTris*)atCol; ColliderJntSphElement* acElem; - ColliderJntSph* ac = (ColliderJntSph*)colAC; + ColliderJntSph* ac = (ColliderJntSph*)acCol; ColliderTrisElement* atElem; Vec3f hitPos; @@ -2265,10 +2276,10 @@ void CollisionCheck_AC_TrisVsJntSph(struct PlayState* play, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderTris* at = (ColliderTris*)colAT; - ColliderCylinder* ac = (ColliderCylinder*)colAC; +void CollisionCheck_AC_TrisVsCyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderTris* at = (ColliderTris*)atCol; + ColliderCylinder* ac = (ColliderCylinder*)acCol; ColliderTrisElement* atElem; if ((ac->dim.radius > 0) && (ac->dim.height > 0) && (at->count > 0) && (at->elements != NULL)) { @@ -2282,7 +2293,7 @@ void CollisionCheck_AC_TrisVsCyl(struct PlayState* play, CollisionCheckContext* if (CollisionCheck_NoSharedFlags(&atElem->info, &ac->info)) { continue; } - if (Math3D_CylTriVsIntersect(&ac->dim, &atElem->dim, &D_801EDE10) != 0) { + if (Math3D_CylTriVsIntersect(&ac->dim, &atElem->dim, &D_801EDE10)) { Vec3f atPos; Vec3f acPos; @@ -2299,11 +2310,11 @@ void CollisionCheck_AC_TrisVsCyl(struct PlayState* play, CollisionCheckContext* /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderTris* at = (ColliderTris*)colAT; +void CollisionCheck_AC_TrisVsTris(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderTris* at = (ColliderTris*)atCol; ColliderTrisElement* atElem; - ColliderTris* ac = (ColliderTris*)colAC; + ColliderTris* ac = (ColliderTris*)acCol; ColliderTrisElement* acElem; if ((ac->count > 0) && (ac->elements != NULL) && (at->count > 0) && (at->elements != NULL)) { @@ -2318,7 +2329,7 @@ void CollisionCheck_AC_TrisVsTris(struct PlayState* play, CollisionCheckContext* if (CollisionCheck_NoSharedFlags(&atElem->info, &acElem->info)) { continue; } - if (Math3D_TriVsTriIntersect(&atElem->dim, &acElem->dim, &D_801EDE20) != 0) { + if (Math3D_TriVsTriIntersect(&atElem->dim, &acElem->dim, &D_801EDE20)) { Vec3f atPos; Vec3f acPos; @@ -2336,10 +2347,10 @@ void CollisionCheck_AC_TrisVsTris(struct PlayState* play, CollisionCheckContext* /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderTris* at = (ColliderTris*)colAT; - ColliderQuad* ac = (ColliderQuad*)colAC; +void CollisionCheck_AC_TrisVsQuad(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderTris* at = (ColliderTris*)atCol; + ColliderQuad* ac = (ColliderQuad*)acCol; ColliderTrisElement* atElem; if ((at->count > 0) && (at->elements != NULL)) { @@ -2357,8 +2368,8 @@ void CollisionCheck_AC_TrisVsQuad(struct PlayState* play, CollisionCheckContext* if (CollisionCheck_NoSharedFlags(&atElem->info, &ac->info)) { continue; } - if (Math3D_TriVsTriIntersect(&D_801EDE40, &atElem->dim, &D_801EDE30) != 0 || - Math3D_TriVsTriIntersect(&D_801EDE78, &atElem->dim, &D_801EDE30) != 0) { + if (Math3D_TriVsTriIntersect(&D_801EDE40, &atElem->dim, &D_801EDE30) || + Math3D_TriVsTriIntersect(&D_801EDE78, &atElem->dim, &D_801EDE30)) { Vec3f atPos; Vec3f acPos; @@ -2375,11 +2386,11 @@ void CollisionCheck_AC_TrisVsQuad(struct PlayState* play, CollisionCheckContext* /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderTris* at = (ColliderTris*)colAT; +void CollisionCheck_AC_TrisVsSphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderTris* at = (ColliderTris*)atCol; ColliderTrisElement* atElem; - ColliderSphere* ac = (ColliderSphere*)colAC; + ColliderSphere* ac = (ColliderSphere*)acCol; Vec3f hitPos; if ((at->count > 0) && (at->elements != NULL)) { @@ -2393,7 +2404,7 @@ void CollisionCheck_AC_TrisVsSphere(struct PlayState* play, CollisionCheckContex if (CollisionCheck_NoSharedFlags(&atElem->info, &ac->info)) { continue; } - if (Math3D_TriVsSphIntersect(&ac->dim.worldSphere, &atElem->dim, &hitPos) != 0) { + if (Math3D_TriVsSphIntersect(&ac->dim.worldSphere, &atElem->dim, &hitPos)) { Vec3f atPos; Vec3f acPos; @@ -2408,12 +2419,12 @@ void CollisionCheck_AC_TrisVsSphere(struct PlayState* play, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { +void CollisionCheck_AC_QuadVsJntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { ColliderJntSphElement* acElem; Vec3f hitPos; - ColliderQuad* at = (ColliderQuad*)colAT; - ColliderJntSph* ac = (ColliderJntSph*)colAC; + ColliderQuad* at = (ColliderQuad*)atCol; + ColliderJntSph* ac = (ColliderJntSph*)acCol; if ((ac->count > 0) && (ac->elements != NULL)) { if (CollisionCheck_SkipTouch(&at->info)) { @@ -2429,8 +2440,8 @@ void CollisionCheck_AC_QuadVsJntSph(struct PlayState* play, CollisionCheckContex if (CollisionCheck_NoSharedFlags(&at->info, &acElem->info)) { continue; } - if (Math3D_TriVsSphIntersect(&acElem->dim.worldSphere, &D_801EDEC8, &hitPos) != 0 || - Math3D_TriVsSphIntersect(&acElem->dim.worldSphere, &D_801EDF00, &hitPos) != 0) { + if (Math3D_TriVsSphIntersect(&acElem->dim.worldSphere, &D_801EDEC8, &hitPos) || + Math3D_TriVsSphIntersect(&acElem->dim.worldSphere, &D_801EDF00, &hitPos)) { Vec3f atPos; Vec3f acPos; @@ -2452,10 +2463,10 @@ void CollisionCheck_AC_QuadVsJntSph(struct PlayState* play, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderQuad* at = (ColliderQuad*)colAT; - ColliderCylinder* ac = (ColliderCylinder*)colAC; +void CollisionCheck_AC_QuadVsCyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderQuad* at = (ColliderQuad*)atCol; + ColliderCylinder* ac = (ColliderCylinder*)acCol; if ((ac->dim.height > 0) && (ac->dim.radius > 0)) { if (CollisionCheck_SkipBump(&ac->info)) { @@ -2471,7 +2482,7 @@ void CollisionCheck_AC_QuadVsCyl(struct PlayState* play, CollisionCheckContext* Math3D_TriNorm(&D_801EDF58, &at->dim.quad[2], &at->dim.quad[3], &at->dim.quad[1]); Math3D_TriNorm(&D_801EDF90, &at->dim.quad[2], &at->dim.quad[1], &at->dim.quad[0]); - if (Math3D_CylTriVsIntersect(&ac->dim, &D_801EDF58, &D_801EDFE0) != 0) { + if (Math3D_CylTriVsIntersect(&ac->dim, &D_801EDF58, &D_801EDFE0)) { if (Collider_QuadSetNearestAC(play, at, &D_801EDFE0)) { Vec3f atPos; Vec3f acPos; @@ -2482,7 +2493,7 @@ void CollisionCheck_AC_QuadVsCyl(struct PlayState* play, CollisionCheckContext* return; } } - if (Math3D_CylTriVsIntersect(&ac->dim, &D_801EDF90, &D_801EDFE0) != 0) { + if (Math3D_CylTriVsIntersect(&ac->dim, &D_801EDF90, &D_801EDFE0)) { if (Collider_QuadSetNearestAC(play, at, &D_801EDFE0)) { Vec3f atPos; Vec3f acPos; @@ -2498,10 +2509,10 @@ void CollisionCheck_AC_QuadVsCyl(struct PlayState* play, CollisionCheckContext* /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderQuad* at = (ColliderQuad*)colAT; - ColliderTris* ac = (ColliderTris*)colAC; +void CollisionCheck_AC_QuadVsTris(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderQuad* at = (ColliderQuad*)atCol; + ColliderTris* ac = (ColliderTris*)acCol; ColliderTrisElement* acElem; if ((ac->count > 0) && (ac->elements != NULL)) { @@ -2520,8 +2531,8 @@ void CollisionCheck_AC_QuadVsTris(struct PlayState* play, CollisionCheckContext* continue; } - if ((Math3D_TriVsTriIntersect(&D_801EE000, &acElem->dim, &D_801EDFF0) != 0) || - (Math3D_TriVsTriIntersect(&D_801EE038, &acElem->dim, &D_801EDFF0) != 0)) { + if ((Math3D_TriVsTriIntersect(&D_801EE000, &acElem->dim, &D_801EDFF0)) || + (Math3D_TriVsTriIntersect(&D_801EE038, &acElem->dim, &D_801EDFF0))) { if (Collider_QuadSetNearestAC(play, at, &D_801EDFF0)) { Vec3f atPos; Vec3f acPos; @@ -2540,10 +2551,10 @@ void CollisionCheck_AC_QuadVsTris(struct PlayState* play, CollisionCheckContext* /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderQuad* at = (ColliderQuad*)colAT; - ColliderQuad* ac = (ColliderQuad*)colAC; +void CollisionCheck_AC_QuadVsQuad(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderQuad* at = (ColliderQuad*)atCol; + ColliderQuad* ac = (ColliderQuad*)acCol; s32 i; s32 j; @@ -2564,8 +2575,8 @@ void CollisionCheck_AC_QuadVsQuad(struct PlayState* play, CollisionCheckContext* for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { - if (Math3D_TriVsTriIntersect(&D_801EE0E8[j], &D_801EE070[i], &D_801EE0D8) != 0 && - Collider_QuadSetNearestAC(play, at, &D_801EE0D8) != 0) { + if (Math3D_TriVsTriIntersect(&D_801EE0E8[j], &D_801EE070[i], &D_801EE0D8) && + Collider_QuadSetNearestAC(play, at, &D_801EE0D8)) { Vec3f atPos; Vec3f acPos; @@ -2581,11 +2592,11 @@ void CollisionCheck_AC_QuadVsQuad(struct PlayState* play, CollisionCheckContext* /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderQuad* at = (ColliderQuad*)colAT; +void CollisionCheck_AC_QuadVsSphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderQuad* at = (ColliderQuad*)atCol; Vec3f hitPos; - ColliderSphere* ac = (ColliderSphere*)colAC; + ColliderSphere* ac = (ColliderSphere*)acCol; if (CollisionCheck_SkipTouch(&at->info)) { return; @@ -2597,8 +2608,8 @@ void CollisionCheck_AC_QuadVsSphere(struct PlayState* play, CollisionCheckContex Math3D_TriNorm(&D_801EE150, &at->dim.quad[2], &at->dim.quad[3], &at->dim.quad[1]); Math3D_TriNorm(&D_801EE188, &at->dim.quad[2], &at->dim.quad[1], &at->dim.quad[0]); - if ((Math3D_TriVsSphIntersect(&ac->dim.worldSphere, &D_801EE150, &hitPos) != 0) || - (Math3D_TriVsSphIntersect(&ac->dim.worldSphere, &D_801EE188, &hitPos) != 0)) { + if ((Math3D_TriVsSphIntersect(&ac->dim.worldSphere, &D_801EE150, &hitPos)) || + (Math3D_TriVsSphIntersect(&ac->dim.worldSphere, &D_801EE188, &hitPos))) { if (Collider_QuadSetNearestAC(play, at, &hitPos)) { Vec3f atPos; Vec3f acPos; @@ -2613,10 +2624,10 @@ void CollisionCheck_AC_QuadVsSphere(struct PlayState* play, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_SphereVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderSphere* at = (ColliderSphere*)colAT; - ColliderJntSph* ac = (ColliderJntSph*)colAC; +void CollisionCheck_AC_SphereVsJntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderSphere* at = (ColliderSphere*)atCol; + ColliderJntSph* ac = (ColliderJntSph*)acCol; ColliderJntSphElement* acElem; f32 overlapSize; f32 centerDist; @@ -2635,7 +2646,7 @@ void CollisionCheck_AC_SphereVsJntSph(struct PlayState* play, CollisionCheckCont } if (Math3D_SphVsSphOverlapCenterDist(&at->dim.worldSphere, &acElem->dim.worldSphere, &overlapSize, - ¢erDist) != 0) { + ¢erDist)) { f32 acToHit; Vec3f hitPos; Vec3f atPos; @@ -2660,10 +2671,10 @@ void CollisionCheck_AC_SphereVsJntSph(struct PlayState* play, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_SphereVsCylinder(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderCylinder* ac = (ColliderCylinder*)colAC; - ColliderSphere* at = (ColliderSphere*)colAT; +void CollisionCheck_AC_SphereVsCylinder(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderCylinder* ac = (ColliderCylinder*)acCol; + ColliderSphere* at = (ColliderSphere*)atCol; f32 overlapSize; f32 centerDist; @@ -2677,7 +2688,7 @@ void CollisionCheck_AC_SphereVsCylinder(struct PlayState* play, CollisionCheckCo return; } - if (Math3D_SphVsCylOverlapCenterDist(&at->dim.worldSphere, &ac->dim, &overlapSize, ¢erDist) != 0) { + if (Math3D_SphVsCylOverlapCenterDist(&at->dim.worldSphere, &ac->dim, &overlapSize, ¢erDist)) { Vec3f hitPos; Vec3f atPos; Vec3f acPos; @@ -2707,10 +2718,10 @@ void CollisionCheck_AC_SphereVsCylinder(struct PlayState* play, CollisionCheckCo /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_SphereVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderSphere* at = (ColliderSphere*)colAT; - ColliderTris* ac = (ColliderTris*)colAC; +void CollisionCheck_AC_SphereVsTris(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderSphere* at = (ColliderSphere*)atCol; + ColliderTris* ac = (ColliderTris*)acCol; ColliderTrisElement* acElem; Vec3f hitPos; @@ -2725,7 +2736,7 @@ void CollisionCheck_AC_SphereVsTris(struct PlayState* play, CollisionCheckContex if (CollisionCheck_NoSharedFlags(&at->info, &acElem->info)) { continue; } - if (Math3D_TriVsSphIntersect(&at->dim.worldSphere, &acElem->dim, &hitPos) != 0) { + if (Math3D_TriVsSphIntersect(&at->dim.worldSphere, &acElem->dim, &hitPos)) { Vec3f atPos; Vec3f acPos; @@ -2740,11 +2751,11 @@ void CollisionCheck_AC_SphereVsTris(struct PlayState* play, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_SphereVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderSphere* at = (ColliderSphere*)colAT; +void CollisionCheck_AC_SphereVsQuad(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderSphere* at = (ColliderSphere*)atCol; Vec3f hitPos; - ColliderQuad* ac = (ColliderQuad*)colAC; + ColliderQuad* ac = (ColliderQuad*)acCol; if (CollisionCheck_SkipTouch(&at->info)) { return; @@ -2756,8 +2767,8 @@ void CollisionCheck_AC_SphereVsQuad(struct PlayState* play, CollisionCheckContex Math3D_TriNorm(&D_801EE6C8, &ac->dim.quad[2], &ac->dim.quad[3], &ac->dim.quad[1]); Math3D_TriNorm(&D_801EE700, &ac->dim.quad[1], &ac->dim.quad[0], &ac->dim.quad[2]); - if (Math3D_TriVsSphIntersect(&at->dim.worldSphere, &D_801EE6C8, &hitPos) != 0 || - Math3D_TriVsSphIntersect(&at->dim.worldSphere, &D_801EE700, &hitPos) != 0) { + if (Math3D_TriVsSphIntersect(&at->dim.worldSphere, &D_801EE6C8, &hitPos) || + Math3D_TriVsSphIntersect(&at->dim.worldSphere, &D_801EE700, &hitPos)) { Vec3f atPos; Vec3f acPos; @@ -2770,10 +2781,10 @@ void CollisionCheck_AC_SphereVsQuad(struct PlayState* play, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_SphereVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, - Collider* colAC) { - ColliderSphere* at = (ColliderSphere*)colAT; - ColliderSphere* ac = (ColliderSphere*)colAC; +void CollisionCheck_AC_SphereVsSphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, + Collider* acCol) { + ColliderSphere* at = (ColliderSphere*)atCol; + ColliderSphere* ac = (ColliderSphere*)acCol; f32 overlapSize; f32 centerDist; @@ -2787,7 +2798,7 @@ void CollisionCheck_AC_SphereVsSphere(struct PlayState* play, CollisionCheckCont return; } - if (Math3D_SphVsSphOverlapCenterDist(&at->dim.worldSphere, &ac->dim.worldSphere, &overlapSize, ¢erDist) != 0) { + if (Math3D_SphVsSphOverlapCenterDist(&at->dim.worldSphere, &ac->dim.worldSphere, &overlapSize, ¢erDist)) { f32 acToHit; Vec3f hitPos; Vec3f atPos; @@ -2810,8 +2821,8 @@ void CollisionCheck_AC_SphereVsSphere(struct PlayState* play, CollisionCheckCont /** * Sets a ColliderJntSph's hit effects */ -void CollisionCheck_SetJntSphHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { - ColliderJntSph* jntSph = (ColliderJntSph*)collider; +void CollisionCheck_SetJntSphHitFX(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { + ColliderJntSph* jntSph = (ColliderJntSph*)col; ColliderJntSphElement* element; for (element = jntSph->elements; element < &jntSph->elements[jntSph->count]; element++) { @@ -2831,8 +2842,8 @@ void CollisionCheck_SetJntSphHitFX(struct PlayState* play, CollisionCheckContext /** * Sets a ColliderCylinder's hit effects */ -void CollisionCheck_SetCylHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { - ColliderCylinder* cylinder = (ColliderCylinder*)collider; +void CollisionCheck_SetCylHitFX(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { + ColliderCylinder* cylinder = (ColliderCylinder*)col; if ((cylinder->info.bumperFlags & BUMP_DRAW_HITMARK) && (cylinder->info.acHitInfo != NULL) && !(cylinder->info.acHitInfo->toucherFlags & TOUCH_DREW_HITMARK)) { @@ -2848,8 +2859,8 @@ void CollisionCheck_SetCylHitFX(struct PlayState* play, CollisionCheckContext* c /** * Sets a ColliderTris's hit effects */ -void CollisionCheck_SetTrisHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { - ColliderTris* tris = (ColliderTris*)collider; +void CollisionCheck_SetTrisHitFX(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { + ColliderTris* tris = (ColliderTris*)col; ColliderTrisElement* element; for (element = tris->elements; element < &tris->elements[tris->count]; element++) { @@ -2869,8 +2880,8 @@ void CollisionCheck_SetTrisHitFX(struct PlayState* play, CollisionCheckContext* /** * Sets a ColliderQuad's hit effects */ -void CollisionCheck_SetQuadHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { - ColliderQuad* quad = (ColliderQuad*)collider; +void CollisionCheck_SetQuadHitFX(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { + ColliderQuad* quad = (ColliderQuad*)col; if ((quad->info.bumperFlags & BUMP_DRAW_HITMARK) && (quad->info.acHitInfo != NULL) && !(quad->info.acHitInfo->toucherFlags & TOUCH_DREW_HITMARK)) { @@ -2885,8 +2896,8 @@ void CollisionCheck_SetQuadHitFX(struct PlayState* play, CollisionCheckContext* /** * Sets a ColliderSphere's hit effects */ -void CollisionCheck_SetSphereHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { - ColliderSphere* sphere = (ColliderSphere*)collider; +void CollisionCheck_SetSphereHitFX(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { + ColliderSphere* sphere = (ColliderSphere*)col; if ((sphere->info.bumperFlags & BUMP_DRAW_HITMARK) && (sphere->info.acHitInfo != NULL) && !(sphere->info.acHitInfo->toucherFlags & TOUCH_DREW_HITMARK)) { @@ -2899,60 +2910,93 @@ void CollisionCheck_SetSphereHitFX(struct PlayState* play, CollisionCheckContext } } -ColChkApplyFunc sColChkApplyFuncs[] = { - CollisionCheck_SetJntSphHitFX, CollisionCheck_SetCylHitFX, CollisionCheck_SetTrisHitFX, - CollisionCheck_SetQuadHitFX, CollisionCheck_SetSphereHitFX, +ColChkApplyFunc sColChkApplyFuncs[COLSHAPE_MAX] = { + CollisionCheck_SetJntSphHitFX, // COLSHAPE_JNTSPH + CollisionCheck_SetCylHitFX, // COLSHAPE_CYLINDER + CollisionCheck_SetTrisHitFX, // COLSHAPE_TRIS + CollisionCheck_SetQuadHitFX, // COLSHAPE_QUAD + CollisionCheck_SetSphereHitFX, // COLSHAPE_SPHERE }; /** * Handles hit effects for each AC collider that had an AC collision. Spawns hitmarks and plays sound effects. */ -void CollisionCheck_SetHitEffects(struct PlayState* play, CollisionCheckContext* colCtxt) { - Collider** col; +void CollisionCheck_SetHitEffects(struct PlayState* play, CollisionCheckContext* colChkCtx) { + Collider** acColP; - for (col = &colCtxt->colAC[0]; col < &colCtxt->colAC[colCtxt->colACCount]; col++) { - Collider* colAC = *col; + for (acColP = &colChkCtx->colAC[0]; acColP < &colChkCtx->colAC[colChkCtx->colACCount]; acColP++) { + Collider* acCol = *acColP; - if ((colAC != NULL) && (colAC->acFlags & AC_ON)) { - if ((colAC->actor != NULL) && (colAC->actor->update == NULL)) { + if ((acCol != NULL) && (acCol->acFlags & AC_ON)) { + if ((acCol->actor != NULL) && (acCol->actor->update == NULL)) { continue; } - sColChkApplyFuncs[colAC->shape](play, colCtxt, colAC); + sColChkApplyFuncs[acCol->shape](play, colChkCtx, acCol); } } } ColChkVsFunc sACVsFuncs[COLSHAPE_MAX][COLSHAPE_MAX] = { - { CollisionCheck_AC_JntSphVsJntSph, CollisionCheck_AC_JntSphVsCyl, CollisionCheck_AC_JntSphVsTris, - CollisionCheck_AC_JntSphVsQuad, CollisionCheck_AC_JntSphVsSphere }, - { CollisionCheck_AC_CylVsJntSph, CollisionCheck_AC_CylVsCyl, CollisionCheck_AC_CylVsTris, - CollisionCheck_AC_CylVsQuad, CollisionCheck_AC_CylVsSphere }, - { CollisionCheck_AC_TrisVsJntSph, CollisionCheck_AC_TrisVsCyl, CollisionCheck_AC_TrisVsTris, - CollisionCheck_AC_TrisVsQuad, CollisionCheck_AC_TrisVsSphere }, - { CollisionCheck_AC_QuadVsJntSph, CollisionCheck_AC_QuadVsCyl, CollisionCheck_AC_QuadVsTris, - CollisionCheck_AC_QuadVsQuad, CollisionCheck_AC_QuadVsSphere }, - { CollisionCheck_AC_SphereVsJntSph, CollisionCheck_AC_SphereVsCylinder, CollisionCheck_AC_SphereVsTris, - CollisionCheck_AC_SphereVsQuad, CollisionCheck_AC_SphereVsSphere }, + // COLSHAPE_JNTSPH + { + CollisionCheck_AC_JntSphVsJntSph, // COLSHAPE_JNTSPH + CollisionCheck_AC_JntSphVsCyl, // COLSHAPE_CYLINDER + CollisionCheck_AC_JntSphVsTris, // COLSHAPE_TRIS + CollisionCheck_AC_JntSphVsQuad, // COLSHAPE_QUAD + CollisionCheck_AC_JntSphVsSphere // COLSHAPE_SPHERE + }, + // COLSHAPE_CYLINDER + { + CollisionCheck_AC_CylVsJntSph, // COLSHAPE_JNTSPH + CollisionCheck_AC_CylVsCyl, // COLSHAPE_CYLINDER + CollisionCheck_AC_CylVsTris, // COLSHAPE_TRIS + CollisionCheck_AC_CylVsQuad, // COLSHAPE_QUAD + CollisionCheck_AC_CylVsSphere // COLSHAPE_SPHERE + }, + // COLSHAPE_TRIS + { + CollisionCheck_AC_TrisVsJntSph, // COLSHAPE_JNTSPH + CollisionCheck_AC_TrisVsCyl, // COLSHAPE_CYLINDER + CollisionCheck_AC_TrisVsTris, // COLSHAPE_TRIS + CollisionCheck_AC_TrisVsQuad, // COLSHAPE_QUAD + CollisionCheck_AC_TrisVsSphere // COLSHAPE_SPHERE + }, + // COLSHAPE_QUAD + { + CollisionCheck_AC_QuadVsJntSph, // COLSHAPE_JNTSPH + CollisionCheck_AC_QuadVsCyl, // COLSHAPE_CYLINDER + CollisionCheck_AC_QuadVsTris, // COLSHAPE_TRIS + CollisionCheck_AC_QuadVsQuad, // COLSHAPE_QUAD + CollisionCheck_AC_QuadVsSphere // COLSHAPE_SPHERE + }, + // COLSHAPE_SPHERE + { + CollisionCheck_AC_SphereVsJntSph, // COLSHAPE_JNTSPH + CollisionCheck_AC_SphereVsCylinder, // COLSHAPE_CYLINDER + CollisionCheck_AC_SphereVsTris, // COLSHAPE_TRIS + CollisionCheck_AC_SphereVsQuad, // COLSHAPE_QUAD + CollisionCheck_AC_SphereVsSphere // COLSHAPE_SPHERE + }, }; /** * Iterates through all AC colliders, performing AC collisions with the AT collider. */ -void CollisionCheck_AC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT) { - Collider** col; +void CollisionCheck_AC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol) { + Collider** acColP; - for (col = &colCtxt->colAC[0]; col < &colCtxt->colAC[colCtxt->colACCount]; col++) { - Collider* colAC = *col; + for (acColP = &colChkCtx->colAC[0]; acColP < &colChkCtx->colAC[colChkCtx->colACCount]; acColP++) { + Collider* acCol = *acColP; - if ((colAC != NULL) && (colAC->acFlags & AC_ON)) { - if ((colAC->actor != NULL) && (colAC->actor->update == NULL)) { + if ((acCol != NULL) && (acCol->acFlags & AC_ON)) { + if ((acCol->actor != NULL) && (acCol->actor->update == NULL)) { continue; } - if ((colAC->acFlags & colAT->atFlags & AC_TYPE_ALL) && (colAT != colAC)) { - if (!(colAT->atFlags & AT_SELF) && (colAT->actor != NULL) && (colAC->actor == colAT->actor)) { + if ((acCol->acFlags & atCol->atFlags & AC_TYPE_ALL) && (atCol != acCol)) { + if (!(atCol->atFlags & AT_SELF) && (atCol->actor != NULL) && (acCol->actor == atCol->actor)) { continue; } - sACVsFuncs[colAT->shape][colAC->shape](play, colCtxt, colAT, colAC); + sACVsFuncs[atCol->shape][acCol->shape](play, colChkCtx, atCol, acCol); } } } @@ -2964,25 +3008,25 @@ void CollisionCheck_AC(struct PlayState* play, CollisionCheckContext* colCtxt, C * successful collision. To collide, an AT collider must share a type (AC_TYPE_PLAYER, AC_TYPE_ENEMY, or AC_TYPE_OTHER) * with the AC collider and the toucher and bumper elements that overlapped must share a dmgFlag. */ -void CollisionCheck_AT(struct PlayState* play, CollisionCheckContext* colCtxt) { - Collider** col; +void CollisionCheck_AT(struct PlayState* play, CollisionCheckContext* colChkCtx) { + Collider** acColP; - if ((colCtxt->colATCount == 0) || (colCtxt->colACCount == 0)) { + if ((colChkCtx->colATCount == 0) || (colChkCtx->colACCount == 0)) { return; } - for (col = &colCtxt->colAT[0]; col < &colCtxt->colAT[colCtxt->colATCount]; col++) { - Collider* colAC = *col; + for (acColP = &colChkCtx->colAT[0]; acColP < &colChkCtx->colAT[colChkCtx->colATCount]; acColP++) { + Collider* acCol = *acColP; - if ((colAC != NULL) && (colAC->atFlags & AT_ON)) { - if ((colAC->actor != NULL) && (colAC->actor->update == NULL)) { + if ((acCol != NULL) && (acCol->atFlags & AT_ON)) { + if ((acCol->actor != NULL) && (acCol->actor->update == NULL)) { continue; } - CollisionCheck_AC(play, colCtxt, colAC); + CollisionCheck_AC(play, colChkCtx, acCol); } } - CollisionCheck_SetHitEffects(play, colCtxt); + CollisionCheck_SetHitEffects(play, colChkCtx); } /** @@ -3003,8 +3047,8 @@ s32 CollisionCheck_GetMassType(u8 mass) { * Sets OC collision flags for OC collider overlaps. If both colliders are attached to actors and can push, * also performs an elastic collision where both colliders are moved apart in proportion to their masses. */ -void CollisionCheck_SetOCvsOC(struct PlayState* play, Collider* left, ColliderInfo* leftInfo, Vec3f* leftPos, - Collider* right, ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlapSize) { +void CollisionCheck_SetOCvsOC(struct PlayState* play, Collider* leftCol, ColliderInfo* leftInfo, Vec3f* leftPos, + Collider* rightCol, ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlapSize) { f32 pad; f32 leftDispRatio; f32 rightDispRatio; @@ -3015,27 +3059,27 @@ void CollisionCheck_SetOCvsOC(struct PlayState* play, Collider* left, ColliderIn f32 inverseTotalMass; f32 xDelta; f32 zDelta; - Actor* leftActor = left->actor; - Actor* rightActor = right->actor; + Actor* leftActor = leftCol->actor; + Actor* rightActor = rightCol->actor; s32 leftMassType; s32 rightMassType; - left->ocFlags1 |= OC1_HIT; - left->oc = rightActor; + leftCol->ocFlags1 |= OC1_HIT; + leftCol->oc = rightActor; leftInfo->ocElemFlags |= OCELEM_HIT; - if (right->ocFlags2 & OC2_TYPE_PLAYER) { - left->ocFlags2 |= OC2_HIT_PLAYER; + if (rightCol->ocFlags2 & OC2_TYPE_PLAYER) { + leftCol->ocFlags2 |= OC2_HIT_PLAYER; } - right->ocFlags1 |= OC1_HIT; - right->oc = leftActor; + rightCol->ocFlags1 |= OC1_HIT; + rightCol->oc = leftActor; rightInfo->ocElemFlags |= OCELEM_HIT; - if (left->ocFlags2 & OC2_TYPE_PLAYER) { - right->ocFlags2 |= OC2_HIT_PLAYER; + if (leftCol->ocFlags2 & OC2_TYPE_PLAYER) { + rightCol->ocFlags2 |= OC2_HIT_PLAYER; } - if ((leftActor == NULL) || (rightActor == NULL) || (left->ocFlags1 & OC1_NO_PUSH) || - (right->ocFlags1 & OC1_NO_PUSH)) { + if ((leftActor == NULL) || (rightActor == NULL) || (leftCol->ocFlags1 & OC1_NO_PUSH) || + (rightCol->ocFlags1 & OC1_NO_PUSH)) { return; } @@ -3102,10 +3146,10 @@ void CollisionCheck_SetOCvsOC(struct PlayState* play, Collider* left, ColliderIn /** * OC overlap check for two JntSphs */ -void CollisionCheck_OC_JntSphVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, - Collider* r) { - ColliderJntSph* left = (ColliderJntSph*)l; - ColliderJntSph* right = (ColliderJntSph*)r; +void CollisionCheck_OC_JntSphVsJntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* leftCol, + Collider* rightCol) { + ColliderJntSph* left = (ColliderJntSph*)leftCol; + ColliderJntSph* right = (ColliderJntSph*)rightCol; ColliderJntSphElement* leftElem; ColliderJntSphElement* rightElem; f32 overlapSize; @@ -3121,8 +3165,7 @@ void CollisionCheck_OC_JntSphVsJntSph(struct PlayState* play, CollisionCheckCont if (!(rightElem->info.ocElemFlags & OCELEM_ON)) { continue; } - if (Math3D_SphVsSphOverlap(&leftElem->dim.worldSphere, &rightElem->dim.worldSphere, &overlapSize) != - 0) { + if (Math3D_SphVsSphOverlap(&leftElem->dim.worldSphere, &rightElem->dim.worldSphere, &overlapSize)) { Vec3f leftPos; Vec3f rightPos; @@ -3139,9 +3182,10 @@ void CollisionCheck_OC_JntSphVsJntSph(struct PlayState* play, CollisionCheckCont /** * OC overlap check for a JntSph and Cylinder */ -void CollisionCheck_OC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { - ColliderJntSph* left = (ColliderJntSph*)l; - ColliderCylinder* right = (ColliderCylinder*)r; +void CollisionCheck_OC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* leftCol, + Collider* rightCol) { + ColliderJntSph* left = (ColliderJntSph*)leftCol; + ColliderCylinder* right = (ColliderCylinder*)rightCol; ColliderJntSphElement* leftElem; f32 overlapSize; @@ -3152,7 +3196,7 @@ void CollisionCheck_OC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext if (!(leftElem->info.ocElemFlags & OCELEM_ON)) { continue; } - if (Math3D_SphVsCylOverlap(&leftElem->dim.worldSphere, &right->dim, &overlapSize) != 0) { + if (Math3D_SphVsCylOverlap(&leftElem->dim.worldSphere, &right->dim, &overlapSize)) { Vec3f leftPos; Vec3f rightPos; @@ -3168,10 +3212,10 @@ void CollisionCheck_OC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext /** * OC overlap check for a JntSph and Sphere */ -void CollisionCheck_OC_JntSphVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, - Collider* r) { - ColliderJntSph* left = (ColliderJntSph*)l; - ColliderSphere* right = (ColliderSphere*)r; +void CollisionCheck_OC_JntSphVsSphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* leftCol, + Collider* rightCol) { + ColliderJntSph* left = (ColliderJntSph*)leftCol; + ColliderSphere* right = (ColliderSphere*)rightCol; ColliderJntSphElement* leftElem; f32 overlapSize; @@ -3182,7 +3226,7 @@ void CollisionCheck_OC_JntSphVsSphere(struct PlayState* play, CollisionCheckCont if (!(leftElem->info.ocElemFlags & OCELEM_ON)) { continue; } - if (Math3D_SphVsSphOverlap(&leftElem->dim.worldSphere, &right->dim.worldSphere, &overlapSize) != 0) { + if (Math3D_SphVsSphOverlap(&leftElem->dim.worldSphere, &right->dim.worldSphere, &overlapSize)) { Vec3f leftPos; Vec3f rightPos; @@ -3198,21 +3242,23 @@ void CollisionCheck_OC_JntSphVsSphere(struct PlayState* play, CollisionCheckCont /** * OC overlap check for a Cylinder and JntSph */ -void CollisionCheck_OC_CylVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { - CollisionCheck_OC_JntSphVsCyl(play, colCtxt, r, l); +void CollisionCheck_OC_CylVsJntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* leftCol, + Collider* rightCol) { + CollisionCheck_OC_JntSphVsCyl(play, colChkCtx, rightCol, leftCol); } /** * OC overlap check for two Cylinders */ -void CollisionCheck_OC_CylVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { - ColliderCylinder* left = (ColliderCylinder*)l; - ColliderCylinder* right = (ColliderCylinder*)r; +void CollisionCheck_OC_CylVsCyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* leftCol, + Collider* rightCol) { + ColliderCylinder* left = (ColliderCylinder*)leftCol; + ColliderCylinder* right = (ColliderCylinder*)rightCol; f32 overlapSize; if ((left->base.ocFlags1 & OCELEM_ON) && (right->base.ocFlags1 & OCELEM_ON) && (left->info.ocElemFlags & OCELEM_ON) && (right->info.ocElemFlags & OCELEM_ON)) { - if (Math3D_CylVsCylOverlap(&left->dim, &right->dim, &overlapSize) != 0) { + if (Math3D_CylVsCylOverlap(&left->dim, &right->dim, &overlapSize)) { Vec3f leftPos; Vec3f rightPos; @@ -3227,14 +3273,15 @@ void CollisionCheck_OC_CylVsCyl(struct PlayState* play, CollisionCheckContext* c /** * OC overlap check for a Cylinder and Sphere */ -void CollisionCheck_OC_CylVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { - ColliderCylinder* left = (ColliderCylinder*)l; - ColliderSphere* right = (ColliderSphere*)r; +void CollisionCheck_OC_CylVsSphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* leftCol, + Collider* rightCol) { + ColliderCylinder* left = (ColliderCylinder*)leftCol; + ColliderSphere* right = (ColliderSphere*)rightCol; f32 overlapSize; if ((left->base.ocFlags1 & OCELEM_ON) && (left->info.ocElemFlags & OCELEM_ON) && (right->base.ocFlags1 & OCELEM_ON) && (right->info.ocElemFlags & OCELEM_ON)) { - if (Math3D_SphVsCylOverlap(&right->dim.worldSphere, &left->dim, &overlapSize) != 0) { + if (Math3D_SphVsCylOverlap(&right->dim.worldSphere, &left->dim, &overlapSize)) { Vec3f leftPos; Vec3f rightPos; @@ -3249,30 +3296,31 @@ void CollisionCheck_OC_CylVsSphere(struct PlayState* play, CollisionCheckContext /** * OC overlap check for a Sphere and JntSph */ -void CollisionCheck_OC_SphereVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, - Collider* r) { - CollisionCheck_OC_JntSphVsSphere(play, colCtxt, r, l); +void CollisionCheck_OC_SphereVsJntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* leftCol, + Collider* rightCol) { + CollisionCheck_OC_JntSphVsSphere(play, colChkCtx, rightCol, leftCol); } /** * OC overlap check for a Sphere and Cylinder */ -void CollisionCheck_OC_SphereVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) { - CollisionCheck_OC_CylVsSphere(play, colCtxt, r, l); +void CollisionCheck_OC_SphereVsCyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* leftCol, + Collider* rightCol) { + CollisionCheck_OC_CylVsSphere(play, colChkCtx, rightCol, leftCol); } /** * OC overlap check for two Spheres */ -void CollisionCheck_OC_SphereVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, - Collider* r) { - ColliderSphere* left = (ColliderSphere*)l; - ColliderSphere* right = (ColliderSphere*)r; +void CollisionCheck_OC_SphereVsSphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* leftCol, + Collider* rightCol) { + ColliderSphere* left = (ColliderSphere*)leftCol; + ColliderSphere* right = (ColliderSphere*)rightCol; f32 overlapSize; if ((left->base.ocFlags1 & OCELEM_ON) && (left->info.ocElemFlags & OCELEM_ON) && (right->base.ocFlags1 & OCELEM_ON) && (right->info.ocElemFlags & OCELEM_ON)) { - if (Math3D_SphVsSphOverlap(&left->dim.worldSphere, &right->dim.worldSphere, &overlapSize) != 0) { + if (Math3D_SphVsSphOverlap(&left->dim.worldSphere, &right->dim.worldSphere, &overlapSize)) { Vec3f leftPos; Vec3f rightPos; @@ -3287,8 +3335,8 @@ void CollisionCheck_OC_SphereVsSphere(struct PlayState* play, CollisionCheckCont /** * Skip any OC colliders that are off */ -s32 CollisionCheck_SkipOC(Collider* collider) { - if (!(collider->ocFlags1 & OCELEM_ON)) { +s32 CollisionCheck_SkipOC(Collider* col) { + if (!(col->ocFlags1 & OCELEM_ON)) { return 1; } return 0; @@ -3300,24 +3348,60 @@ s32 CollisionCheck_SkipOC(Collider* collider) { * Second, OC2_UNK1 and OC2_UNK2 can't collide with each other (has something to do with horses?) * Third, the colliders can't collide if they belong to the same actor */ -s32 CollisionCheck_Incompatible(Collider* left, Collider* right) { - if (!(left->ocFlags1 & right->ocFlags2 & OC1_TYPE_ALL) || !(left->ocFlags2 & right->ocFlags1 & OC1_TYPE_ALL) || - ((left->ocFlags2 & OC2_UNK1) && (right->ocFlags2 & OC2_UNK2)) || - ((right->ocFlags2 & OC2_UNK1) && (left->ocFlags2 & OC2_UNK2))) { +s32 CollisionCheck_Incompatible(Collider* leftCol, Collider* rightCol) { + if (!(leftCol->ocFlags1 & rightCol->ocFlags2 & OC1_TYPE_ALL) || + !(leftCol->ocFlags2 & rightCol->ocFlags1 & OC1_TYPE_ALL) || + ((leftCol->ocFlags2 & OC2_UNK1) && (rightCol->ocFlags2 & OC2_UNK2)) || + ((rightCol->ocFlags2 & OC2_UNK1) && (leftCol->ocFlags2 & OC2_UNK2))) { return 1; } - if (left->actor == right->actor) { + if (leftCol->actor == rightCol->actor) { return 1; } return 0; } ColChkVsFunc sOCVsFuncs[COLSHAPE_MAX][COLSHAPE_MAX] = { - { CollisionCheck_OC_JntSphVsJntSph, CollisionCheck_OC_JntSphVsCyl, NULL, NULL, CollisionCheck_OC_JntSphVsSphere }, - { CollisionCheck_OC_CylVsJntSph, CollisionCheck_OC_CylVsCyl, NULL, NULL, CollisionCheck_OC_CylVsSphere }, - { NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL }, - { CollisionCheck_OC_SphereVsJntSph, CollisionCheck_OC_SphereVsCyl, NULL, NULL, CollisionCheck_OC_SphereVsSphere }, + // COLSHAPE_JNTSPH + { + CollisionCheck_OC_JntSphVsJntSph, // COLSHAPE_JNTSPH + CollisionCheck_OC_JntSphVsCyl, // COLSHAPE_CYLINDER + NULL, // COLSHAPE_TRIS + NULL, // COLSHAPE_QUAD + CollisionCheck_OC_JntSphVsSphere // COLSHAPE_SPHERE + }, + // COLSHAPE_CYLINDER + { + CollisionCheck_OC_CylVsJntSph, // COLSHAPE_JNTSPH + CollisionCheck_OC_CylVsCyl, // COLSHAPE_CYLINDER + NULL, // COLSHAPE_TRIS + NULL, // COLSHAPE_QUAD + CollisionCheck_OC_CylVsSphere // COLSHAPE_SPHERE + }, + // COLSHAPE_TRIS + { + NULL, // COLSHAPE_JNTSPH + NULL, // COLSHAPE_CYLINDER + NULL, // COLSHAPE_TRIS + NULL, // COLSHAPE_QUAD + NULL // COLSHAPE_SPHERE + }, + // COLSHAPE_QUAD + { + NULL, // COLSHAPE_JNTSPH + NULL, // COLSHAPE_CYLINDER + NULL, // COLSHAPE_TRIS + NULL, // COLSHAPE_QUAD + NULL // COLSHAPE_SPHERE + }, + // COLSHAPE_SPHERE + { + CollisionCheck_OC_SphereVsJntSph, // COLSHAPE_JNTSPH + CollisionCheck_OC_SphereVsCyl, // COLSHAPE_CYLINDER + NULL, // COLSHAPE_TRIS + NULL, // COLSHAPE_QUAD + CollisionCheck_OC_SphereVsSphere // COLSHAPE_SPHERE + }, }; /** @@ -3327,24 +3411,25 @@ ColChkVsFunc sOCVsFuncs[COLSHAPE_MAX][COLSHAPE_MAX] = { * colliders can collide, and each collider must have the OC flag corresponding to the other's OC type. Additionally, * OC2_UNK1 cannot collide with OC2_UNK2, nor can two colliders that share an actor. */ -void CollisionCheck_OC(struct PlayState* play, CollisionCheckContext* colCtxt) { - Collider** left; - Collider** right; +void CollisionCheck_OC(struct PlayState* play, CollisionCheckContext* colChkCtx) { + Collider** leftColP; + Collider** rightColP; ColChkVsFunc vsFunc; - for (left = colCtxt->colOC; left < colCtxt->colOC + colCtxt->colOCCount; left++) { - if ((*left == NULL) || CollisionCheck_SkipOC(*left)) { + for (leftColP = colChkCtx->colOC; leftColP < colChkCtx->colOC + colChkCtx->colOCCount; leftColP++) { + if ((*leftColP == NULL) || CollisionCheck_SkipOC(*leftColP)) { continue; } - for (right = left + 1; right < colCtxt->colOC + colCtxt->colOCCount; right++) { - if ((*right == NULL) || CollisionCheck_SkipOC(*right) || CollisionCheck_Incompatible(*left, *right)) { + for (rightColP = leftColP + 1; rightColP < colChkCtx->colOC + colChkCtx->colOCCount; rightColP++) { + if ((*rightColP == NULL) || CollisionCheck_SkipOC(*rightColP) || + CollisionCheck_Incompatible(*leftColP, *rightColP)) { continue; } - vsFunc = sOCVsFuncs[(*left)->shape][(*right)->shape]; + vsFunc = sOCVsFuncs[(*leftColP)->shape][(*rightColP)->shape]; if (vsFunc == NULL) { continue; } - vsFunc(play, colCtxt, *left, *right); + vsFunc(play, colChkCtx, *leftColP, *rightColP); } } } @@ -3414,30 +3499,30 @@ void CollisionCheck_SetInfoGetDamageTable(CollisionCheckInfo* info, s32 index, C /** * Apply AC damage effect */ -void CollisionCheck_ApplyDamage(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, +void CollisionCheck_ApplyDamage(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, ColliderInfo* info) { f32 damage; f32 finalDamage = 0.0f; s32 pad; - Collider* at; + Collider* atCol; ColliderInfo* atInfo; s32 pad1; u32 effect; - if ((collider->actor == NULL) || !(collider->acFlags & AC_HIT)) { + if ((col->actor == NULL) || !(col->acFlags & AC_HIT)) { return; } if (!(info->bumperFlags & BUMP_HIT) || (info->bumperFlags & BUMP_NO_DAMAGE)) { return; } - at = info->acHit; + atCol = info->acHit; atInfo = info->acHitInfo; - if ((at != NULL) && (atInfo != NULL) && (collider != NULL) && (info != NULL)) { - damage = CollisionCheck_GetDamageAndEffectOnBumper(at, atInfo, collider, info, &effect); + if ((atCol != NULL) && (atInfo != NULL) && (col != NULL) && (info != NULL)) { + damage = CollisionCheck_GetDamageAndEffectOnBumper(atCol, atInfo, col, info, &effect); - if (CollisionCheck_GetToucherDamage(at, atInfo, collider, info) != 0) { + if (CollisionCheck_GetToucherDamage(atCol, atInfo, col, info) != 0) { if (damage < 1.0f) { finalDamage = 0.0f; if (effect == 0) { @@ -3450,13 +3535,12 @@ void CollisionCheck_ApplyDamage(struct PlayState* play, CollisionCheckContext* c } } } - if (collider->actor->colChkInfo.damageTable != NULL) { - collider->actor->colChkInfo.damageEffect = effect; + if (col->actor->colChkInfo.damageTable != NULL) { + col->actor->colChkInfo.damageEffect = effect; } - if (!(collider->acFlags & AC_HARD) || - ((collider->acFlags & AC_HARD) && (atInfo->toucher.dmgFlags == 0x20000000))) { - if (collider->actor->colChkInfo.damage < finalDamage) { - collider->actor->colChkInfo.damage = finalDamage; + if (!(col->acFlags & AC_HARD) || ((col->acFlags & AC_HARD) && (atInfo->toucher.dmgFlags == 0x20000000))) { + if (col->actor->colChkInfo.damage < finalDamage) { + col->actor->colChkInfo.damage = finalDamage; } } } @@ -3465,13 +3549,13 @@ void CollisionCheck_ApplyDamage(struct PlayState* play, CollisionCheckContext* c /** * Apply ColliderJntSph AC damage effect */ -void CollisionCheck_ApplyDamageJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { - ColliderJntSph* jntSph = (ColliderJntSph*)collider; +void CollisionCheck_ApplyDamageJntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { + ColliderJntSph* jntSph = (ColliderJntSph*)col; s32 i; if ((jntSph->count > 0) && (jntSph->elements != NULL)) { for (i = 0; i < jntSph->count; i++) { - CollisionCheck_ApplyDamage(play, colCtxt, &jntSph->base, &jntSph->elements[i].info); + CollisionCheck_ApplyDamage(play, colChkCtx, &jntSph->base, &jntSph->elements[i].info); } } } @@ -3479,58 +3563,61 @@ void CollisionCheck_ApplyDamageJntSph(struct PlayState* play, CollisionCheckCont /** * Apply ColliderCylinder AC damage effect */ -void CollisionCheck_ApplyDamageCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { - ColliderCylinder* cylinder = (ColliderCylinder*)collider; +void CollisionCheck_ApplyDamageCyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { + ColliderCylinder* cylinder = (ColliderCylinder*)col; - CollisionCheck_ApplyDamage(play, colCtxt, &cylinder->base, &cylinder->info); + CollisionCheck_ApplyDamage(play, colChkCtx, &cylinder->base, &cylinder->info); } /** * Apply ColliderTris AC damage effect */ -void CollisionCheck_ApplyDamageTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { - ColliderTris* tris = (ColliderTris*)collider; +void CollisionCheck_ApplyDamageTris(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { + ColliderTris* tris = (ColliderTris*)col; s32 i; // unlike sphere groups above, tri groups are not guarded against // tris->elements being NULL for (i = 0; i < tris->count; i++) { - CollisionCheck_ApplyDamage(play, colCtxt, &tris->base, &tris->elements[i].info); + CollisionCheck_ApplyDamage(play, colChkCtx, &tris->base, &tris->elements[i].info); } } /** * Apply ColliderQuad AC damage effect */ -void CollisionCheck_ApplyDamageQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { - ColliderQuad* quad = (ColliderQuad*)collider; +void CollisionCheck_ApplyDamageQuad(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { + ColliderQuad* quad = (ColliderQuad*)col; - CollisionCheck_ApplyDamage(play, colCtxt, &quad->base, &quad->info); + CollisionCheck_ApplyDamage(play, colChkCtx, &quad->base, &quad->info); } /** * Apply ColliderSphere AC damage effect */ -void CollisionCheck_ApplyDamageSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) { - ColliderSphere* sphere = (ColliderSphere*)collider; +void CollisionCheck_ApplyDamageSphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { + ColliderSphere* sphere = (ColliderSphere*)col; - CollisionCheck_ApplyDamage(play, colCtxt, &sphere->base, &sphere->info); + CollisionCheck_ApplyDamage(play, colChkCtx, &sphere->base, &sphere->info); } -ColChkApplyFunc sApplyDamageFuncs[] = { - CollisionCheck_ApplyDamageJntSph, CollisionCheck_ApplyDamageCyl, CollisionCheck_ApplyDamageTris, - CollisionCheck_ApplyDamageQuad, CollisionCheck_ApplyDamageSphere, +ColChkApplyFunc sApplyDamageFuncs[COLSHAPE_MAX] = { + CollisionCheck_ApplyDamageJntSph, // COLSHAPE_JNTSPH + CollisionCheck_ApplyDamageCyl, // COLSHAPE_CYLINDER + CollisionCheck_ApplyDamageTris, // COLSHAPE_TRIS + CollisionCheck_ApplyDamageQuad, // COLSHAPE_QUAD + CollisionCheck_ApplyDamageSphere, // COLSHAPE_SPHERE }; /** * For all AC colliders, sets any damage effects from collisions with AT colliders to their corresponding actor's * CollisionCheckInfo. */ -void CollisionCheck_Damage(struct PlayState* play, CollisionCheckContext* colCtxt) { +void CollisionCheck_Damage(struct PlayState* play, CollisionCheckContext* colChkCtx) { s32 i; - for (i = 0; i < colCtxt->colACCount; i++) { - Collider* col = colCtxt->colAC[i]; + for (i = 0; i < colChkCtx->colACCount; i++) { + Collider* col = colChkCtx->colAC[i]; if (col == NULL) { continue; @@ -3538,16 +3625,16 @@ void CollisionCheck_Damage(struct PlayState* play, CollisionCheckContext* colCtx if (col->acFlags & AC_NO_DAMAGE) { continue; } - sApplyDamageFuncs[col->shape](play, colCtxt, col); + sApplyDamageFuncs[col->shape](play, colChkCtx, col); } } /** * Checks if the line segment ab intersects any of the ColliderJntSph's elements */ -s32 CollisionCheck_LineOC_JntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, +s32 CollisionCheck_LineOC_JntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, Vec3f* a, Vec3f* b) { - ColliderJntSph* jntSph = (ColliderJntSph*)collider; + ColliderJntSph* jntSph = (ColliderJntSph*)col; s32 i; for (i = 0; i < jntSph->count; i++) { @@ -3559,53 +3646,57 @@ s32 CollisionCheck_LineOC_JntSph(struct PlayState* play, CollisionCheckContext* D_801EDEB0.a = *a; D_801EDEB0.b = *b; - if (Math3D_LineVsSph(&element->dim.worldSphere, &D_801EDEB0) != 0) { - return 1; + if (Math3D_LineVsSph(&element->dim.worldSphere, &D_801EDEB0)) { + return true; } } - return 0; + return false; } /** * Checks if the line segment ab intersects the ColliderCylinder */ -s32 CollisionCheck_LineOC_Cyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, +s32 CollisionCheck_LineOC_Cyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, Vec3f* a, Vec3f* b) { - ColliderCylinder* cylinder = (ColliderCylinder*)collider; + ColliderCylinder* cylinder = (ColliderCylinder*)col; if (!(cylinder->info.ocElemFlags & OCELEM_ON)) { - return 0; + return false; } - if (Math3D_CylVsLineSeg(&cylinder->dim, a, b, &D_801EDF38, &D_801EDF48) != 0) { - return 1; + if (Math3D_CylVsLineSeg(&cylinder->dim, a, b, &D_801EDF38, &D_801EDF48)) { + return true; } - return 0; + return false; } /** * Checks if the line segment ab intersects the ColliderSphere */ -s32 CollisionCheck_LineOC_Sphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, +s32 CollisionCheck_LineOC_Sphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* col, Vec3f* a, Vec3f* b) { - ColliderSphere* sphere = (ColliderSphere*)collider; + ColliderSphere* sphere = (ColliderSphere*)col; if (!(sphere->info.ocElemFlags & OCELEM_ON)) { - return 0; + return false; } D_801EDFC8.a = *a; D_801EDFC8.b = *b; - if (Math3D_LineVsSph(&sphere->dim.worldSphere, &D_801EDFC8) != 0) { - return 1; + if (Math3D_LineVsSph(&sphere->dim.worldSphere, &D_801EDFC8)) { + return true; } - return 0; + return false; } -ColChkLineFunc sOCLineCheckFuncs[] = { - CollisionCheck_LineOC_JntSph, CollisionCheck_LineOC_Cyl, NULL, NULL, CollisionCheck_LineOC_Sphere, +static ColChkLineFunc sOCLineCheckFuncs[COLSHAPE_MAX] = { + CollisionCheck_LineOC_JntSph, // COLSHAPE_JNTSPH + CollisionCheck_LineOC_Cyl, // COLSHAPE_CYLINDER + NULL, // COLSHAPE_TRIS + NULL, // COLSHAPE_QUAD + CollisionCheck_LineOC_Sphere, // COLSHAPE_SPHERE }; /** @@ -3615,19 +3706,19 @@ ColChkLineFunc sOCLineCheckFuncs[] = { s32 CollisionCheck_LineOC(struct PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, Actor** exclusions, s32 numExclusions) { ColChkLineFunc lineCheck; - Collider** col; + Collider** colP; s32 i; s32 exclude; - s32 result = 0; + s32 result = false; - for (col = colChkCtx->colOC; col < &colChkCtx->colOC[colChkCtx->colOCCount]; col++) { - if (CollisionCheck_SkipOC(*col)) { + for (colP = colChkCtx->colOC; colP < &colChkCtx->colOC[colChkCtx->colOCCount]; colP++) { + if (CollisionCheck_SkipOC(*colP)) { continue; } - exclude = 0; + exclude = false; for (i = 0; i < numExclusions; i++) { - if ((*col)->actor == exclusions[i]) { + if ((*colP)->actor == exclusions[i]) { exclude = 1; break; } @@ -3636,12 +3727,12 @@ s32 CollisionCheck_LineOC(struct PlayState* play, CollisionCheckContext* colChkC continue; } - lineCheck = sOCLineCheckFuncs[(*col)->shape]; + lineCheck = sOCLineCheckFuncs[(*colP)->shape]; if (lineCheck == NULL) { continue; } - result = lineCheck(play, colChkCtx, (*col), a, b); + result = lineCheck(play, colChkCtx, *colP, a, b); if (result) { break; } @@ -3653,17 +3744,17 @@ s32 CollisionCheck_LineOC(struct PlayState* play, CollisionCheckContext* colChkC * Checks if the line segment ab intersects any OC colliders. Returns true if there are any intersections and false * otherwise. */ -s32 CollisionCheck_LineOCCheckAll(struct PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b) { - return CollisionCheck_LineOC(play, colCtxt, a, b, NULL, 0); +s32 CollisionCheck_LineOCCheckAll(struct PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b) { + return CollisionCheck_LineOC(play, colChkCtx, a, b, NULL, 0); } /** * Checks if the line segment ab intersects any OC colliders, excluding those attached to actors on the exclusion list. * Returns true if there are any intersections and false otherwise. */ -s32 CollisionCheck_LineOCCheck(struct PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b, +s32 CollisionCheck_LineOCCheck(struct PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, Actor** exclusions, s32 numExclusions) { - return CollisionCheck_LineOC(play, colCtxt, a, b, exclusions, numExclusions); + return CollisionCheck_LineOC(play, colChkCtx, a, b, exclusions, numExclusions); } /** @@ -4027,21 +4118,21 @@ s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* a return 0; } if ((SQ(actorDotItemXZ) - (4.0f * SQXZ(itemStep) * radSqDiff)) > zero) { - intersect1 = intersect2 = 1; + intersect1 = intersect2 = true; } else { - intersect1 = 1; - intersect2 = 0; + intersect1 = true; + intersect2 = false; } closeDist = sqrtf(SQ(actorDotItemXZ) - (4.0f * SQXZ(itemStep) * radSqDiff)); - if (intersect1 != 0) { + if (intersect1) { frac1 = (closeDist - actorDotItemXZ) / (2.0f * SQXZ(itemStep)); } - if (intersect2 != 0) { + if (intersect2) { frac2 = (-actorDotItemXZ - closeDist) / (2.0f * SQXZ(itemStep)); } } else if (!IS_ZERO(DOTXZ(2.0f * itemStep, actorToItem))) { - intersect1 = 1; - intersect2 = 0; + intersect1 = true; + intersect2 = false; frac1 = -radSqDiff / DOTXZ(2.0f * itemStep, actorToItem); } else { if (radSqDiff <= 0.0f) { @@ -4065,7 +4156,7 @@ s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* a return 0; } - if (intersect2 == 0) { + if (!intersect2) { if ((frac1 < 0.0f) || (1.0f < frac1)) { return 0; } @@ -4077,24 +4168,24 @@ s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* a return 0; } if (test1) { - intersect1 = 0; + intersect1 = false; } if (test2) { - intersect2 = 0; + intersect2 = false; } } - if ((intersect1 != 0) && + if (intersect1 && (((frac1 * itemStep.y + actorToItem.y) < 0.0f) || (height < (frac1 * itemStep.y + actorToItem.y)))) { - intersect1 = 0; + intersect1 = false; } - if ((intersect2 != 0) && + if (intersect2 && (((frac2 * itemStep.y + actorToItem.y) < 0.0f) || (height < (frac2 * itemStep.y + actorToItem.y)))) { - intersect2 = 0; + intersect2 = false; } - if ((intersect1 == 0) && (intersect2 == 0)) { + if (!intersect1 && !intersect2) { return 0; - } else if ((intersect1 != 0) && (intersect2 != 0)) { + } else if (intersect1 && intersect2) { out1->x = frac1 * itemStep.x + actorToItem.x + actorPos->x; out1->y = frac1 * itemStep.y + actorToItem.y + actorPos->y; out1->z = frac1 * itemStep.z + actorToItem.z + actorPos->z; @@ -4102,12 +4193,12 @@ s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* a out2->y = frac2 * itemStep.y + actorToItem.y + actorPos->y; out2->z = frac2 * itemStep.z + actorToItem.z + actorPos->z; return 2; - } else if (intersect1 != 0) { + } else if (intersect1) { out1->x = frac1 * itemStep.x + actorToItem.x + actorPos->x; out1->y = frac1 * itemStep.y + actorToItem.y + actorPos->y; out1->z = frac1 * itemStep.z + actorToItem.z + actorPos->z; return 1; - } else if (intersect2 != 0) { + } else if (intersect2) { out1->x = frac2 * itemStep.x + actorToItem.x + actorPos->x; out1->y = frac2 * itemStep.y + actorToItem.y + actorPos->y; out1->z = frac2 * itemStep.z + actorToItem.z + actorPos->z;