mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-10 19:20:13 +00:00
z_collision_check.c OK (#1642)
* Match z_collision_check.c * Disable function declarations * Remove /* OOT_DEBUG */ * Remove newlines around ifdef * Newlines * Tweak z_actor.c #if to avoid merge conflicts
This commit is contained in:
parent
77c9c97ff9
commit
17da5e7bf9
4 changed files with 29 additions and 5 deletions
|
@ -619,8 +619,10 @@ u16 WaterBox_GetBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox);
|
||||||
u32 WaterBox_GetLightIndex(CollisionContext* colCtx, WaterBox* waterBox);
|
u32 WaterBox_GetLightIndex(CollisionContext* colCtx, WaterBox* waterBox);
|
||||||
s32 func_80042708(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* point, Vec3f* closestPoint);
|
s32 func_80042708(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* point, Vec3f* closestPoint);
|
||||||
s32 func_800427B4(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec3f* pointB, 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_DrawDynaCollision(PlayState*, CollisionContext*);
|
||||||
void BgCheck_DrawStaticCollision(PlayState*, CollisionContext*);
|
void BgCheck_DrawStaticCollision(PlayState*, CollisionContext*);
|
||||||
|
#endif
|
||||||
void func_80043334(CollisionContext* colCtx, Actor* actor, s32 bgId);
|
void func_80043334(CollisionContext* colCtx, Actor* actor, s32 bgId);
|
||||||
s32 DynaPolyActor_TransformCarriedActor(CollisionContext* colCtx, s32 bgId, Actor* carriedActor);
|
s32 DynaPolyActor_TransformCarriedActor(CollisionContext* colCtx, s32 bgId, Actor* carriedActor);
|
||||||
void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 transformFlags);
|
void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 transformFlags);
|
||||||
|
@ -665,8 +667,10 @@ s32 func_8005B198(void);
|
||||||
s16 Camera_SetFinishedFlag(Camera* camera);
|
s16 Camera_SetFinishedFlag(Camera* camera);
|
||||||
DamageTable* DamageTable_Get(s32 index);
|
DamageTable* DamageTable_Get(s32 index);
|
||||||
void DamageTable_Clear(DamageTable* table);
|
void DamageTable_Clear(DamageTable* table);
|
||||||
|
#if OOT_DEBUG
|
||||||
void Collider_DrawRedPoly(GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC);
|
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);
|
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_InitJntSph(PlayState* play, ColliderJntSph* jntSph);
|
||||||
s32 Collider_FreeJntSph(PlayState* play, ColliderJntSph* jntSph);
|
s32 Collider_FreeJntSph(PlayState* play, ColliderJntSph* jntSph);
|
||||||
s32 Collider_DestroyJntSph(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_ClearContext(PlayState* play, CollisionCheckContext* colChkCtx);
|
||||||
void CollisionCheck_EnableSAC(PlayState* play, CollisionCheckContext* colChkCtx);
|
void CollisionCheck_EnableSAC(PlayState* play, CollisionCheckContext* colChkCtx);
|
||||||
void CollisionCheck_DisableSAC(PlayState* play, CollisionCheckContext* colChkCtx);
|
void CollisionCheck_DisableSAC(PlayState* play, CollisionCheckContext* colChkCtx);
|
||||||
|
#if OOT_DEBUG
|
||||||
void Collider_Draw(PlayState* play, Collider* col);
|
void Collider_Draw(PlayState* play, Collider* col);
|
||||||
void CollisionCheck_DrawCollision(PlayState* play, CollisionCheckContext* colChkCtx);
|
void CollisionCheck_DrawCollision(PlayState* play, CollisionCheckContext* colChkCtx);
|
||||||
|
#endif
|
||||||
s32 CollisionCheck_SetAT(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider);
|
s32 CollisionCheck_SetAT(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider);
|
||||||
s32 CollisionCheck_SetAT_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index);
|
s32 CollisionCheck_SetAT_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index);
|
||||||
s32 CollisionCheck_SetAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider);
|
s32 CollisionCheck_SetAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider);
|
||||||
|
|
|
@ -2609,9 +2609,11 @@ void func_800315AC(PlayState* play, ActorContext* actorCtx) {
|
||||||
TitleCard_Draw(play, &actorCtx->titleCtx);
|
TitleCard_Draw(play, &actorCtx->titleCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OOT_DEBUG
|
||||||
if ((HREG(64) != 1) || (HREG(76) != 0)) {
|
if ((HREG(64) != 1) || (HREG(76) != 0)) {
|
||||||
CollisionCheck_DrawCollision(play, &play->colChkCtx);
|
CollisionCheck_DrawCollision(play, &play->colChkCtx);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 6563);
|
CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 6563);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4409,6 +4409,7 @@ s32 func_800427B4(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OOT_DEBUG
|
||||||
/**
|
/**
|
||||||
* Draw a list of dyna polys, specified by `ssList`
|
* 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);
|
BgCheck_DrawStaticPolyList(play, colCtx, &lookup->ceiling, 255, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -7,6 +7,7 @@ typedef void (*ColChkApplyFunc)(PlayState*, CollisionCheckContext*, Collider*);
|
||||||
typedef void (*ColChkVsFunc)(PlayState*, CollisionCheckContext*, Collider*, Collider*);
|
typedef void (*ColChkVsFunc)(PlayState*, CollisionCheckContext*, Collider*, Collider*);
|
||||||
typedef s32 (*ColChkLineFunc)(PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*);
|
typedef s32 (*ColChkLineFunc)(PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*);
|
||||||
|
|
||||||
|
#if OOT_DEBUG
|
||||||
/**
|
/**
|
||||||
* Draws a red triangle with vertices vA, vB, and vC.
|
* 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);
|
CLOSE_DISPS(gfxCtx, "../z_collision_check.c", 757);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
s32 Collider_InitBase(PlayState* play, Collider* col) {
|
s32 Collider_InitBase(PlayState* play, Collider* col) {
|
||||||
static Collider init = {
|
static Collider init = {
|
||||||
|
@ -1000,9 +1002,12 @@ s32 Collider_ResetLineOC(PlayState* play, OcLine* line) {
|
||||||
void CollisionCheck_InitContext(PlayState* play, CollisionCheckContext* colChkCtx) {
|
void CollisionCheck_InitContext(PlayState* play, CollisionCheckContext* colChkCtx) {
|
||||||
colChkCtx->sacFlags = 0;
|
colChkCtx->sacFlags = 0;
|
||||||
CollisionCheck_ClearContext(play, colChkCtx);
|
CollisionCheck_ClearContext(play, colChkCtx);
|
||||||
|
|
||||||
|
#if OOT_DEBUG
|
||||||
AREG(21) = true;
|
AREG(21) = true;
|
||||||
AREG(22) = true;
|
AREG(22) = true;
|
||||||
AREG(23) = true;
|
AREG(23) = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollisionCheck_DestroyContext(PlayState* play, CollisionCheckContext* colChkCtx) {
|
void CollisionCheck_DestroyContext(PlayState* play, CollisionCheckContext* colChkCtx) {
|
||||||
|
@ -1052,6 +1057,7 @@ void CollisionCheck_DisableSAC(PlayState* play, CollisionCheckContext* colChkCtx
|
||||||
colChkCtx->sacFlags &= ~SAC_ENABLE;
|
colChkCtx->sacFlags &= ~SAC_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OOT_DEBUG
|
||||||
/**
|
/**
|
||||||
* Draws a collider of any shape.
|
* Draws a collider of any shape.
|
||||||
* Math3D_DrawSphere and Math3D_DrawCylinder are noops, so JntSph and Cylinder are not drawn.
|
* 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[] = {
|
static ColChkResetFunc sATResetFuncs[] = {
|
||||||
Collider_ResetJntSphAT,
|
Collider_ResetJntSphAT,
|
||||||
|
@ -2153,8 +2160,6 @@ void CollisionCheck_ATTrisVsACCyl(PlayState* play, CollisionCheckContext* colChk
|
||||||
ColliderTris* atTris = (ColliderTris*)atCol;
|
ColliderTris* atTris = (ColliderTris*)atCol;
|
||||||
ColliderTrisElement* atTrisElem;
|
ColliderTrisElement* atTrisElem;
|
||||||
ColliderCylinder* acCyl = (ColliderCylinder*)acCol;
|
ColliderCylinder* acCyl = (ColliderCylinder*)acCol;
|
||||||
Vec3f atPos;
|
|
||||||
Vec3f acPos;
|
|
||||||
|
|
||||||
if (acCyl->dim.radius > 0 && acCyl->dim.height > 0 && atTris->count > 0 && atTris->elements != NULL) {
|
if (acCyl->dim.radius > 0 && acCyl->dim.height > 0 && atTris->count > 0 && atTris->elements != NULL) {
|
||||||
if (CollisionCheck_SkipElementBump(&acCyl->elem) == true) {
|
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) {
|
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.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.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);
|
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) {
|
void CollisionCheck_SetJntSphHitFX(PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) {
|
||||||
ColliderJntSph* jntSph = (ColliderJntSph*)col;
|
ColliderJntSph* jntSph = (ColliderJntSph*)col;
|
||||||
ColliderJntSphElement* jntSphElem;
|
ColliderJntSphElement* jntSphElem;
|
||||||
Vec3f hitPos;
|
|
||||||
|
|
||||||
for (jntSphElem = jntSph->elements; jntSphElem < jntSph->elements + jntSph->count; jntSphElem++) {
|
for (jntSphElem = jntSph->elements; jntSphElem < jntSph->elements + jntSph->count; jntSphElem++) {
|
||||||
if ((jntSphElem->base.bumperFlags & BUMP_DRAW_HITMARK) && (jntSphElem->base.acHitElem != NULL) &&
|
if ((jntSphElem->base.bumperFlags & BUMP_DRAW_HITMARK) && (jntSphElem->base.acHitElem != NULL) &&
|
||||||
!(jntSphElem->base.acHitElem->toucherFlags & TOUCH_DREW_HITMARK)) {
|
!(jntSphElem->base.acHitElem->toucherFlags & TOUCH_DREW_HITMARK)) {
|
||||||
|
Vec3f hitPos;
|
||||||
|
|
||||||
Math_Vec3s_ToVec3f(&hitPos, &jntSphElem->base.bumper.hitPos);
|
Math_Vec3s_ToVec3f(&hitPos, &jntSphElem->base.bumper.hitPos);
|
||||||
CollisionCheck_HitEffects(play, jntSphElem->base.acHit, jntSphElem->base.acHitElem, &jntSph->base,
|
CollisionCheck_HitEffects(play, jntSphElem->base.acHit, jntSphElem->base.acHitElem, &jntSph->base,
|
||||||
&jntSphElem->base, &hitPos);
|
&jntSphElem->base, &hitPos);
|
||||||
|
@ -2528,10 +2537,11 @@ void CollisionCheck_SetJntSphHitFX(PlayState* play, CollisionCheckContext* colCh
|
||||||
|
|
||||||
void CollisionCheck_SetCylHitFX(PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) {
|
void CollisionCheck_SetCylHitFX(PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) {
|
||||||
ColliderCylinder* cyl = (ColliderCylinder*)col;
|
ColliderCylinder* cyl = (ColliderCylinder*)col;
|
||||||
Vec3f hitPos;
|
|
||||||
|
|
||||||
if ((cyl->elem.bumperFlags & BUMP_DRAW_HITMARK) && (cyl->elem.acHitElem != NULL) &&
|
if ((cyl->elem.bumperFlags & BUMP_DRAW_HITMARK) && (cyl->elem.acHitElem != NULL) &&
|
||||||
!(cyl->elem.acHitElem->toucherFlags & TOUCH_DREW_HITMARK)) {
|
!(cyl->elem.acHitElem->toucherFlags & TOUCH_DREW_HITMARK)) {
|
||||||
|
Vec3f hitPos;
|
||||||
|
|
||||||
Math_Vec3s_ToVec3f(&hitPos, &cyl->elem.bumper.hitPos);
|
Math_Vec3s_ToVec3f(&hitPos, &cyl->elem.bumper.hitPos);
|
||||||
CollisionCheck_HitEffects(play, cyl->elem.acHit, cyl->elem.acHitElem, &cyl->base, &cyl->elem, &hitPos);
|
CollisionCheck_HitEffects(play, cyl->elem.acHit, cyl->elem.acHitElem, &cyl->base, &cyl->elem, &hitPos);
|
||||||
cyl->elem.acHitElem->toucherFlags |= TOUCH_DREW_HITMARK;
|
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) {
|
void CollisionCheck_SetTrisHitFX(PlayState* play, CollisionCheckContext* colChkCtx, Collider* col) {
|
||||||
ColliderTris* tris = (ColliderTris*)col;
|
ColliderTris* tris = (ColliderTris*)col;
|
||||||
ColliderTrisElement* trisElem;
|
ColliderTrisElement* trisElem;
|
||||||
Vec3f hitPos;
|
|
||||||
|
|
||||||
for (trisElem = tris->elements; trisElem < tris->elements + tris->count; trisElem++) {
|
for (trisElem = tris->elements; trisElem < tris->elements + tris->count; trisElem++) {
|
||||||
if ((trisElem->base.bumperFlags & BUMP_DRAW_HITMARK) && (trisElem->base.acHitElem != NULL) &&
|
if ((trisElem->base.bumperFlags & BUMP_DRAW_HITMARK) && (trisElem->base.acHitElem != NULL) &&
|
||||||
!(trisElem->base.acHitElem->toucherFlags & TOUCH_DREW_HITMARK)) {
|
!(trisElem->base.acHitElem->toucherFlags & TOUCH_DREW_HITMARK)) {
|
||||||
|
Vec3f hitPos;
|
||||||
|
|
||||||
Math_Vec3s_ToVec3f(&hitPos, &trisElem->base.bumper.hitPos);
|
Math_Vec3s_ToVec3f(&hitPos, &trisElem->base.bumper.hitPos);
|
||||||
CollisionCheck_HitEffects(play, trisElem->base.acHit, trisElem->base.acHitElem, &tris->base,
|
CollisionCheck_HitEffects(play, trisElem->base.acHit, trisElem->base.acHitElem, &tris->base,
|
||||||
&trisElem->base, &hitPos);
|
&trisElem->base, &hitPos);
|
||||||
|
@ -3688,6 +3699,9 @@ u8 CollisionCheck_GetSwordDamage(s32 dmgFlags) {
|
||||||
damage = 8;
|
damage = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OOT_DEBUG
|
||||||
KREG(7) = damage;
|
KREG(7) = damage;
|
||||||
|
#endif
|
||||||
|
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue