summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authormzxrules <mzxrules@gmail.com>2022-08-30 11:49:51 -0400
committerGitHub <noreply@github.com>2022-08-30 17:49:51 +0200
commit327a813b37ebc98d75e92ed03b0d14fa69915204 (patch)
tree87abf9f408e390af70e7de677fd31993b7d34b6e /src/code
parentfe8d5988b909e0c26c41933f8ee2044ca7580fc0 (diff)
Fix RaycastFloor flags (#1328)
* fix raycast floor flags * format.sh * Name flags * Rename RaycastFloor functions, clean up caller code, document z_bg_spot15_rrbox * change comment to prevent format wrap * change to "if BGCHECK_GROUND_CHECK_ON is set" * roman suggestions
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_actor.c24
-rw-r--r--src/code/z_bgcheck.c362
-rw-r--r--src/code/z_camera.c22
-rw-r--r--src/code/z_onepointdemo.c6
-rw-r--r--src/code/z_play.c16
-rw-r--r--src/code/z_player_lib.c2
6 files changed, 253 insertions, 179 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index ab310a446..9c71c3128 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -1168,13 +1168,13 @@ s32 func_8002E234(Actor* actor, f32 arg1, s32 arg2) {
return true;
}
-s32 func_8002E2AC(PlayState* play, Actor* actor, Vec3f* arg2, s32 arg3) {
+s32 func_8002E2AC(PlayState* play, Actor* actor, Vec3f* pos, s32 arg3) {
f32 floorHeightDiff;
s32 floorBgId;
- arg2->y += 50.0f;
+ pos->y += 50.0f;
- actor->floorHeight = BgCheck_EntityRaycastFloor5(play, &play->colCtx, &actor->floorPoly, &floorBgId, actor, arg2);
+ actor->floorHeight = BgCheck_EntityRaycastDown5(play, &play->colCtx, &actor->floorPoly, &floorBgId, actor, pos);
actor->bgCheckFlags &= ~(BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_GROUND_LEAVE | BGCHECKFLAG_GROUND_STRICT);
if (actor->floorHeight <= BGCHECK_Y_MIN) {
@@ -3472,9 +3472,9 @@ f32 func_80033AEC(Vec3f* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4, f32 ar
void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) {
MtxF sp60;
- f32 var;
- Vec3f sp50;
- CollisionPoly* sp4C;
+ f32 yIntersect;
+ Vec3f checkPos;
+ CollisionPoly* groundPoly;
OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 8120);
@@ -3484,14 +3484,14 @@ void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, alpha);
- sp50.x = arg0->x;
- sp50.y = arg0->y + 1.0f;
- sp50.z = arg0->z;
+ checkPos.x = arg0->x;
+ checkPos.y = arg0->y + 1.0f;
+ checkPos.z = arg0->z;
- var = BgCheck_EntityRaycastFloor2(play, &play->colCtx, &sp4C, &sp50);
+ yIntersect = BgCheck_EntityRaycastDown2(play, &play->colCtx, &groundPoly, &checkPos);
- if (sp4C != NULL) {
- func_80038A28(sp4C, arg0->x, var, arg0->z, &sp60);
+ if (groundPoly != NULL) {
+ func_80038A28(groundPoly, arg0->x, yIntersect, arg0->z, &sp60);
Matrix_Put(&sp60);
} else {
Matrix_Translate(arg0->x, arg0->y, arg0->z, MTXMODE_NEW);
diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c
index a52400b26..60260a4e1 100644
--- a/src/code/z_bgcheck.c
+++ b/src/code/z_bgcheck.c
@@ -1,6 +1,29 @@
#include "global.h"
#include "vt.h"
+u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* nodeList);
+void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector);
+s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos);
+s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB,
+ Vec3f* posResult, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 chkDist,
+ u32 bccFlags);
+void SSNodeList_Initialize(SSNodeList* this);
+void SSNodeList_Alloc(PlayState* play, SSNodeList* this, s32 tblMax, s32 numPolys);
+u16 SSNodeList_GetNextNodeIdx(SSNodeList* this);
+void DynaPoly_Init(PlayState* play, DynaCollisionContext* dyna);
+void DynaPoly_Alloc(PlayState* play, DynaCollisionContext* dyna);
+f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown);
+s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* outZ, Vec3f* pos, f32 radius,
+ CollisionPoly** outPoly, s32* outBgId, Actor* actor);
+s32 BgCheck_CheckDynaCeiling(CollisionContext* colCtx, u16 xpFlags, f32* outY, Vec3f* pos, f32 chkDist,
+ CollisionPoly** outPoly, s32* outBgId, Actor* actor);
+s32 BgCheck_CheckLineAgainstDyna(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
+ CollisionPoly** outPoly, f32* distSq, s32* outBgId, Actor* actor, f32 chkDist,
+ s32 bccFlags);
+s32 BgCheck_SphVsFirstDynaPoly(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId,
+ Vec3f* center, f32 radius, Actor* actor, u16 bciFlags);
+void BgCheck_ResetPolyCheckTbl(SSNodeList* nodeList, s32 numPolys);
+
#define SS_NULL 0xFFFF
// bccFlags
@@ -24,6 +47,16 @@
#define COLPOLY_IGNORE_ENTITY (1 << 1)
#define COLPOLY_IGNORE_PROJECTILES (1 << 2)
+// raycast down flags (downChkFlags)
+#define BGCHECK_RAYCAST_DOWN_CHECK_CEILINGS (1 << 0)
+#define BGCHECK_RAYCAST_DOWN_CHECK_WALLS (1 << 1)
+#define BGCHECK_RAYCAST_DOWN_CHECK_FLOORS (1 << 2)
+#define BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE (1 << 3) // stops checking dyna walls on finding first candidate result
+#define BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY (1 << 4) // skips walls and ceilings with normal.y < 0
+
+// raycast down groundChk flag. When enabled, search range is limited to floors and walls with a normal.y >= 0
+#define BGCHECK_GROUND_CHECK_ON (1 << 0)
+
s32 D_80119D90[WALL_TYPE_MAX] = {
0, // WALL_TYPE_0
WALL_FLAG_0, // WALL_TYPE_1
@@ -527,10 +560,10 @@ void StaticLookup_AddPoly(StaticLookup* lookup, CollisionContext* colCtx, Collis
* Locates the closest static poly directly underneath `pos`, starting at list `ssList`
* returns yIntersect of the closest poly, or `yIntersectMin`
* stores the pointer of the closest poly to `outPoly`
- * if (flags & 1), ignore polys with a normal.y < 0 (from vertical walls to ceilings)
+ * if BGCHECK_GROUND_CHECK_ON is set, ignore polys with a normal.y < 0 (from vertical walls to ceilings)
*/
-f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList* ssList, CollisionPoly** outPoly,
- Vec3f* pos, f32 yIntersectMin, f32 chkDist, s32 flags) {
+f32 BgCheck_RaycastDownStaticList(CollisionContext* colCtx, u16 xpFlags, SSList* ssList, CollisionPoly** outPoly,
+ Vec3f* pos, f32 yIntersectMin, f32 chkDist, s32 groundChk) {
SSNode* curNode;
s32 polyId;
f32 result;
@@ -547,7 +580,7 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList
polyId = curNode->polyId;
if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[polyId].flags_vIA, xpFlags) ||
- ((flags & 1) && colCtx->colHeader->polyList[polyId].normal.y < 0)) {
+ ((groundChk & BGCHECK_GROUND_CHECK_ON) && colCtx->colHeader->polyList[polyId].normal.y < 0)) {
if (curNode->next == SS_NULL) {
break;
}
@@ -565,7 +598,6 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList
pos->z, &yIntersect, chkDist) == true) {
// if poly is closer to pos without going over
if (yIntersect < pos->y && result < yIntersect) {
-
result = yIntersect;
*outPoly = &colCtx->colHeader->polyList[polyId];
}
@@ -584,31 +616,31 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList
* returns yIntersect of the closest poly, or `yIntersectMin`
* stores the pointer of the closest poly to `outPoly`
*/
-f32 BgCheck_RaycastFloorStatic(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** poly,
- Vec3f* pos, u32 arg5, f32 chkDist, f32 yIntersectMin) {
- s32 flag; // skip polys with normal.y < 0
+f32 BgCheck_RaycastDownStatic(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** poly,
+ Vec3f* pos, u32 downChkFlags, f32 chkDist, f32 yIntersectMin) {
f32 yIntersect = yIntersectMin;
+ s32 groundChk;
- if (arg5 & 4) {
- yIntersect = BgCheck_RaycastFloorStaticList(colCtx, xpFlags, &lookup->floor, poly, pos, yIntersect, chkDist, 0);
+ if (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_FLOORS) {
+ yIntersect = BgCheck_RaycastDownStaticList(colCtx, xpFlags, &lookup->floor, poly, pos, yIntersect, chkDist, 0);
}
- if ((arg5 & 2) || (arg5 & 8)) {
- flag = 0;
- if (arg5 & 0x10) {
- flag = 1;
+ if ((downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_WALLS) || (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE)) {
+ groundChk = 0;
+ if (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY) {
+ groundChk |= BGCHECK_GROUND_CHECK_ON;
}
yIntersect =
- BgCheck_RaycastFloorStaticList(colCtx, xpFlags, &lookup->wall, poly, pos, yIntersect, chkDist, flag);
+ BgCheck_RaycastDownStaticList(colCtx, xpFlags, &lookup->wall, poly, pos, yIntersect, chkDist, groundChk);
}
- if (arg5 & 1) {
- flag = 0;
- if (arg5 & 0x10) {
- flag = 1;
+ if (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_CEILINGS) {
+ groundChk = 0;
+ if (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY) {
+ groundChk |= BGCHECK_GROUND_CHECK_ON;
}
yIntersect =
- BgCheck_RaycastFloorStaticList(colCtx, xpFlags, &lookup->ceiling, poly, pos, yIntersect, chkDist, flag);
+ BgCheck_RaycastDownStaticList(colCtx, xpFlags, &lookup->ceiling, poly, pos, yIntersect, chkDist, groundChk);
}
return yIntersect;
@@ -1662,19 +1694,19 @@ s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos) {
}
/**
- * Raycast Toward Floor
+ * Raycast Downward
+ * If `actor` != null, bgcheck will be skipped for that actor
* returns the yIntersect of the nearest poly found directly below `pos`, or BGCHECK_Y_MIN if no floor detected
* returns the poly found in `outPoly`, and the bgId of the entity in `outBgId`
*/
-f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly,
- s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 chkDist) {
-
+f32 BgCheck_RaycastDownImpl(PlayState* play, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly,
+ s32* outBgId, Vec3f* pos, Actor* actor, u32 downChkFlags, f32 chkDist) {
f32 yIntersectDyna;
s32* temp_a0;
StaticLookup* lookupTbl;
Vec3f checkPos;
StaticLookup* lookup;
- DynaRaycast dynaRaycast;
+ DynaRaycastDown dynaRaycastDown;
f32 yIntersect;
*outBgId = BGCHECK_SCENE;
@@ -1697,25 +1729,26 @@ f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFl
checkPos.y -= colCtx->subdivLength.y;
continue;
}
- yIntersect = BgCheck_RaycastFloorStatic(lookup, colCtx, xpFlags, outPoly, pos, arg7, chkDist, BGCHECK_Y_MIN);
+ yIntersect =
+ BgCheck_RaycastDownStatic(lookup, colCtx, xpFlags, outPoly, pos, downChkFlags, chkDist, BGCHECK_Y_MIN);
if (yIntersect > BGCHECK_Y_MIN) {
break;
}
checkPos.y -= colCtx->subdivLength.y;
}
- dynaRaycast.colCtx = colCtx;
- dynaRaycast.xpFlags = xpFlags;
- dynaRaycast.yIntersect = yIntersect;
- dynaRaycast.pos = pos;
- dynaRaycast.actor = actor;
- dynaRaycast.unk_20 = arg7;
- dynaRaycast.chkDist = chkDist;
- dynaRaycast.play = play;
- dynaRaycast.resultPoly = outPoly;
- dynaRaycast.bgId = outBgId;
+ dynaRaycastDown.colCtx = colCtx;
+ dynaRaycastDown.xpFlags = xpFlags;
+ dynaRaycastDown.yIntersect = yIntersect;
+ dynaRaycastDown.pos = pos;
+ dynaRaycastDown.actor = actor;
+ dynaRaycastDown.downChkFlags = downChkFlags;
+ dynaRaycastDown.chkDist = chkDist;
+ dynaRaycastDown.play = play;
+ dynaRaycastDown.resultPoly = outPoly;
+ dynaRaycastDown.bgId = outBgId;
- yIntersectDyna = BgCheck_RaycastFloorDyna(&dynaRaycast);
+ yIntersectDyna = BgCheck_RaycastDownDyna(&dynaRaycastDown);
if (yIntersect < yIntersectDyna) {
yIntersect = yIntersectDyna;
@@ -1728,133 +1761,171 @@ f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFl
}
/**
- * Public raycast toward floor
+ * Public raycast downward, ground check (UNUSED)
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_CameraRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) {
+f32 BgCheck_CameraRaycastDown1(CollisionContext* colCtx, CollisionPoly** outGroundPoly, Vec3f* pos) {
s32 bgId;
- return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_CAMERA, outPoly, &bgId, pos, NULL, 0x1C, 1.0f);
+ return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_CAMERA, outGroundPoly, &bgId, pos, NULL,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
+ BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
+ 1.0f);
}
/**
- * Public raycast toward floor
+ * Public raycast downward, ground check
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) {
+f32 BgCheck_EntityRaycastDown1(CollisionContext* colCtx, CollisionPoly** outGroundPoly, Vec3f* pos) {
s32 bgId;
- return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f);
+ return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outGroundPoly, &bgId, pos, NULL,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
+ BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
+ 1.0f);
}
/**
- * Public raycast toward floor
+ * Public raycast downward, ground check
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_EntityRaycastFloor2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) {
+f32 BgCheck_EntityRaycastDown2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outGroundPoly, Vec3f* pos) {
s32 bgId;
- return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f);
+ return BgCheck_RaycastDownImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outGroundPoly, &bgId, pos, NULL,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
+ BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
+ 1.0f);
}
/**
- * Public raycast toward floor
+ * Public raycast downward, ground check
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_EntityRaycastFloor3(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) {
- return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, NULL, 0x1C, 1.0f);
+f32 BgCheck_EntityRaycastDown3(CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId, Vec3f* pos) {
+ return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outGroundPoly, bgId, pos, NULL,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
+ BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
+ 1.0f);
}
/**
- * Public raycast toward floor
+ * Public raycast downward, ground check
+ * If `actor` != null, bgcheck will be skipped for that actor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_EntityRaycastFloor4(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor,
- Vec3f* pos) {
- return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f);
+f32 BgCheck_EntityRaycastDown4(CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId, Actor* actor,
+ Vec3f* pos) {
+ return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outGroundPoly, bgId, pos, actor,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
+ BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
+ 1.0f);
}
/**
- * Public raycast toward floor
+ * Public raycast downward, ground check
+ * If `actor` != null, bgcheck will be skipped for that actor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_EntityRaycastFloor5(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId,
- Actor* actor, Vec3f* pos) {
- return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f);
+f32 BgCheck_EntityRaycastDown5(PlayState* play, CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId,
+ Actor* actor, Vec3f* pos) {
+ return BgCheck_RaycastDownImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outGroundPoly, bgId, pos, actor,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
+ BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
+ 1.0f);
}
/**
- * Public raycast toward floor
+ * Public raycast downward, ground check
+ * If `actor` != null, bgcheck will be skipped for that actor
+ * `chkDist` is the distance beyond the poly's boundary where the check will still pass
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_EntityRaycastFloor6(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos,
- f32 chkDist) {
- return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, chkDist);
+f32 BgCheck_EntityRaycastDown6(CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId, Actor* actor,
+ Vec3f* pos, f32 chkDist) {
+ return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outGroundPoly, bgId, pos, actor,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
+ BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
+ chkDist);
}
/**
- * Public raycast toward floor
+ * Public raycast downward, floor and exhaustive wall check (UNUSED)
+ * If `actor` != null, bgcheck will be skipped for that actor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_EntityRaycastFloor7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor,
- Vec3f* pos) {
- return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x06, 1.0f);
+f32 BgCheck_EntityRaycastDown7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos) {
+ return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS, 1.0f);
}
/**
- * Public raycast toward floor
+ * Public raycast downward, ground check
+ * `outGroundPoly` returns original value if no poly detected
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_AnyRaycastFloor1(CollisionContext* colCtx, CollisionPoly* outPoly, Vec3f* pos) {
- CollisionPoly* tempPoly;
+f32 BgCheck_AnyRaycastDown1(CollisionContext* colCtx, CollisionPoly* outGroundPoly, Vec3f* pos) {
+ CollisionPoly* checkResultPoly;
f32 result;
s32 bgId;
- result = BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &tempPoly, &bgId, pos, NULL, 0x1C, 1.0f);
+ result = BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &checkResultPoly, &bgId, pos, NULL,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
+ BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
+ 1.0f);
- if (tempPoly != NULL) {
- *outPoly = *tempPoly;
+ if (checkResultPoly != NULL) {
+ *outGroundPoly = *checkResultPoly;
}
return result;
}
/**
- * Public raycast toward floor
+ * Public raycast downward, ground check (UNUSED)
+ * `outGroundPoly` returns original value if no poly detected
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_AnyRaycastFloor2(CollisionContext* colCtx, CollisionPoly* outPoly, s32* bgId, Vec3f* pos) {
- CollisionPoly* tempPoly;
- f32 result = BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &tempPoly, bgId, pos, NULL, 0x1C, 1.0f);
+f32 BgCheck_AnyRaycastDown2(CollisionContext* colCtx, CollisionPoly* outGroundPoly, s32* bgId, Vec3f* pos) {
+ CollisionPoly* checkResultPoly;
+ f32 result = BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &checkResultPoly, bgId, pos, NULL,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
+ BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
+ 1.0f);
- if (tempPoly != NULL) {
- *outPoly = *tempPoly;
+ if (checkResultPoly != NULL) {
+ *outGroundPoly = *checkResultPoly;
}
return result;
}
/**
- * Public raycast toward floor
+ * Public raycast downward, floor and exhaustive wall check
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_CameraRaycastFloor2(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) {
- return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_CAMERA, outPoly, bgId, pos, NULL, 0x06, 1.0f);
+f32 BgCheck_CameraRaycastDown2(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) {
+ return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_CAMERA, outPoly, bgId, pos, NULL,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS, 1.0f);
}
/**
- * Public raycast toward floor
+ * Public raycast downward, exhaustive wall check (UNUSED)
+ * If `actor` != null, bgcheck will be skipped for that actor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_EntityRaycastFloor8(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor,
- Vec3f* pos) {
- return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x02, 1.0f);
+f32 BgCheck_EntityRaycastDownWalls(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor,
+ Vec3f* pos) {
+ return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS, 1.0f);
}
/**
- * Public raycast toward floor
+ * Public raycast downward, floor and exhaustive wall check (UNUSED)
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_EntityRaycastFloor9(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) {
- return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, NULL, 0x06, 1.0f);
+f32 BgCheck_EntityRaycastDown9(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) {
+ return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, NULL,
+ BGCHECK_RAYCAST_DOWN_CHECK_WALLS | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS, 1.0f);
}
/**
@@ -3014,52 +3085,54 @@ void DynaPoly_UpdateBgActorTransforms(PlayState* play, DynaCollisionContext* dyn
#define DYNA_RAYCAST_CEILINGS 4
/**
- * Perform dyna poly raycast toward floor on a list of floor, wall, or ceiling polys
+ * Performs a downward raycast check on a list of floor, wall, or ceiling dyna polys
* `listType` specifies the poly list type (e.g. DYNA_RAYCAST_FLOORS)
*/
-f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) {
+f32 BgCheck_RaycastDownDynaList(DynaRaycastDown* dynaRaycastDown, u32 listType) {
CollisionPoly* polyList;
SSNode* curNode;
f32 result;
f32 yIntersect;
s16 id;
- result = dynaRaycast->yIntersect;
- if (dynaRaycast->ssList->head == SS_NULL) {
+ result = dynaRaycastDown->yIntersect;
+ if (dynaRaycastDown->ssList->head == SS_NULL) {
return result;
}
- polyList = dynaRaycast->dyna->polyList;
- curNode = &dynaRaycast->dyna->polyNodes.tbl[dynaRaycast->ssList->head];
+ polyList = dynaRaycastDown->dyna->polyList;
+ curNode = &dynaRaycastDown->dyna->polyNodes.tbl[dynaRaycastDown->ssList->head];
while (true) {
id = curNode->polyId;
- if (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIA, dynaRaycast->xpFlags)) {
+ if (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIA, dynaRaycastDown->xpFlags)) {
if (curNode->next == SS_NULL) {
break;
} else {
- curNode = &dynaRaycast->dyna->polyNodes.tbl[curNode->next];
+ curNode = &dynaRaycastDown->dyna->polyNodes.tbl[curNode->next];
continue;
}
}
- if ((listType & (DYNA_RAYCAST_WALLS | DYNA_RAYCAST_CEILINGS)) && (dynaRaycast->unk_20 & 0x10) &&
+ if ((listType & (DYNA_RAYCAST_WALLS | DYNA_RAYCAST_CEILINGS)) &&
+ (dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY) &&
COLPOLY_GET_NORMAL(polyList[id].normal.y) < 0.0f) {
if (curNode->next == SS_NULL) {
break;
} else {
- curNode = &dynaRaycast->dyna->polyNodes.tbl[curNode->next];
+ curNode = &dynaRaycastDown->dyna->polyNodes.tbl[curNode->next];
continue;
}
}
- if (CollisionPoly_CheckYIntersectApprox1(&polyList[id], dynaRaycast->dyna->vtxList, dynaRaycast->pos->x,
- dynaRaycast->pos->z, &yIntersect, dynaRaycast->chkDist) == true &&
- yIntersect < dynaRaycast->pos->y && result < yIntersect) {
+ if (CollisionPoly_CheckYIntersectApprox1(&polyList[id], dynaRaycastDown->dyna->vtxList, dynaRaycastDown->pos->x,
+ dynaRaycastDown->pos->z, &yIntersect,
+ dynaRaycastDown->chkDist) == true &&
+ yIntersect < dynaRaycastDown->pos->y && result < yIntersect) {
result = yIntersect;
- *dynaRaycast->resultPoly = &dynaRaycast->dyna->polyList[id];
+ *dynaRaycastDown->resultPoly = &dynaRaycastDown->dyna->polyList[id];
}
if (curNode->next == SS_NULL) {
break;
} else {
- curNode = &dynaRaycast->dyna->polyNodes.tbl[curNode->next];
+ curNode = &dynaRaycastDown->dyna->polyNodes.tbl[curNode->next];
continue;
}
}
@@ -3067,10 +3140,10 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) {
}
/**
- * Perform dyna poly raycast toward floor
+ * Performs a downward raycast check on dyna polys
* returns the yIntersect of the poly found, or BGCHECK_Y_MIN if no poly is found
*/
-f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) {
+f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown) {
s32 i;
f32 result;
f32 intersect2;
@@ -3092,75 +3165,76 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) {
CollisionPoly* poly;
result = BGCHECK_Y_MIN;
- *dynaRaycast->bgId = BGCHECK_SCENE;
+ *dynaRaycastDown->bgId = BGCHECK_SCENE;
for (i = 0; i < BG_ACTOR_MAX; i++) {
- if (!(dynaRaycast->colCtx->dyna.bgActorFlags[i] & BGACTOR_IN_USE)) {
+ if (!(dynaRaycastDown->colCtx->dyna.bgActorFlags[i] & BGACTOR_IN_USE)) {
continue;
}
- if (dynaRaycast->actor == dynaRaycast->colCtx->dyna.bgActors[i].actor ||
- dynaRaycast->pos->y < dynaRaycast->colCtx->dyna.bgActors[i].minY ||
- Math3D_XZInSphere(&dynaRaycast->colCtx->dyna.bgActors[i].boundingSphere, dynaRaycast->pos->x,
- dynaRaycast->pos->z) == false) {
+ if (dynaRaycastDown->actor == dynaRaycastDown->colCtx->dyna.bgActors[i].actor ||
+ dynaRaycastDown->pos->y < dynaRaycastDown->colCtx->dyna.bgActors[i].minY ||
+ Math3D_XZInSphere(&dynaRaycastDown->colCtx->dyna.bgActors[i].boundingSphere, dynaRaycastDown->pos->x,
+ dynaRaycastDown->pos->z) == false) {
continue;
}
- dynaRaycast->dyna = &dynaRaycast->colCtx->dyna;
- if (dynaRaycast->unk_20 & BGCHECK_IGNORE_FLOOR) {
- dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.floor;
- intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_FLOORS);
-
- if (dynaRaycast->yIntersect < intersect2) {
+ dynaRaycastDown->dyna = &dynaRaycastDown->colCtx->dyna;
+ if (dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_FLOORS) {
+ dynaRaycastDown->ssList = &dynaRaycastDown->colCtx->dyna.bgActors[i].dynaLookup.floor;
+ intersect2 = BgCheck_RaycastDownDynaList(dynaRaycastDown, DYNA_RAYCAST_FLOORS);
- dynaRaycast->yIntersect = intersect2;
- *dynaRaycast->bgId = i;
+ if (dynaRaycastDown->yIntersect < intersect2) {
+ dynaRaycastDown->yIntersect = intersect2;
+ *dynaRaycastDown->bgId = i;
result = intersect2;
}
}
- if ((dynaRaycast->unk_20 & BGCHECK_IGNORE_WALL) ||
- (*dynaRaycast->resultPoly == NULL && (dynaRaycast->unk_20 & 8))) {
- dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.wall;
- intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_WALLS);
- if (dynaRaycast->yIntersect < intersect2) {
+ if ((dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_WALLS) ||
+ (*dynaRaycastDown->resultPoly == NULL &&
+ (dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE))) {
+ dynaRaycastDown->ssList = &dynaRaycastDown->colCtx->dyna.bgActors[i].dynaLookup.wall;
+ intersect2 = BgCheck_RaycastDownDynaList(dynaRaycastDown, DYNA_RAYCAST_WALLS);
- dynaRaycast->yIntersect = intersect2;
- *dynaRaycast->bgId = i;
+ if (dynaRaycastDown->yIntersect < intersect2) {
+ dynaRaycastDown->yIntersect = intersect2;
+ *dynaRaycastDown->bgId = i;
result = intersect2;
}
}
- if (dynaRaycast->unk_20 & BGCHECK_IGNORE_CEILING) {
- dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.ceiling;
- intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_CEILINGS);
- if (dynaRaycast->yIntersect < intersect2) {
+ if (dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_CEILINGS) {
+ dynaRaycastDown->ssList = &dynaRaycastDown->colCtx->dyna.bgActors[i].dynaLookup.ceiling;
+ intersect2 = BgCheck_RaycastDownDynaList(dynaRaycastDown, DYNA_RAYCAST_CEILINGS);
- dynaRaycast->yIntersect = intersect2;
- *dynaRaycast->bgId = i;
+ if (dynaRaycastDown->yIntersect < intersect2) {
+ dynaRaycastDown->yIntersect = intersect2;
+ *dynaRaycastDown->bgId = i;
result = intersect2;
}
}
}
- dynaActor = DynaPoly_GetActor(dynaRaycast->colCtx, *dynaRaycast->bgId);
- if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->play != NULL)) {
- pauseState = dynaRaycast->play->pauseCtx.state != 0;
+ dynaActor = DynaPoly_GetActor(dynaRaycastDown->colCtx, *dynaRaycastDown->bgId);
+ if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycastDown->play != NULL)) {
+ pauseState = dynaRaycastDown->play->pauseCtx.state != 0;
if (pauseState == 0) {
- pauseState = dynaRaycast->play->pauseCtx.debugState != 0;
+ pauseState = dynaRaycastDown->play->pauseCtx.debugState != 0;
}
- if (!pauseState && (dynaRaycast->colCtx->dyna.bgActorFlags[*dynaRaycast->bgId] & BGACTOR_1)) {
- curTransform = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].curTransform;
+ if (!pauseState && (dynaRaycastDown->colCtx->dyna.bgActorFlags[*dynaRaycastDown->bgId] & BGACTOR_1)) {
+ curTransform = &dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].curTransform;
polyMin =
- &dynaRaycast->dyna->polyList[dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].dynaLookup.polyStartIndex];
- polyIndex = *dynaRaycast->resultPoly - polyMin;
- poly = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].colHeader->polyList[polyIndex];
+ &dynaRaycastDown->dyna
+ ->polyList[dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].dynaLookup.polyStartIndex];
+ polyIndex = *dynaRaycastDown->resultPoly - polyMin;
+ poly = &dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].colHeader->polyList[polyIndex];
SkinMatrix_SetTranslateRotateYXZScale(&srpMtx, curTransform->scale.x, curTransform->scale.y,
curTransform->scale.z, curTransform->rot.x, curTransform->rot.y,
curTransform->rot.z, curTransform->pos.x, curTransform->pos.y,
curTransform->pos.z);
- vtxList = dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].colHeader->vtxList;
+ vtxList = dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].colHeader->vtxList;
for (i2 = 0; i2 < 3; i2++) {
Math_Vec3s_ToVec3f(&vtx, &vtxList[COLPOLY_VTX_INDEX(poly->vtxData[i2])]);
@@ -3174,9 +3248,9 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) {
polyNorm.y *= 1.0f / magnitude;
polyNorm.z *= 1.0f / magnitude;
polyDist = -DOTXYZ(polyNorm, polyVtx[0]);
- if (Math3D_TriChkPointParaYIntersectInsideTri(&polyVtx[0], &polyVtx[1], &polyVtx[2], polyNorm.x,
- polyNorm.y, polyNorm.z, polyDist, dynaRaycast->pos->z,
- dynaRaycast->pos->x, &intersect, dynaRaycast->chkDist)) {
+ if (Math3D_TriChkPointParaYIntersectInsideTri(
+ &polyVtx[0], &polyVtx[1], &polyVtx[2], polyNorm.x, polyNorm.y, polyNorm.z, polyDist,
+ dynaRaycastDown->pos->z, dynaRaycastDown->pos->x, &intersect, dynaRaycastDown->chkDist)) {
if (fabsf(intersect - result) < 1.0f) {
result = intersect;
diff --git a/src/code/z_camera.c b/src/code/z_camera.c
index 49d260152..89db13211 100644
--- a/src/code/z_camera.c
+++ b/src/code/z_camera.c
@@ -233,7 +233,7 @@ s32 Camera_BGCheckInfo(Camera* camera, Vec3f* from, CamColChk* to) {
toNewPos = to->pos;
toNewPos.y += 5.0f;
- floorPolyY = BgCheck_CameraRaycastFloor2(colCtx, &floorPoly, &floorBgId, &toNewPos);
+ floorPolyY = BgCheck_CameraRaycastDown2(colCtx, &floorPoly, &floorBgId, &toNewPos);
if ((to->pos.y - floorPolyY) > 5.0f) {
// if the y distance from the check point to the floor is more than 5 units
@@ -293,7 +293,7 @@ s32 func_80043F94(Camera* camera, Vec3f* from, CamColChk* to) {
to->norm.z = -fromToNorm.z;
toNewPos = to->pos;
toNewPos.y += 5.0f;
- floorY = BgCheck_CameraRaycastFloor2(colCtx, &floorPoly, &bgId, &toNewPos);
+ floorY = BgCheck_CameraRaycastDown2(colCtx, &floorPoly, &bgId, &toNewPos);
if ((to->pos.y - floorY) > 5.0f) {
// to is not on the ground or below it.
to->pos.x += to->norm.x;
@@ -377,7 +377,7 @@ s32 Camera_CheckOOB(Camera* camera, Vec3f* from, Vec3f* to) {
f32 Camera_GetFloorYNorm(Camera* camera, Vec3f* floorNorm, Vec3f* chkPos, s32* bgId) {
s32 pad;
CollisionPoly* floorPoly;
- f32 floorY = BgCheck_EntityRaycastFloor3(&camera->play->colCtx, &floorPoly, bgId, chkPos);
+ f32 floorY = BgCheck_EntityRaycastDown3(&camera->play->colCtx, &floorPoly, bgId, chkPos);
if (floorY == BGCHECK_Y_MIN) {
// no floor
@@ -418,7 +418,7 @@ f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, s32* bgId) {
s32 i;
for (i = 3; i > 0; i--) {
- floorY = BgCheck_CameraRaycastFloor2(colCtx, &floorPoly, bgId, pos);
+ floorY = BgCheck_CameraRaycastDown2(colCtx, &floorPoly, bgId, pos);
if (floorY == BGCHECK_Y_MIN ||
(camera->playerGroundY < floorY && !(COLPOLY_GET_NORMAL(floorPoly->normal.y) > 0.5f))) {
// no floor, or player is below the floor and floor is not considered steep
@@ -492,7 +492,7 @@ Vec3s* Camera_GetBgCamFuncDataUnderPlayer(Camera* camera, u16* bgCamCount) {
Actor_GetWorldPosShapeRot(&playerPosShape, &camera->player->actor);
playerPosShape.pos.y += Player_GetHeight(camera->player);
- if (BgCheck_EntityRaycastFloor3(&camera->play->colCtx, &floorPoly, &bgId, &playerPosShape.pos) == BGCHECK_Y_MIN) {
+ if (BgCheck_EntityRaycastDown3(&camera->play->colCtx, &floorPoly, &bgId, &playerPosShape.pos) == BGCHECK_Y_MIN) {
// no floor
return NULL;
}
@@ -3647,7 +3647,7 @@ s32 Camera_KeepOn4(Camera* camera) {
OLib_Vec3fDiffToVecSphGeo(&spA8, at, eyeNext);
D_8015BD50 = playerPosRot->pos;
D_8015BD50.y += playerHeight;
- temp_f0_2 = BgCheck_CameraRaycastFloor2(&camera->play->colCtx, &spC0, &i, &D_8015BD50);
+ temp_f0_2 = BgCheck_CameraRaycastDown2(&camera->play->colCtx, &spC0, &i, &D_8015BD50);
if (temp_f0_2 > (roData->unk_00 + D_8015BD50.y)) {
D_8015BD50.y = temp_f0_2 + 10.0f;
} else {
@@ -7407,7 +7407,7 @@ Vec3s Camera_Update(Camera* camera) {
Vec3f viewEye;
Vec3f viewUp;
f32 viewFov;
- Vec3f spAC;
+ Vec3f pos;
s32 bgId;
f32 playerGroundY;
f32 playerXZSpeed;
@@ -7441,11 +7441,11 @@ Vec3s Camera_Update(Camera* camera) {
camera->playerPosDelta.x = curPlayerPosRot.pos.x - camera->playerPosRot.pos.x;
camera->playerPosDelta.y = curPlayerPosRot.pos.y - camera->playerPosRot.pos.y;
camera->playerPosDelta.z = curPlayerPosRot.pos.z - camera->playerPosRot.pos.z;
- spAC = curPlayerPosRot.pos;
- spAC.y += Player_GetHeight(camera->player);
+ pos = curPlayerPosRot.pos;
+ pos.y += Player_GetHeight(camera->player);
- playerGroundY = BgCheck_EntityRaycastFloor5(camera->play, &camera->play->colCtx, &playerFloorPoly, &bgId,
- &camera->player->actor, &spAC);
+ playerGroundY = BgCheck_EntityRaycastDown5(camera->play, &camera->play->colCtx, &playerFloorPoly, &bgId,
+ &camera->player->actor, &pos);
if (playerGroundY != BGCHECK_Y_MIN) {
// player is above ground.
sOOBTimer = 0;
diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c
index 0f61caee1..9750aa21e 100644
--- a/src/code/z_onepointdemo.c
+++ b/src/code/z_onepointdemo.c
@@ -39,11 +39,11 @@ s32 OnePointCutscene_BgCheckLineTest(CollisionContext* colCtx, Vec3f* vec1, Vec3
return BgCheck_CameraLineTest1(colCtx, vec1, vec2, &posResult, &outPoly, true, true, true, false, &bgId);
}
-f32 OnePointCutscene_RaycastFloor(CollisionContext* colCtx, Vec3f* pos) {
+f32 OnePointCutscene_RaycastDown(CollisionContext* colCtx, Vec3f* pos) {
CollisionPoly* outPoly;
s32 bgId;
- return BgCheck_EntityRaycastFloor3(colCtx, &outPoly, &bgId, pos);
+ return BgCheck_EntityRaycastDown3(colCtx, &outPoly, &bgId, pos);
}
void OnePointCutscene_SetCsCamPoints(Camera* camera, s16 actionParameters, s16 initTimer, CutsceneCameraPoint* atPoints,
@@ -292,7 +292,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act
case 4500:
Actor_GetFocus(&spA0, actor);
spC0 = spA0.pos;
- spC0.y = OnePointCutscene_RaycastFloor(&play->colCtx, &spC0) + 40.0f;
+ spC0.y = OnePointCutscene_RaycastDown(&play->colCtx, &spC0) + 40.0f;
spD0.r = 150.0f;
spD0.yaw = spA0.rot.y;
spD0.pitch = 0x3E8;
diff --git a/src/code/z_play.c b/src/code/z_play.c
index 3f79dc66f..33013a2e5 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -1315,7 +1315,7 @@ s32 Play_InCsMode(PlayState* this) {
return (this->csCtx.state != CS_STATE_IDLE) || Player_InCsMode(this);
}
-f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* vec) {
+f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* pos) {
CollisionPoly poly;
f32 temp1;
f32 temp2;
@@ -1326,7 +1326,7 @@ f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* vec) {
f32 nz;
s32 pad[5];
- floorY = BgCheck_AnyRaycastFloor1(&this->colCtx, &poly, vec);
+ floorY = BgCheck_AnyRaycastDown1(&this->colCtx, &poly, pos);
if (floorY > BGCHECK_Y_MIN) {
nx = COLPOLY_GET_NORMAL(poly.normal.x);
@@ -1355,9 +1355,9 @@ f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* vec) {
mf->wy = 0.0f;
mf->xz = 0.0f;
mf->wz = 0.0f;
- mf->xw = vec->x;
+ mf->xw = pos->x;
mf->yw = floorY;
- mf->zw = vec->z;
+ mf->zw = pos->z;
mf->ww = 1.0f;
} else {
mf->xy = 0.0f;
@@ -1372,9 +1372,9 @@ f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* vec) {
mf->yz = 0.0f;
mf->zy = 0.0f;
mf->yy = 1.0f;
- mf->xw = vec->x;
- mf->yw = vec->y;
- mf->zw = vec->z;
+ mf->xw = pos->x;
+ mf->yw = pos->y;
+ mf->zw = pos->z;
mf->ww = 1.0f;
}
@@ -1776,7 +1776,7 @@ s32 func_800C0DB4(PlayState* this, Vec3f* pos) {
if (WaterBox_GetSurface1(this, &this->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y,
&waterBox) == true &&
pos->y < waterSurfacePos.y &&
- BgCheck_EntityRaycastFloor3(&this->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN) {
+ BgCheck_EntityRaycastDown3(&this->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN) {
return true;
} else {
return false;
diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c
index 928fe3333..5563096ea 100644
--- a/src/code/z_player_lib.c
+++ b/src/code/z_player_lib.c
@@ -997,7 +997,7 @@ void func_8008F87C(PlayState* play, Player* this, SkelAnime* skelAnime, Vec3f* p
footprintPos.y += 15.0f;
- sp80 = BgCheck_EntityRaycastFloor4(&play->colCtx, &sp88, &sp84, &this->actor, &footprintPos) + sp74;
+ sp80 = BgCheck_EntityRaycastDown4(&play->colCtx, &sp88, &sp84, &this->actor, &footprintPos) + sp74;
if (sp98.y < sp80) {
sp70 = sp98.x - spA4.x;