diff --git a/include/functions.h b/include/functions.h index fea1e252dc..52873969c1 100644 --- a/include/functions.h +++ b/include/functions.h @@ -619,8 +619,10 @@ u16 WaterBox_GetBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox); u32 WaterBox_GetLightIndex(CollisionContext* colCtx, WaterBox* waterBox); s32 func_80042708(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* point, Vec3f* closestPoint); s32 func_800427B4(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec3f* pointB, Vec3f* closestPoint); +#if OOT_DEBUG void BgCheck_DrawDynaCollision(PlayState*, CollisionContext*); void BgCheck_DrawStaticCollision(PlayState*, CollisionContext*); +#endif void func_80043334(CollisionContext* colCtx, Actor* actor, s32 bgId); s32 DynaPolyActor_TransformCarriedActor(CollisionContext* colCtx, s32 bgId, Actor* carriedActor); void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 transformFlags); @@ -665,8 +667,10 @@ s32 func_8005B198(void); s16 Camera_SetFinishedFlag(Camera* camera); DamageTable* DamageTable_Get(s32 index); void DamageTable_Clear(DamageTable* table); +#if OOT_DEBUG void Collider_DrawRedPoly(GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC); void Collider_DrawPoly(GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC, u8 r, u8 g, u8 b); +#endif s32 Collider_InitJntSph(PlayState* play, ColliderJntSph* jntSph); s32 Collider_FreeJntSph(PlayState* play, ColliderJntSph* jntSph); s32 Collider_DestroyJntSph(PlayState* play, ColliderJntSph* jntSph); @@ -714,8 +718,10 @@ void CollisionCheck_DestroyContext(PlayState* play, CollisionCheckContext* colCh void CollisionCheck_ClearContext(PlayState* play, CollisionCheckContext* colChkCtx); void CollisionCheck_EnableSAC(PlayState* play, CollisionCheckContext* colChkCtx); void CollisionCheck_DisableSAC(PlayState* play, CollisionCheckContext* colChkCtx); +#if OOT_DEBUG void Collider_Draw(PlayState* play, Collider* col); void CollisionCheck_DrawCollision(PlayState* play, CollisionCheckContext* colChkCtx); +#endif s32 CollisionCheck_SetAT(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider); s32 CollisionCheck_SetAT_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index); s32 CollisionCheck_SetAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider); diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 73793558af..28083a5c26 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -2609,9 +2609,11 @@ void func_800315AC(PlayState* play, ActorContext* actorCtx) { TitleCard_Draw(play, &actorCtx->titleCtx); } +#if OOT_DEBUG if ((HREG(64) != 1) || (HREG(76) != 0)) { CollisionCheck_DrawCollision(play, &play->colChkCtx); } +#endif CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 6563); } diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index e2605d57f8..488d9464f8 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -4409,6 +4409,7 @@ s32 func_800427B4(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec return result; } +#if OOT_DEBUG /** * Draw a list of dyna polys, specified by `ssList` */ @@ -4556,3 +4557,4 @@ void BgCheck_DrawStaticCollision(PlayState* play, CollisionContext* colCtx) { BgCheck_DrawStaticPolyList(play, colCtx, &lookup->ceiling, 255, 0, 0); } } +#endif diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 8d55adbdd3..57510f3c48 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -7,6 +7,7 @@ typedef void (*ColChkApplyFunc)(PlayState*, CollisionCheckContext*, Collider*); typedef void (*ColChkVsFunc)(PlayState*, CollisionCheckContext*, Collider*, Collider*); typedef s32 (*ColChkLineFunc)(PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); +#if OOT_DEBUG /** * Draws a red triangle with vertices vA, vB, and vC. */ @@ -69,6 +70,7 @@ void Collider_DrawPoly(GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC, CLOSE_DISPS(gfxCtx, "../z_collision_check.c", 757); } +#endif s32 Collider_InitBase(PlayState* play, Collider* col) { static Collider init = { @@ -1000,9 +1002,12 @@ s32 Collider_ResetLineOC(PlayState* play, OcLine* line) { void CollisionCheck_InitContext(PlayState* play, CollisionCheckContext* colChkCtx) { colChkCtx->sacFlags = 0; CollisionCheck_ClearContext(play, colChkCtx); + +#if OOT_DEBUG AREG(21) = true; AREG(22) = true; AREG(23) = true; +#endif } void CollisionCheck_DestroyContext(PlayState* play, CollisionCheckContext* colChkCtx) { @@ -1052,6 +1057,7 @@ void CollisionCheck_DisableSAC(PlayState* play, CollisionCheckContext* colChkCtx colChkCtx->sacFlags &= ~SAC_ENABLE; } +#if OOT_DEBUG /** * Draws a collider of any shape. * Math3D_DrawSphere and Math3D_DrawCylinder are noops, so JntSph and Cylinder are not drawn. @@ -1130,6 +1136,7 @@ void CollisionCheck_DrawCollision(PlayState* play, CollisionCheckContext* colChk } } } +#endif static ColChkResetFunc sATResetFuncs[] = { Collider_ResetJntSphAT, @@ -2153,8 +2160,6 @@ void CollisionCheck_ATTrisVsACCyl(PlayState* play, CollisionCheckContext* colChk ColliderTris* atTris = (ColliderTris*)atCol; ColliderTrisElement* atTrisElem; ColliderCylinder* acCyl = (ColliderCylinder*)acCol; - Vec3f atPos; - Vec3f acPos; if (acCyl->dim.radius > 0 && acCyl->dim.height > 0 && atTris->count > 0 && atTris->elements != NULL) { if (CollisionCheck_SkipElementBump(&acCyl->elem) == true) { @@ -2169,6 +2174,9 @@ void CollisionCheck_ATTrisVsACCyl(PlayState* play, CollisionCheckContext* colChk } if (Math3D_CylTriVsIntersect(&acCyl->dim, &atTrisElem->dim, &hitPos) == true) { + Vec3f atPos; + Vec3f acPos; + atPos.x = (atTrisElem->dim.vtx[0].x + atTrisElem->dim.vtx[1].x + atTrisElem->dim.vtx[2].x) * (1.0f / 3); atPos.y = (atTrisElem->dim.vtx[0].y + atTrisElem->dim.vtx[1].y + atTrisElem->dim.vtx[2].y) * (1.0f / 3); atPos.z = (atTrisElem->dim.vtx[0].z + atTrisElem->dim.vtx[1].z + atTrisElem->dim.vtx[2].z) * (1.0f / 3); @@ -2512,11 +2520,12 @@ void CollisionCheck_ATQuadVsACQuad(PlayState* play, CollisionCheckContext* colCh void CollisionCheck_SetJntSphHitFX(PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { ColliderJntSph* jntSph = (ColliderJntSph*)col; ColliderJntSphElement* jntSphElem; - Vec3f hitPos; for (jntSphElem = jntSph->elements; jntSphElem < jntSph->elements + jntSph->count; jntSphElem++) { if ((jntSphElem->base.bumperFlags & BUMP_DRAW_HITMARK) && (jntSphElem->base.acHitElem != NULL) && !(jntSphElem->base.acHitElem->toucherFlags & TOUCH_DREW_HITMARK)) { + Vec3f hitPos; + Math_Vec3s_ToVec3f(&hitPos, &jntSphElem->base.bumper.hitPos); CollisionCheck_HitEffects(play, jntSphElem->base.acHit, jntSphElem->base.acHitElem, &jntSph->base, &jntSphElem->base, &hitPos); @@ -2528,10 +2537,11 @@ void CollisionCheck_SetJntSphHitFX(PlayState* play, CollisionCheckContext* colCh void CollisionCheck_SetCylHitFX(PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { ColliderCylinder* cyl = (ColliderCylinder*)col; - Vec3f hitPos; if ((cyl->elem.bumperFlags & BUMP_DRAW_HITMARK) && (cyl->elem.acHitElem != NULL) && !(cyl->elem.acHitElem->toucherFlags & TOUCH_DREW_HITMARK)) { + Vec3f hitPos; + Math_Vec3s_ToVec3f(&hitPos, &cyl->elem.bumper.hitPos); CollisionCheck_HitEffects(play, cyl->elem.acHit, cyl->elem.acHitElem, &cyl->base, &cyl->elem, &hitPos); cyl->elem.acHitElem->toucherFlags |= TOUCH_DREW_HITMARK; @@ -2541,11 +2551,12 @@ void CollisionCheck_SetCylHitFX(PlayState* play, CollisionCheckContext* colChkCt void CollisionCheck_SetTrisHitFX(PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) { ColliderTris* tris = (ColliderTris*)col; ColliderTrisElement* trisElem; - Vec3f hitPos; for (trisElem = tris->elements; trisElem < tris->elements + tris->count; trisElem++) { if ((trisElem->base.bumperFlags & BUMP_DRAW_HITMARK) && (trisElem->base.acHitElem != NULL) && !(trisElem->base.acHitElem->toucherFlags & TOUCH_DREW_HITMARK)) { + Vec3f hitPos; + Math_Vec3s_ToVec3f(&hitPos, &trisElem->base.bumper.hitPos); CollisionCheck_HitEffects(play, trisElem->base.acHit, trisElem->base.acHitElem, &tris->base, &trisElem->base, &hitPos); @@ -3688,6 +3699,9 @@ u8 CollisionCheck_GetSwordDamage(s32 dmgFlags) { damage = 8; } +#if OOT_DEBUG KREG(7) = damage; +#endif + return damage; }