From 0d7670f05980037814b43507e9707a9bacdd98d8 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Fri, 29 Apr 2022 20:29:49 +0200 Subject: [PATCH] Fixup `feetFloorFlags` doc and -> `feetFloorFlag` (#1180) --- include/z64actor.h | 2 +- src/code/z_actor.c | 18 ++++++++++-------- .../actors/ovl_player_actor/z_player.c | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/z64actor.h b/include/z64actor.h index 6a0e07db5a..2d91dcbe48 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -96,7 +96,7 @@ typedef struct { /* 0x0C */ ActorShadowFunc shadowDraw; // Shadow draw function /* 0x10 */ f32 shadowScale; // Changes the size of the shadow /* 0x14 */ u8 shadowAlpha; // Default is 255 - /* 0x15 */ u8 feetFloorFlags; // Set if the actor's foot is clipped under the floor. & 1 is right foot, & 2 is left + /* 0x15 */ u8 feetFloorFlag; // 0 if actor or feet aren't on ground, or 1 or 2 depending on feet positions /* 0x18 */ Vec3f feetPos[2]; // Update by using `Actor_SetFeetPos` in PostLimbDraw } ActorShape; // size = 0x30 diff --git a/src/code/z_actor.c b/src/code/z_actor.c index c5cc774211..6da4ff122f 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -137,18 +137,20 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); - actor->shape.feetFloorFlags = 0; + // feetFloorFlag is temporarily a bitfield where the bits are set if the foot is on ground + // feetFloorFlag & 2 is left foot, feetFloorFlag & 1 is right foot + actor->shape.feetFloorFlag = 0; for (i = 0; i < 2; i++) { feetPosPtr->y += 50.0f; *floorHeightPtr = func_800BFCB8(globalCtx, &floorMtx, feetPosPtr); feetPosPtr->y -= 50.0f; - actor->shape.feetFloorFlags <<= 1; + actor->shape.feetFloorFlag <<= 1; distToFloor = feetPosPtr->y - *floorHeightPtr; if ((-1.0f <= distToFloor) && (distToFloor < 500.0f)) { if (distToFloor <= 0.0f) { - actor->shape.feetFloorFlags++; + actor->shape.feetFloorFlag++; } distToFloor = CLAMP_MAX(distToFloor, 30.0f); shadowAlpha = (f32)actor->shape.shadowAlpha * (1.0f - (distToFloor * (1.0f / 30.0f))); @@ -189,14 +191,14 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx } if (!(actor->bgCheckFlags & BGCHECKFLAG_GROUND)) { - actor->shape.feetFloorFlags = 0; - } else if (actor->shape.feetFloorFlags == 3) { + actor->shape.feetFloorFlag = 0; + } else if (actor->shape.feetFloorFlag == 3) { f32 footDistY = actor->shape.feetPos[FOOT_LEFT].y - actor->shape.feetPos[FOOT_RIGHT].y; - if ((floorHeight[0] + footDistY) < (floorHeight[1] - footDistY)) { - actor->shape.feetFloorFlags = 2; + if ((floorHeight[FOOT_LEFT] + footDistY) < (floorHeight[FOOT_RIGHT] - footDistY)) { + actor->shape.feetFloorFlag = 2; } else { - actor->shape.feetFloorFlags = 1; + actor->shape.feetFloorFlag = 1; } } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index a1064af965..b0113512b1 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -11175,7 +11175,7 @@ void func_8084BBE4(Player* this, GlobalContext* globalCtx) { return; } - if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A) || (this->actor.shape.feetFloorFlags != 0)) { + if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A) || (this->actor.shape.feetFloorFlag != 0)) { func_80837B60(this); if (this->unk_84F < 0) { this->linearVelocity = -0.8f;