Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colliders: colType -> colMaterial #2186

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions include/z64collision_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@ struct PlayState;
* Bases for all shapes of colliders
*/

typedef enum ColliderType {
/* 0 */ COLTYPE_HIT0, // Blue blood, white hitmark
/* 1 */ COLTYPE_HIT1, // No blood, dust hitmark
/* 2 */ COLTYPE_HIT2, // Green blood, dust hitmark
/* 3 */ COLTYPE_HIT3, // No blood, white hitmark
/* 4 */ COLTYPE_HIT4, // Water burst, no hitmark
/* 5 */ COLTYPE_HIT5, // No blood, red hitmark
/* 6 */ COLTYPE_HIT6, // Green blood, white hitmark
/* 7 */ COLTYPE_HIT7, // Red blood, white hitmark
/* 8 */ COLTYPE_HIT8, // Blue blood, red hitmark
/* 9 */ COLTYPE_METAL,
/* 10 */ COLTYPE_NONE,
/* 11 */ COLTYPE_WOOD,
/* 12 */ COLTYPE_HARD,
/* 13 */ COLTYPE_TREE
} ColliderType;

typedef enum ColliderShape {
/* 0 */ COLSHAPE_JNTSPH,
/* 1 */ COLSHAPE_CYLINDER,
Expand All @@ -42,6 +25,23 @@ typedef enum ColliderShape {
/* 4 */ COLSHAPE_MAX
} ColliderShape;

typedef enum ColliderMaterial {
/* 0 */ COL_MATERIAL_HIT0, // Blue blood, white hitmark
/* 1 */ COL_MATERIAL_HIT1, // No blood, dust hitmark
/* 2 */ COL_MATERIAL_HIT2, // Green blood, dust hitmark
/* 3 */ COL_MATERIAL_HIT3, // No blood, white hitmark
/* 4 */ COL_MATERIAL_HIT4, // Water burst, no hitmark
/* 5 */ COL_MATERIAL_HIT5, // No blood, red hitmark
/* 6 */ COL_MATERIAL_HIT6, // Green blood, white hitmark
/* 7 */ COL_MATERIAL_HIT7, // Red blood, white hitmark
/* 8 */ COL_MATERIAL_HIT8, // Blue blood, red hitmark
/* 9 */ COL_MATERIAL_METAL,
/* 10 */ COL_MATERIAL_NONE,
/* 11 */ COL_MATERIAL_WOOD,
/* 12 */ COL_MATERIAL_HARD,
/* 13 */ COL_MATERIAL_TREE
} ColliderMaterial;

typedef struct Collider {
/* 0x00 */ struct Actor* actor; // Attached actor
/* 0x04 */ struct Actor* at; // Actor attached to what it collided with as an AT collider.
Expand All @@ -51,12 +51,12 @@ typedef struct Collider {
/* 0x11 */ u8 acFlags;
/* 0x12 */ u8 ocFlags1;
/* 0x13 */ u8 ocFlags2; // Flags related to which colliders it can OC collide with.
/* 0x14 */ u8 colType; // Determines hitmarks and sound effects during AC collisions. See `ColliderType` enum
/* 0x14 */ u8 colMaterial; // Determines hitmarks and sound effects during AC collisions. See `ColliderMaterial` enum
/* 0x15 */ u8 shape; // See `ColliderShape` enum
} Collider; // size = 0x18

typedef struct ColliderInit {
/* 0x00 */ u8 colType;
/* 0x00 */ u8 colMaterial;
/* 0x01 */ u8 atFlags;
/* 0x02 */ u8 acFlags;
/* 0x03 */ u8 ocFlags1;
Expand All @@ -65,7 +65,7 @@ typedef struct ColliderInit {
} ColliderInit; // size = 0x06

typedef struct ColliderInitType1 {
/* 0x00 */ u8 colType;
/* 0x00 */ u8 colMaterial;
/* 0x01 */ u8 atFlags;
/* 0x02 */ u8 acFlags;
/* 0x03 */ u8 ocFlags1;
Expand Down
60 changes: 30 additions & 30 deletions src/code/z_collision_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void Collider_DrawPoly(GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC,

s32 Collider_InitBase(PlayState* play, Collider* col) {
static Collider init = {
NULL, NULL, NULL, NULL, AT_NONE, AC_NONE, OC1_NONE, OC2_NONE, COLTYPE_HIT3, COLSHAPE_MAX,
NULL, NULL, NULL, NULL, AT_NONE, AC_NONE, OC1_NONE, OC2_NONE, COL_MATERIAL_HIT3, COLSHAPE_MAX,
};

*col = init;
Expand All @@ -93,7 +93,7 @@ s32 Collider_DestroyBase(PlayState* play, Collider* col) {
}

/**
* Uses default OC2_TYPE_1 and COLTYPE_HIT0
* Uses default OC2_TYPE_1 and COL_MATERIAL_HIT0
*/
s32 Collider_SetBaseToActor(PlayState* play, Collider* col, ColliderInitToActor* src) {
col->actor = src->actor;
Expand All @@ -110,7 +110,7 @@ s32 Collider_SetBaseToActor(PlayState* play, Collider* col, ColliderInitToActor*
*/
s32 Collider_SetBaseType1(PlayState* play, Collider* col, Actor* actor, ColliderInitType1* src) {
col->actor = actor;
col->colType = src->colType;
col->colMaterial = src->colMaterial;
col->atFlags = src->atFlags;
col->acFlags = src->acFlags;
col->ocFlags1 = src->ocFlags1;
Expand All @@ -121,7 +121,7 @@ s32 Collider_SetBaseType1(PlayState* play, Collider* col, Actor* actor, Collider

s32 Collider_SetBase(PlayState* play, Collider* col, Actor* actor, ColliderInit* src) {
col->actor = actor;
col->colType = src->colType;
col->colMaterial = src->colMaterial;
col->atFlags = src->atFlags;
col->acFlags = src->acFlags;
col->ocFlags1 = src->ocFlags1;
Expand Down Expand Up @@ -339,7 +339,7 @@ s32 Collider_DestroyJntSph(PlayState* play, ColliderJntSph* jntSph) {

/**
* Sets up the ColliderJntSph using the values in src, sets it to the actor specified in src, and dynamically allocates
* the element array. Uses default OC2_TYPE_1 and COLTYPE_HIT0. Unused.
* the element array. Uses default OC2_TYPE_1 and COL_MATERIAL_HIT0. Unused.
*/
s32 Collider_SetJntSphToActor(PlayState* play, ColliderJntSph* dest, ColliderJntSphInitToActor* src) {
ColliderJntSphElement* destElem;
Expand Down Expand Up @@ -524,7 +524,7 @@ s32 Collider_DestroyCylinder(PlayState* play, ColliderCylinder* cyl) {

/**
* Sets up the ColliderCylinder using the values in src and sets it to the actor specified in src. Uses default
* OC2_TYPE_1 and COLTYPE_0. Used only by DekuJr, who sets it to himself anyways.
* OC2_TYPE_1 and COL_MATERIAL_0. Used only by DekuJr, who sets it to himself anyways.
*/
s32 Collider_SetCylinderToActor(PlayState* play, ColliderCylinder* dest, ColliderCylinderInitToActor* src) {
Collider_SetBaseToActor(play, &dest->base, &src->base);
Expand Down Expand Up @@ -1546,7 +1546,7 @@ void CollisionCheck_RedBloodUnused(PlayState* play, Collider* collider, Vec3f* v
void CollisionCheck_HitSolid(PlayState* play, ColliderElement* elem, Collider* collider, Vec3f* hitPos) {
s32 flags = elem->atElemFlags & ATELEM_SFX_MASK;

if (flags == ATELEM_SFX_NORMAL && collider->colType != COLTYPE_METAL) {
if (flags == ATELEM_SFX_NORMAL && collider->colMaterial != COL_MATERIAL_METAL) {
EffectSsHitMark_SpawnFixedScale(play, EFFECT_HITMARK_WHITE, hitPos);
if (collider->actor == NULL) {
Audio_PlaySfxGeneral(NA_SE_IT_SHIELD_BOUND, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
Expand All @@ -1555,7 +1555,7 @@ void CollisionCheck_HitSolid(PlayState* play, ColliderElement* elem, Collider* c
Audio_PlaySfxGeneral(NA_SE_IT_SHIELD_BOUND, &collider->actor->projectedPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
}
} else if (flags == ATELEM_SFX_NORMAL) { // collider->colType == COLTYPE_METAL
} else if (flags == ATELEM_SFX_NORMAL) { // collider->colMaterial == COL_MATERIAL_METAL
EffectSsHitMark_SpawnFixedScale(play, EFFECT_HITMARK_METAL, hitPos);
if (collider->actor == NULL) {
CollisionCheck_SpawnShieldParticlesMetal(play, hitPos);
Expand Down Expand Up @@ -1640,24 +1640,24 @@ static ColChkBloodFunc sBloodFuncs[] = {
};

static HitInfo sHitInfo[] = {
{ BLOOD_BLUE, HIT_WHITE }, // COLTYPE_HIT0
{ BLOOD_NONE, HIT_DUST }, // COLTYPE_HIT1
{ BLOOD_GREEN, HIT_DUST }, // COLTYPE_HIT2
{ BLOOD_NONE, HIT_WHITE }, // COLTYPE_HIT3
{ BLOOD_WATER, HIT_NONE }, // COLTYPE_HIT4
{ BLOOD_NONE, HIT_RED }, // COLTYPE_HIT5
{ BLOOD_GREEN, HIT_WHITE }, // COLTYPE_HIT6
{ BLOOD_RED, HIT_WHITE }, // COLTYPE_HIT7
{ BLOOD_BLUE, HIT_RED }, // COLTYPE_HIT8
{ BLOOD_NONE, HIT_SOLID }, // COLTYPE_METAL
{ BLOOD_NONE, HIT_NONE }, // COLTYPE_NONE
{ BLOOD_NONE, HIT_SOLID }, // COLTYPE_WOOD
{ BLOOD_NONE, HIT_SOLID }, // COLTYPE_HARD
{ BLOOD_NONE, HIT_WOOD }, // COLTYPE_TREE
{ BLOOD_BLUE, HIT_WHITE }, // COL_MATERIAL_HIT0
{ BLOOD_NONE, HIT_DUST }, // COL_MATERIAL_HIT1
{ BLOOD_GREEN, HIT_DUST }, // COL_MATERIAL_HIT2
{ BLOOD_NONE, HIT_WHITE }, // COL_MATERIAL_HIT3
{ BLOOD_WATER, HIT_NONE }, // COL_MATERIAL_HIT4
{ BLOOD_NONE, HIT_RED }, // COL_MATERIAL_HIT5
{ BLOOD_GREEN, HIT_WHITE }, // COL_MATERIAL_HIT6
{ BLOOD_RED, HIT_WHITE }, // COL_MATERIAL_HIT7
{ BLOOD_BLUE, HIT_RED }, // COL_MATERIAL_HIT8
{ BLOOD_NONE, HIT_SOLID }, // COL_MATERIAL_METAL
{ BLOOD_NONE, HIT_NONE }, // COL_MATERIAL_NONE
{ BLOOD_NONE, HIT_SOLID }, // COL_MATERIAL_WOOD
{ BLOOD_NONE, HIT_SOLID }, // COL_MATERIAL_HARD
{ BLOOD_NONE, HIT_WOOD }, // COL_MATERIAL_TREE
};

/**
* Handles hitmarks, blood, and sound effects for each AC collision, determined by the AC collider's colType
* Handles hitmarks, blood, and sound effects for each AC collision, determined by the AC collider's colMaterial
*/
void CollisionCheck_HitEffects(PlayState* play, Collider* atCol, ColliderElement* atElem, Collider* acCol,
ColliderElement* acElem, Vec3f* hitPos) {
Expand All @@ -1668,21 +1668,21 @@ void CollisionCheck_HitEffects(PlayState* play, Collider* atCol, ColliderElement
return;
}
if (acCol->actor != NULL) {
sBloodFuncs[sHitInfo[acCol->colType].blood](play, acCol, hitPos);
sBloodFuncs[sHitInfo[acCol->colMaterial].blood](play, acCol, hitPos);
}
if (acCol->actor != NULL) {
if (sHitInfo[acCol->colType].effect == HIT_SOLID) {
if (sHitInfo[acCol->colMaterial].effect == HIT_SOLID) {
CollisionCheck_HitSolid(play, atElem, acCol, hitPos);
} else if (sHitInfo[acCol->colType].effect == HIT_WOOD) {
} else if (sHitInfo[acCol->colMaterial].effect == HIT_WOOD) {
if (atCol->actor == NULL) {
CollisionCheck_SpawnShieldParticles(play, hitPos);
Audio_PlaySfxGeneral(NA_SE_IT_REFLECTION_WOOD, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
} else {
CollisionCheck_SpawnShieldParticlesWood(play, hitPos, &atCol->actor->projectedPos);
}
} else if (sHitInfo[acCol->colType].effect != HIT_NONE) {
EffectSsHitMark_SpawnFixedScale(play, sHitInfo[acCol->colType].effect, hitPos);
} else if (sHitInfo[acCol->colMaterial].effect != HIT_NONE) {
EffectSsHitMark_SpawnFixedScale(play, sHitInfo[acCol->colMaterial].effect, hitPos);
if (!(acElem->acElemFlags & ACELEM_NO_SWORD_SFX)) {
CollisionCheck_SwordHitAudio(atCol, acElem);
}
Expand Down Expand Up @@ -1736,8 +1736,8 @@ s32 CollisionCheck_SetATvsAC(PlayState* play, Collider* atCol, ColliderElement*
acElem->acDmgInfo.hitPos.x = hitPos->x;
acElem->acDmgInfo.hitPos.y = hitPos->y;
acElem->acDmgInfo.hitPos.z = hitPos->z;
if (!(atElem->atElemFlags & ATELEM_AT_HITMARK) && acCol->colType != COLTYPE_METAL &&
acCol->colType != COLTYPE_WOOD && acCol->colType != COLTYPE_HARD) {
if (!(atElem->atElemFlags & ATELEM_AT_HITMARK) && acCol->colMaterial != COL_MATERIAL_METAL &&
acCol->colMaterial != COL_MATERIAL_WOOD && acCol->colMaterial != COL_MATERIAL_HARD) {
acElem->acElemFlags |= ACELEM_DRAW_HITMARK;
} else {
CollisionCheck_HitEffects(play, atCol, atElem, acCol, acElem, hitPos);
Expand Down
2 changes: 1 addition & 1 deletion src/code/z_en_a_keep.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ActorProfile En_A_Obj_Profile = {

static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_NONE,
AC_ON | AC_TYPE_ALL,
OC1_ON | OC1_TYPE_ALL,
Expand Down
2 changes: 1 addition & 1 deletion src/code/z_en_item00.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ActorProfile En_Item00_Profile = {

static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_NONE,
AC_ON | AC_TYPE_PLAYER,
OC1_NONE,
Expand Down
12 changes: 6 additions & 6 deletions src/code/z_player_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,17 +1312,17 @@ u8 func_80090480(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo
}

void Player_UpdateShieldCollider(PlayState* play, Player* this, ColliderQuad* collider, Vec3f* quadSrc) {
static u8 shieldColTypes[PLAYER_SHIELD_MAX] = {
COLTYPE_METAL,
COLTYPE_WOOD,
COLTYPE_METAL,
COLTYPE_METAL,
static u8 shieldColMaterials[PLAYER_SHIELD_MAX] = {
COL_MATERIAL_METAL,
COL_MATERIAL_WOOD,
COL_MATERIAL_METAL,
COL_MATERIAL_METAL,
};

if (this->stateFlags1 & PLAYER_STATE1_22) {
Vec3f quadDest[4];

this->shieldQuad.base.colType = shieldColTypes[this->currentShield];
this->shieldQuad.base.colMaterial = shieldColMaterials[this->currentShield];

Matrix_MultVec3f(&quadSrc[0], &quadDest[0]);
Matrix_MultVec3f(&quadSrc[1], &quadDest[1]);
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ActorProfile Arms_Hook_Profile = {

static ColliderQuadInit sQuadInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_ON | AT_TYPE_PLAYER,
AC_NONE,
OC1_NONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ActorProfile Bg_Bdan_Objects_Profile = {

static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_ON | AT_TYPE_ENEMY,
AC_NONE,
OC1_NONE,
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static ColliderJntSphElementInit sJntSphElementsInit[] = {

static ColliderJntSphInit sJntSphInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_NONE,
AC_ON | AC_TYPE_PLAYER,
OC1_ON | OC1_TYPE_ALL,
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_Bg_Bombwall/z_bg_bombwall.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static ColliderTrisElementInit sTrisElementsInit[3] = {

static ColliderTrisInit sTrisInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_NONE,
AC_ON | AC_TYPE_PLAYER,
OC1_NONE,
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ActorProfile Bg_Breakwall_Profile = {

static ColliderQuadInit sQuadInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_NONE,
AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER,
OC1_NONE,
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ActorProfile Bg_Ddan_Kd_Profile = {

static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_NONE,
AC_ON | AC_TYPE_ALL,
OC1_NONE,
Expand Down
4 changes: 2 additions & 2 deletions src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ActorProfile Bg_Dodoago_Profile = {

static ColliderCylinderInit sColCylinderInitMain = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_NONE,
AC_ON | AC_TYPE_ALL,
OC1_NONE,
Expand All @@ -54,7 +54,7 @@ static ColliderCylinderInit sColCylinderInitMain = {

static ColliderCylinderInit sColCylinderInitLeftRight = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_NONE,
AC_NONE,
OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ActorProfile Bg_Gnd_Soulmeiro_Profile = {

static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_NONE,
AC_ON | AC_TYPE_PLAYER,
OC1_NONE,
Expand Down
4 changes: 2 additions & 2 deletions src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static ColliderTrisElementInit sTrisElementsInit[4] = {

static ColliderTrisInit sTrisInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_ON | AT_TYPE_ENEMY,
AC_NONE,
OC1_NONE,
Expand All @@ -100,7 +100,7 @@ static ColliderTrisInit sTrisInit = {

static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_NONE,
AC_NONE,
OC1_ON | OC1_TYPE_ALL,
Expand Down
4 changes: 2 additions & 2 deletions src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ActorProfile Bg_Haka_Trap_Profile = {

static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_METAL,
COL_MATERIAL_METAL,
AT_ON | AT_TYPE_ENEMY,
AC_ON | AC_HARD | AC_TYPE_PLAYER,
OC1_ON | OC1_TYPE_PLAYER,
Expand Down Expand Up @@ -88,7 +88,7 @@ static ColliderTrisElementInit sTrisElementsInit[2] = {

static ColliderTrisInit sTrisInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_NONE,
AC_ON | AC_TYPE_PLAYER,
OC1_NONE,
Expand Down
4 changes: 2 additions & 2 deletions src/overlays/actors/ovl_Bg_Haka_Tubo/z_bg_haka_tubo.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ActorProfile Bg_Haka_Tubo_Profile = {

static ColliderCylinderInit sPotColliderInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_NONE,
AC_ON | AC_TYPE_PLAYER,
OC1_NONE,
Expand All @@ -52,7 +52,7 @@ static ColliderCylinderInit sPotColliderInit = {

static ColliderCylinderInit sFlamesColliderInit = {
{
COLTYPE_NONE,
COL_MATERIAL_NONE,
AT_ON | AT_TYPE_ENEMY,
AC_NONE,
OC1_ON | OC1_TYPE_PLAYER,
Expand Down
Loading