1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-03 14:34:32 +00:00

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
This commit is contained in:
mzxrules 2022-08-30 11:49:51 -04:00 committed by GitHub
parent fe8d5988b9
commit 327a813b37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 497 additions and 451 deletions

View file

@ -534,35 +534,25 @@ s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* tors
void ActorOverlayTable_LogPrint(void); void ActorOverlayTable_LogPrint(void);
void ActorOverlayTable_Init(void); void ActorOverlayTable_Init(void);
void ActorOverlayTable_Cleanup(void); void ActorOverlayTable_Cleanup(void);
u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* nodeList);
void func_80038A28(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest); void func_80038A28(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest);
f32 CollisionPoly_GetPointDistanceFromPlane(CollisionPoly* poly, Vec3f* point); f32 CollisionPoly_GetPointDistanceFromPlane(CollisionPoly* poly, Vec3f* point);
void CollisionPoly_GetVerticesByBgId(CollisionPoly* poly, s32 bgId, CollisionContext* colCtx, Vec3f* dest); void CollisionPoly_GetVerticesByBgId(CollisionPoly* poly, s32 bgId, CollisionContext* colCtx, Vec3f* dest);
s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionContext* colCtx, f32* outY, Vec3f* pos,
f32 checkHeight, CollisionPoly** outPoly);
s32 BgCheck_CheckLineAgainstSSList(SSList* ssList, CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA,
Vec3f* posB, Vec3f* outPos, CollisionPoly** outPoly, f32* outDistSq, f32 chkDist,
s32 bccFlags);
void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector);
void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader* colHeader); void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader* colHeader);
s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos); f32 BgCheck_EntityRaycastDown1(CollisionContext* colCtx, CollisionPoly** outGroundPoly, Vec3f* pos);
f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); f32 BgCheck_EntityRaycastDown2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outGroundPoly, Vec3f* pos);
f32 BgCheck_EntityRaycastFloor2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, f32 BgCheck_EntityRaycastDown3(CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId, Vec3f* pos);
f32 BgCheck_EntityRaycastDown4(CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId, Actor* actor,
Vec3f* pos); Vec3f* pos);
f32 BgCheck_EntityRaycastFloor3(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos); f32 BgCheck_EntityRaycastDown5(PlayState* play, CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId,
f32 BgCheck_EntityRaycastFloor4(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos);
f32 BgCheck_EntityRaycastFloor5(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId,
Actor* actor, Vec3f* pos); Actor* actor, Vec3f* pos);
f32 BgCheck_EntityRaycastFloor6(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos, f32 BgCheck_EntityRaycastDown6(CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId, Actor* actor,
f32 chkDist); Vec3f* pos, f32 chkDist);
f32 BgCheck_EntityRaycastFloor7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); f32 BgCheck_EntityRaycastDown7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos);
f32 BgCheck_AnyRaycastFloor1(CollisionContext* colCtx, CollisionPoly* outPoly, Vec3f* pos); f32 BgCheck_AnyRaycastDown1(CollisionContext* colCtx, CollisionPoly* outGroundPoly, Vec3f* pos);
f32 BgCheck_AnyRaycastFloor2(CollisionContext* colCtx, CollisionPoly* outPoly, s32* bgId, Vec3f* pos); f32 BgCheck_AnyRaycastDown2(CollisionContext* colCtx, CollisionPoly* outGroundPoly, s32* bgId, Vec3f* pos);
f32 BgCheck_CameraRaycastFloor2(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos); f32 BgCheck_CameraRaycastDown2(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos);
f32 BgCheck_EntityRaycastFloor8(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); f32 BgCheck_EntityRaycastDownWalls(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos);
f32 BgCheck_EntityRaycastFloor9(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos); f32 BgCheck_EntityRaycastDown9(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos);
s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev,
f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight, u8 argA);
s32 BgCheck_EntitySphVsWall1(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, s32 BgCheck_EntitySphVsWall1(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius,
CollisionPoly** outPoly, f32 checkHeight); CollisionPoly** outPoly, f32 checkHeight);
s32 BgCheck_EntitySphVsWall2(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, s32 BgCheck_EntitySphVsWall2(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius,
@ -574,9 +564,6 @@ s32 BgCheck_EntitySphVsWall4(CollisionContext* colCtx, Vec3f* posResult, Vec3f*
s32 BgCheck_AnyCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight); s32 BgCheck_AnyCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight);
s32 BgCheck_EntityCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight, s32 BgCheck_EntityCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight,
CollisionPoly** outPoly, s32* outBgId, Actor* actor); CollisionPoly** outPoly, s32* outBgId, Actor* actor);
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);
s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId);
s32 BgCheck_CameraLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, s32 BgCheck_CameraLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
@ -599,12 +586,7 @@ s32 BgCheck_AnyLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec
s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly,
s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId);
s32 BgCheck_SphVsFirstPoly(CollisionContext* colCtx, Vec3f* center, f32 radius); s32 BgCheck_SphVsFirstPoly(CollisionContext* colCtx, Vec3f* center, f32 radius);
void SSNodeList_Initialize(SSNodeList*);
void SSNodeList_Alloc(PlayState* play, SSNodeList* this, s32 tblMax, s32 numPolys);
u16 SSNodeList_GetNextNodeIdx(SSNodeList* this);
s32 DynaPoly_IsBgIdBgActor(s32 bgId); s32 DynaPoly_IsBgIdBgActor(s32 bgId);
void DynaPoly_Init(PlayState* play, DynaCollisionContext* dyna);
void DynaPoly_Alloc(PlayState* play, DynaCollisionContext* dyna);
void DynaPoly_DisableCollision(PlayState* play, DynaCollisionContext* dyna, s32 bgId); void DynaPoly_DisableCollision(PlayState* play, DynaCollisionContext* dyna, s32 bgId);
void DynaPoly_EnableCollision(PlayState* play, DynaCollisionContext* dyna, s32 bgId); void DynaPoly_EnableCollision(PlayState* play, DynaCollisionContext* dyna, s32 bgId);
void DynaPoly_DisableCeilingCollision(PlayState* play, DynaCollisionContext* dyna, s32 bgId); void DynaPoly_DisableCeilingCollision(PlayState* play, DynaCollisionContext* dyna, s32 bgId);
@ -615,19 +597,8 @@ void DynaPoly_InvalidateLookup(PlayState* play, DynaCollisionContext* dyna);
void DynaPoly_UnsetAllInteractFlags(PlayState* play, DynaCollisionContext* dyna, Actor* actor); void DynaPoly_UnsetAllInteractFlags(PlayState* play, DynaCollisionContext* dyna, Actor* actor);
void DynaPoly_UpdateContext(PlayState* play, DynaCollisionContext* dyna); void DynaPoly_UpdateContext(PlayState* play, DynaCollisionContext* dyna);
void DynaPoly_UpdateBgActorTransforms(PlayState* play, DynaCollisionContext* dyna); void DynaPoly_UpdateBgActorTransforms(PlayState* play, DynaCollisionContext* dyna);
f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast);
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 CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest); void CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest);
void func_800418D0(CollisionContext* colCtx, PlayState* play); void func_800418D0(CollisionContext* colCtx, PlayState* play);
void BgCheck_ResetPolyCheckTbl(SSNodeList* nodeList, s32 numPolys);
u32 SurfaceType_GetBgCamIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetBgCamIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u16 BgCheck_GetBgCamSettingImpl(CollisionContext* colCtx, u32 bgCamIndex, s32 bgId); u16 BgCheck_GetBgCamSettingImpl(CollisionContext* colCtx, u32 bgCamIndex, s32 bgId);
u16 BgCheck_GetBgCamSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u16 BgCheck_GetBgCamSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
@ -1483,7 +1454,7 @@ void Play_Destroy(GameState* thisx);
void Play_Init(GameState* thisx); void Play_Init(GameState* thisx);
void Play_Main(GameState* thisx); void Play_Main(GameState* thisx);
s32 Play_InCsMode(PlayState* this); s32 Play_InCsMode(PlayState* this);
f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* vec); f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* pos);
void* Play_LoadFile(PlayState* this, RomFile* file); void* Play_LoadFile(PlayState* this, RomFile* file);
void Play_GetScreenPos(PlayState* this, Vec3f* src, Vec3f* dest); void Play_GetScreenPos(PlayState* this, Vec3f* src, Vec3f* dest);
s16 Play_CreateSubCamera(PlayState* this); s16 Play_CreateSubCamera(PlayState* this);

View file

@ -296,11 +296,11 @@ typedef struct {
/* 0x14 */ Vec3f* pos; /* 0x14 */ Vec3f* pos;
/* 0x18 */ s32* bgId; /* 0x18 */ s32* bgId;
/* 0x1C */ struct Actor* actor; /* 0x1C */ struct Actor* actor;
/* 0x20 */ u32 unk_20; /* 0x20 */ u32 downChkFlags;
/* 0x24 */ f32 chkDist; /* 0x24 */ f32 chkDist;
/* 0x28 */ DynaCollisionContext* dyna; /* 0x28 */ DynaCollisionContext* dyna;
/* 0x2C */ SSList* ssList; /* 0x2C */ SSList* ssList;
} DynaRaycast; } DynaRaycastDown;
typedef struct { typedef struct {
/* 0x00 */ struct CollisionContext* colCtx; /* 0x00 */ struct CollisionContext* colCtx;

View file

@ -1168,13 +1168,13 @@ s32 func_8002E234(Actor* actor, f32 arg1, s32 arg2) {
return true; 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; f32 floorHeightDiff;
s32 floorBgId; 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); actor->bgCheckFlags &= ~(BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_GROUND_LEAVE | BGCHECKFLAG_GROUND_STRICT);
if (actor->floorHeight <= BGCHECK_Y_MIN) { 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) { void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) {
MtxF sp60; MtxF sp60;
f32 var; f32 yIntersect;
Vec3f sp50; Vec3f checkPos;
CollisionPoly* sp4C; CollisionPoly* groundPoly;
OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 8120); 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); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, alpha);
sp50.x = arg0->x; checkPos.x = arg0->x;
sp50.y = arg0->y + 1.0f; checkPos.y = arg0->y + 1.0f;
sp50.z = arg0->z; checkPos.z = arg0->z;
var = BgCheck_EntityRaycastFloor2(play, &play->colCtx, &sp4C, &sp50); yIntersect = BgCheck_EntityRaycastDown2(play, &play->colCtx, &groundPoly, &checkPos);
if (sp4C != NULL) { if (groundPoly != NULL) {
func_80038A28(sp4C, arg0->x, var, arg0->z, &sp60); func_80038A28(groundPoly, arg0->x, yIntersect, arg0->z, &sp60);
Matrix_Put(&sp60); Matrix_Put(&sp60);
} else { } else {
Matrix_Translate(arg0->x, arg0->y, arg0->z, MTXMODE_NEW); Matrix_Translate(arg0->x, arg0->y, arg0->z, MTXMODE_NEW);

View file

@ -1,6 +1,29 @@
#include "global.h" #include "global.h"
#include "vt.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 #define SS_NULL 0xFFFF
// bccFlags // bccFlags
@ -24,6 +47,16 @@
#define COLPOLY_IGNORE_ENTITY (1 << 1) #define COLPOLY_IGNORE_ENTITY (1 << 1)
#define COLPOLY_IGNORE_PROJECTILES (1 << 2) #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] = { s32 D_80119D90[WALL_TYPE_MAX] = {
0, // WALL_TYPE_0 0, // WALL_TYPE_0
WALL_FLAG_0, // WALL_TYPE_1 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` * Locates the closest static poly directly underneath `pos`, starting at list `ssList`
* returns yIntersect of the closest poly, or `yIntersectMin` * returns yIntersect of the closest poly, or `yIntersectMin`
* stores the pointer of the closest poly to `outPoly` * 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, f32 BgCheck_RaycastDownStaticList(CollisionContext* colCtx, u16 xpFlags, SSList* ssList, CollisionPoly** outPoly,
Vec3f* pos, f32 yIntersectMin, f32 chkDist, s32 flags) { Vec3f* pos, f32 yIntersectMin, f32 chkDist, s32 groundChk) {
SSNode* curNode; SSNode* curNode;
s32 polyId; s32 polyId;
f32 result; f32 result;
@ -547,7 +580,7 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList
polyId = curNode->polyId; polyId = curNode->polyId;
if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[polyId].flags_vIA, xpFlags) || 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) { if (curNode->next == SS_NULL) {
break; break;
} }
@ -565,7 +598,6 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList
pos->z, &yIntersect, chkDist) == true) { pos->z, &yIntersect, chkDist) == true) {
// if poly is closer to pos without going over // if poly is closer to pos without going over
if (yIntersect < pos->y && result < yIntersect) { if (yIntersect < pos->y && result < yIntersect) {
result = yIntersect; result = yIntersect;
*outPoly = &colCtx->colHeader->polyList[polyId]; *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` * returns yIntersect of the closest poly, or `yIntersectMin`
* stores the pointer of the closest poly to `outPoly` * stores the pointer of the closest poly to `outPoly`
*/ */
f32 BgCheck_RaycastFloorStatic(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** poly, f32 BgCheck_RaycastDownStatic(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** poly,
Vec3f* pos, u32 arg5, f32 chkDist, f32 yIntersectMin) { Vec3f* pos, u32 downChkFlags, f32 chkDist, f32 yIntersectMin) {
s32 flag; // skip polys with normal.y < 0
f32 yIntersect = yIntersectMin; f32 yIntersect = yIntersectMin;
s32 groundChk;
if (arg5 & 4) { if (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_FLOORS) {
yIntersect = BgCheck_RaycastFloorStaticList(colCtx, xpFlags, &lookup->floor, poly, pos, yIntersect, chkDist, 0); yIntersect = BgCheck_RaycastDownStaticList(colCtx, xpFlags, &lookup->floor, poly, pos, yIntersect, chkDist, 0);
} }
if ((arg5 & 2) || (arg5 & 8)) { if ((downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_WALLS) || (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE)) {
flag = 0; groundChk = 0;
if (arg5 & 0x10) { if (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY) {
flag = 1; groundChk |= BGCHECK_GROUND_CHECK_ON;
} }
yIntersect = 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) { if (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_CEILINGS) {
flag = 0; groundChk = 0;
if (arg5 & 0x10) { if (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY) {
flag = 1; groundChk |= BGCHECK_GROUND_CHECK_ON;
} }
yIntersect = 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; 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 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` * 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, f32 BgCheck_RaycastDownImpl(PlayState* play, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly,
s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 chkDist) { s32* outBgId, Vec3f* pos, Actor* actor, u32 downChkFlags, f32 chkDist) {
f32 yIntersectDyna; f32 yIntersectDyna;
s32* temp_a0; s32* temp_a0;
StaticLookup* lookupTbl; StaticLookup* lookupTbl;
Vec3f checkPos; Vec3f checkPos;
StaticLookup* lookup; StaticLookup* lookup;
DynaRaycast dynaRaycast; DynaRaycastDown dynaRaycastDown;
f32 yIntersect; f32 yIntersect;
*outBgId = BGCHECK_SCENE; *outBgId = BGCHECK_SCENE;
@ -1697,25 +1729,26 @@ f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFl
checkPos.y -= colCtx->subdivLength.y; checkPos.y -= colCtx->subdivLength.y;
continue; 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) { if (yIntersect > BGCHECK_Y_MIN) {
break; break;
} }
checkPos.y -= colCtx->subdivLength.y; checkPos.y -= colCtx->subdivLength.y;
} }
dynaRaycast.colCtx = colCtx; dynaRaycastDown.colCtx = colCtx;
dynaRaycast.xpFlags = xpFlags; dynaRaycastDown.xpFlags = xpFlags;
dynaRaycast.yIntersect = yIntersect; dynaRaycastDown.yIntersect = yIntersect;
dynaRaycast.pos = pos; dynaRaycastDown.pos = pos;
dynaRaycast.actor = actor; dynaRaycastDown.actor = actor;
dynaRaycast.unk_20 = arg7; dynaRaycastDown.downChkFlags = downChkFlags;
dynaRaycast.chkDist = chkDist; dynaRaycastDown.chkDist = chkDist;
dynaRaycast.play = play; dynaRaycastDown.play = play;
dynaRaycast.resultPoly = outPoly; dynaRaycastDown.resultPoly = outPoly;
dynaRaycast.bgId = outBgId; dynaRaycastDown.bgId = outBgId;
yIntersectDyna = BgCheck_RaycastFloorDyna(&dynaRaycast); yIntersectDyna = BgCheck_RaycastDownDyna(&dynaRaycastDown);
if (yIntersect < yIntersectDyna) { if (yIntersect < yIntersectDyna) {
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 * 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; 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 * 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; 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 * 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; 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 * 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) { f32 BgCheck_EntityRaycastDown3(CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId, Vec3f* pos) {
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
* If `actor` != null, bgcheck will be skipped for that actor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected * 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, f32 BgCheck_EntityRaycastDown4(CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId, Actor* actor,
Vec3f* pos) { Vec3f* pos) {
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f); 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 * 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, f32 BgCheck_EntityRaycastDown5(PlayState* play, CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId,
Actor* actor, Vec3f* pos) { Actor* actor, Vec3f* pos) {
return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f); 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 * 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 BgCheck_EntityRaycastDown6(CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId, Actor* actor,
f32 chkDist) { Vec3f* pos, f32 chkDist) {
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 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 * 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, f32 BgCheck_EntityRaycastDown7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos) {
Vec3f* pos) { return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor,
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x06, 1.0f); 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 * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/ */
f32 BgCheck_AnyRaycastFloor1(CollisionContext* colCtx, CollisionPoly* outPoly, Vec3f* pos) { f32 BgCheck_AnyRaycastDown1(CollisionContext* colCtx, CollisionPoly* outGroundPoly, Vec3f* pos) {
CollisionPoly* tempPoly; CollisionPoly* checkResultPoly;
f32 result; f32 result;
s32 bgId; 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) { if (checkResultPoly != NULL) {
*outPoly = *tempPoly; *outGroundPoly = *checkResultPoly;
} }
return result; 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 * 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) { f32 BgCheck_AnyRaycastDown2(CollisionContext* colCtx, CollisionPoly* outGroundPoly, s32* bgId, Vec3f* pos) {
CollisionPoly* tempPoly; CollisionPoly* checkResultPoly;
f32 result = BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &tempPoly, bgId, pos, NULL, 0x1C, 1.0f); 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) { if (checkResultPoly != NULL) {
*outPoly = *tempPoly; *outGroundPoly = *checkResultPoly;
} }
return result; 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 * 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) { f32 BgCheck_CameraRaycastDown2(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) {
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_CAMERA, outPoly, bgId, pos, NULL, 0x06, 1.0f); 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 * 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, f32 BgCheck_EntityRaycastDownWalls(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor,
Vec3f* pos) { Vec3f* pos) {
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x02, 1.0f); 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 * 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) { f32 BgCheck_EntityRaycastDown9(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) {
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, NULL, 0x06, 1.0f); 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 #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) * `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; CollisionPoly* polyList;
SSNode* curNode; SSNode* curNode;
f32 result; f32 result;
f32 yIntersect; f32 yIntersect;
s16 id; s16 id;
result = dynaRaycast->yIntersect; result = dynaRaycastDown->yIntersect;
if (dynaRaycast->ssList->head == SS_NULL) { if (dynaRaycastDown->ssList->head == SS_NULL) {
return result; return result;
} }
polyList = dynaRaycast->dyna->polyList; polyList = dynaRaycastDown->dyna->polyList;
curNode = &dynaRaycast->dyna->polyNodes.tbl[dynaRaycast->ssList->head]; curNode = &dynaRaycastDown->dyna->polyNodes.tbl[dynaRaycastDown->ssList->head];
while (true) { while (true) {
id = curNode->polyId; 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) { if (curNode->next == SS_NULL) {
break; break;
} else { } else {
curNode = &dynaRaycast->dyna->polyNodes.tbl[curNode->next]; curNode = &dynaRaycastDown->dyna->polyNodes.tbl[curNode->next];
continue; 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) { COLPOLY_GET_NORMAL(polyList[id].normal.y) < 0.0f) {
if (curNode->next == SS_NULL) { if (curNode->next == SS_NULL) {
break; break;
} else { } else {
curNode = &dynaRaycast->dyna->polyNodes.tbl[curNode->next]; curNode = &dynaRaycastDown->dyna->polyNodes.tbl[curNode->next];
continue; continue;
} }
} }
if (CollisionPoly_CheckYIntersectApprox1(&polyList[id], dynaRaycast->dyna->vtxList, dynaRaycast->pos->x, if (CollisionPoly_CheckYIntersectApprox1(&polyList[id], dynaRaycastDown->dyna->vtxList, dynaRaycastDown->pos->x,
dynaRaycast->pos->z, &yIntersect, dynaRaycast->chkDist) == true && dynaRaycastDown->pos->z, &yIntersect,
yIntersect < dynaRaycast->pos->y && result < yIntersect) { dynaRaycastDown->chkDist) == true &&
yIntersect < dynaRaycastDown->pos->y && result < yIntersect) {
result = yIntersect; result = yIntersect;
*dynaRaycast->resultPoly = &dynaRaycast->dyna->polyList[id]; *dynaRaycastDown->resultPoly = &dynaRaycastDown->dyna->polyList[id];
} }
if (curNode->next == SS_NULL) { if (curNode->next == SS_NULL) {
break; break;
} else { } else {
curNode = &dynaRaycast->dyna->polyNodes.tbl[curNode->next]; curNode = &dynaRaycastDown->dyna->polyNodes.tbl[curNode->next];
continue; 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 * 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; s32 i;
f32 result; f32 result;
f32 intersect2; f32 intersect2;
@ -3092,75 +3165,76 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) {
CollisionPoly* poly; CollisionPoly* poly;
result = BGCHECK_Y_MIN; result = BGCHECK_Y_MIN;
*dynaRaycast->bgId = BGCHECK_SCENE; *dynaRaycastDown->bgId = BGCHECK_SCENE;
for (i = 0; i < BG_ACTOR_MAX; i++) { 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; continue;
} }
if (dynaRaycast->actor == dynaRaycast->colCtx->dyna.bgActors[i].actor || if (dynaRaycastDown->actor == dynaRaycastDown->colCtx->dyna.bgActors[i].actor ||
dynaRaycast->pos->y < dynaRaycast->colCtx->dyna.bgActors[i].minY || dynaRaycastDown->pos->y < dynaRaycastDown->colCtx->dyna.bgActors[i].minY ||
Math3D_XZInSphere(&dynaRaycast->colCtx->dyna.bgActors[i].boundingSphere, dynaRaycast->pos->x, Math3D_XZInSphere(&dynaRaycastDown->colCtx->dyna.bgActors[i].boundingSphere, dynaRaycastDown->pos->x,
dynaRaycast->pos->z) == false) { dynaRaycastDown->pos->z) == false) {
continue; continue;
} }
dynaRaycast->dyna = &dynaRaycast->colCtx->dyna; dynaRaycastDown->dyna = &dynaRaycastDown->colCtx->dyna;
if (dynaRaycast->unk_20 & BGCHECK_IGNORE_FLOOR) { if (dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_FLOORS) {
dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.floor; dynaRaycastDown->ssList = &dynaRaycastDown->colCtx->dyna.bgActors[i].dynaLookup.floor;
intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_FLOORS); intersect2 = BgCheck_RaycastDownDynaList(dynaRaycastDown, DYNA_RAYCAST_FLOORS);
if (dynaRaycast->yIntersect < intersect2) { if (dynaRaycastDown->yIntersect < intersect2) {
dynaRaycastDown->yIntersect = intersect2;
dynaRaycast->yIntersect = intersect2; *dynaRaycastDown->bgId = i;
*dynaRaycast->bgId = i;
result = intersect2; result = intersect2;
} }
} }
if ((dynaRaycast->unk_20 & BGCHECK_IGNORE_WALL) || if ((dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_WALLS) ||
(*dynaRaycast->resultPoly == NULL && (dynaRaycast->unk_20 & 8))) { (*dynaRaycastDown->resultPoly == NULL &&
dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.wall; (dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE))) {
intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_WALLS); dynaRaycastDown->ssList = &dynaRaycastDown->colCtx->dyna.bgActors[i].dynaLookup.wall;
if (dynaRaycast->yIntersect < intersect2) { intersect2 = BgCheck_RaycastDownDynaList(dynaRaycastDown, DYNA_RAYCAST_WALLS);
dynaRaycast->yIntersect = intersect2; if (dynaRaycastDown->yIntersect < intersect2) {
*dynaRaycast->bgId = i; dynaRaycastDown->yIntersect = intersect2;
*dynaRaycastDown->bgId = i;
result = intersect2; result = intersect2;
} }
} }
if (dynaRaycast->unk_20 & BGCHECK_IGNORE_CEILING) { if (dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_CEILINGS) {
dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.ceiling; dynaRaycastDown->ssList = &dynaRaycastDown->colCtx->dyna.bgActors[i].dynaLookup.ceiling;
intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_CEILINGS); intersect2 = BgCheck_RaycastDownDynaList(dynaRaycastDown, DYNA_RAYCAST_CEILINGS);
if (dynaRaycast->yIntersect < intersect2) {
dynaRaycast->yIntersect = intersect2; if (dynaRaycastDown->yIntersect < intersect2) {
*dynaRaycast->bgId = i; dynaRaycastDown->yIntersect = intersect2;
*dynaRaycastDown->bgId = i;
result = intersect2; result = intersect2;
} }
} }
} }
dynaActor = DynaPoly_GetActor(dynaRaycast->colCtx, *dynaRaycast->bgId); dynaActor = DynaPoly_GetActor(dynaRaycastDown->colCtx, *dynaRaycastDown->bgId);
if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->play != NULL)) { if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycastDown->play != NULL)) {
pauseState = dynaRaycast->play->pauseCtx.state != 0; pauseState = dynaRaycastDown->play->pauseCtx.state != 0;
if (pauseState == 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)) { if (!pauseState && (dynaRaycastDown->colCtx->dyna.bgActorFlags[*dynaRaycastDown->bgId] & BGACTOR_1)) {
curTransform = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].curTransform; curTransform = &dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].curTransform;
polyMin = polyMin =
&dynaRaycast->dyna->polyList[dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].dynaLookup.polyStartIndex]; &dynaRaycastDown->dyna
polyIndex = *dynaRaycast->resultPoly - polyMin; ->polyList[dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].dynaLookup.polyStartIndex];
poly = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].colHeader->polyList[polyIndex]; polyIndex = *dynaRaycastDown->resultPoly - polyMin;
poly = &dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].colHeader->polyList[polyIndex];
SkinMatrix_SetTranslateRotateYXZScale(&srpMtx, curTransform->scale.x, curTransform->scale.y, SkinMatrix_SetTranslateRotateYXZScale(&srpMtx, curTransform->scale.x, curTransform->scale.y,
curTransform->scale.z, curTransform->rot.x, curTransform->rot.y, curTransform->scale.z, curTransform->rot.x, curTransform->rot.y,
curTransform->rot.z, curTransform->pos.x, curTransform->pos.y, curTransform->rot.z, curTransform->pos.x, curTransform->pos.y,
curTransform->pos.z); 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++) { for (i2 = 0; i2 < 3; i2++) {
Math_Vec3s_ToVec3f(&vtx, &vtxList[COLPOLY_VTX_INDEX(poly->vtxData[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.y *= 1.0f / magnitude;
polyNorm.z *= 1.0f / magnitude; polyNorm.z *= 1.0f / magnitude;
polyDist = -DOTXYZ(polyNorm, polyVtx[0]); polyDist = -DOTXYZ(polyNorm, polyVtx[0]);
if (Math3D_TriChkPointParaYIntersectInsideTri(&polyVtx[0], &polyVtx[1], &polyVtx[2], polyNorm.x, if (Math3D_TriChkPointParaYIntersectInsideTri(
polyNorm.y, polyNorm.z, polyDist, dynaRaycast->pos->z, &polyVtx[0], &polyVtx[1], &polyVtx[2], polyNorm.x, polyNorm.y, polyNorm.z, polyDist,
dynaRaycast->pos->x, &intersect, dynaRaycast->chkDist)) { dynaRaycastDown->pos->z, dynaRaycastDown->pos->x, &intersect, dynaRaycastDown->chkDist)) {
if (fabsf(intersect - result) < 1.0f) { if (fabsf(intersect - result) < 1.0f) {
result = intersect; result = intersect;

View file

@ -233,7 +233,7 @@ s32 Camera_BGCheckInfo(Camera* camera, Vec3f* from, CamColChk* to) {
toNewPos = to->pos; toNewPos = to->pos;
toNewPos.y += 5.0f; 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 ((to->pos.y - floorPolyY) > 5.0f) {
// if the y distance from the check point to the floor is more than 5 units // 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; to->norm.z = -fromToNorm.z;
toNewPos = to->pos; toNewPos = to->pos;
toNewPos.y += 5.0f; 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) { if ((to->pos.y - floorY) > 5.0f) {
// to is not on the ground or below it. // to is not on the ground or below it.
to->pos.x += to->norm.x; 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) { f32 Camera_GetFloorYNorm(Camera* camera, Vec3f* floorNorm, Vec3f* chkPos, s32* bgId) {
s32 pad; s32 pad;
CollisionPoly* floorPoly; 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) { if (floorY == BGCHECK_Y_MIN) {
// no floor // no floor
@ -418,7 +418,7 @@ f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, s32* bgId) {
s32 i; s32 i;
for (i = 3; i > 0; 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 || if (floorY == BGCHECK_Y_MIN ||
(camera->playerGroundY < floorY && !(COLPOLY_GET_NORMAL(floorPoly->normal.y) > 0.5f))) { (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 // 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); Actor_GetWorldPosShapeRot(&playerPosShape, &camera->player->actor);
playerPosShape.pos.y += Player_GetHeight(camera->player); 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 // no floor
return NULL; return NULL;
} }
@ -3647,7 +3647,7 @@ s32 Camera_KeepOn4(Camera* camera) {
OLib_Vec3fDiffToVecSphGeo(&spA8, at, eyeNext); OLib_Vec3fDiffToVecSphGeo(&spA8, at, eyeNext);
D_8015BD50 = playerPosRot->pos; D_8015BD50 = playerPosRot->pos;
D_8015BD50.y += playerHeight; 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)) { if (temp_f0_2 > (roData->unk_00 + D_8015BD50.y)) {
D_8015BD50.y = temp_f0_2 + 10.0f; D_8015BD50.y = temp_f0_2 + 10.0f;
} else { } else {
@ -7407,7 +7407,7 @@ Vec3s Camera_Update(Camera* camera) {
Vec3f viewEye; Vec3f viewEye;
Vec3f viewUp; Vec3f viewUp;
f32 viewFov; f32 viewFov;
Vec3f spAC; Vec3f pos;
s32 bgId; s32 bgId;
f32 playerGroundY; f32 playerGroundY;
f32 playerXZSpeed; f32 playerXZSpeed;
@ -7441,11 +7441,11 @@ Vec3s Camera_Update(Camera* camera) {
camera->playerPosDelta.x = curPlayerPosRot.pos.x - camera->playerPosRot.pos.x; camera->playerPosDelta.x = curPlayerPosRot.pos.x - camera->playerPosRot.pos.x;
camera->playerPosDelta.y = curPlayerPosRot.pos.y - camera->playerPosRot.pos.y; camera->playerPosDelta.y = curPlayerPosRot.pos.y - camera->playerPosRot.pos.y;
camera->playerPosDelta.z = curPlayerPosRot.pos.z - camera->playerPosRot.pos.z; camera->playerPosDelta.z = curPlayerPosRot.pos.z - camera->playerPosRot.pos.z;
spAC = curPlayerPosRot.pos; pos = curPlayerPosRot.pos;
spAC.y += Player_GetHeight(camera->player); pos.y += Player_GetHeight(camera->player);
playerGroundY = BgCheck_EntityRaycastFloor5(camera->play, &camera->play->colCtx, &playerFloorPoly, &bgId, playerGroundY = BgCheck_EntityRaycastDown5(camera->play, &camera->play->colCtx, &playerFloorPoly, &bgId,
&camera->player->actor, &spAC); &camera->player->actor, &pos);
if (playerGroundY != BGCHECK_Y_MIN) { if (playerGroundY != BGCHECK_Y_MIN) {
// player is above ground. // player is above ground.
sOOBTimer = 0; sOOBTimer = 0;

View file

@ -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); 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; CollisionPoly* outPoly;
s32 bgId; 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, 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: case 4500:
Actor_GetFocus(&spA0, actor); Actor_GetFocus(&spA0, actor);
spC0 = spA0.pos; 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.r = 150.0f;
spD0.yaw = spA0.rot.y; spD0.yaw = spA0.rot.y;
spD0.pitch = 0x3E8; spD0.pitch = 0x3E8;

View file

@ -1315,7 +1315,7 @@ s32 Play_InCsMode(PlayState* this) {
return (this->csCtx.state != CS_STATE_IDLE) || Player_InCsMode(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; CollisionPoly poly;
f32 temp1; f32 temp1;
f32 temp2; f32 temp2;
@ -1326,7 +1326,7 @@ f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* vec) {
f32 nz; f32 nz;
s32 pad[5]; s32 pad[5];
floorY = BgCheck_AnyRaycastFloor1(&this->colCtx, &poly, vec); floorY = BgCheck_AnyRaycastDown1(&this->colCtx, &poly, pos);
if (floorY > BGCHECK_Y_MIN) { if (floorY > BGCHECK_Y_MIN) {
nx = COLPOLY_GET_NORMAL(poly.normal.x); 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->wy = 0.0f;
mf->xz = 0.0f; mf->xz = 0.0f;
mf->wz = 0.0f; mf->wz = 0.0f;
mf->xw = vec->x; mf->xw = pos->x;
mf->yw = floorY; mf->yw = floorY;
mf->zw = vec->z; mf->zw = pos->z;
mf->ww = 1.0f; mf->ww = 1.0f;
} else { } else {
mf->xy = 0.0f; mf->xy = 0.0f;
@ -1372,9 +1372,9 @@ f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* vec) {
mf->yz = 0.0f; mf->yz = 0.0f;
mf->zy = 0.0f; mf->zy = 0.0f;
mf->yy = 1.0f; mf->yy = 1.0f;
mf->xw = vec->x; mf->xw = pos->x;
mf->yw = vec->y; mf->yw = pos->y;
mf->zw = vec->z; mf->zw = pos->z;
mf->ww = 1.0f; 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, if (WaterBox_GetSurface1(this, &this->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y,
&waterBox) == true && &waterBox) == true &&
pos->y < waterSurfacePos.y && 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; return true;
} else { } else {
return false; return false;

View file

@ -997,7 +997,7 @@ void func_8008F87C(PlayState* play, Player* this, SkelAnime* skelAnime, Vec3f* p
footprintPos.y += 15.0f; 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) { if (sp98.y < sp80) {
sp70 = sp98.x - spA4.x; sp70 = sp98.x - spA4.x;

View file

@ -349,10 +349,9 @@ void func_808805C0(BgHakaTrap* this, PlayState* play) {
void func_808806BC(BgHakaTrap* this, PlayState* play) { void func_808806BC(BgHakaTrap* this, PlayState* play) {
Vec3f vector; Vec3f vector;
f32 tempf20; f32 floorHeight;
f32 temp; f32 yIntersect;
s32 i; s32 i;
s32 sp64;
this->dyna.actor.velocity.y *= 1.6f; this->dyna.actor.velocity.y *= 1.6f;
@ -364,20 +363,22 @@ void func_808806BC(BgHakaTrap* this, PlayState* play) {
vector.y = (this->dyna.actor.world.pos.y + 1.0f) + 25.0f; vector.y = (this->dyna.actor.world.pos.y + 1.0f) + 25.0f;
vector.z = this->dyna.actor.world.pos.z; vector.z = this->dyna.actor.world.pos.z;
tempf20 = this->dyna.actor.floorHeight; floorHeight = this->dyna.actor.floorHeight;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
temp = s32 bgId;
BgCheck_EntityRaycastFloor4(&play->colCtx, &this->dyna.actor.floorPoly, &sp64, &this->dyna.actor, &vector) -
yIntersect =
BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &vector) -
25.0f; 25.0f;
if (tempf20 < temp) { if (floorHeight < yIntersect) {
tempf20 = temp; floorHeight = yIntersect;
} }
vector.x -= 90.0f; vector.x -= 90.0f;
} }
if (Math_StepToF(&this->dyna.actor.world.pos.y, tempf20, this->dyna.actor.velocity.y)) { if (Math_StepToF(&this->dyna.actor.world.pos.y, floorHeight, this->dyna.actor.velocity.y)) {
if (this->dyna.actor.velocity.y > 0.01f) { if (this->dyna.actor.velocity.y > 0.01f) {
Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_TRAP_BOUND); Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_TRAP_BOUND);
} }

View file

@ -378,18 +378,18 @@ void BgHeavyBlock_LiftedUp(BgHeavyBlock* this, PlayState* play) {
void BgHeavyBlock_Fly(BgHeavyBlock* this, PlayState* play) { void BgHeavyBlock_Fly(BgHeavyBlock* this, PlayState* play) {
s32 bgId; s32 bgId;
s32 quakeIndex; s32 quakeIndex;
Vec3f pos; Vec3f checkPos;
f32 raycastResult; f32 yIntersect;
Actor_MoveForward(&this->dyna.actor); Actor_MoveForward(&this->dyna.actor);
pos.x = this->dyna.actor.home.pos.x; checkPos.x = this->dyna.actor.home.pos.x;
pos.y = this->dyna.actor.home.pos.y + 1000.0f; checkPos.y = this->dyna.actor.home.pos.y + 1000.0f;
pos.z = this->dyna.actor.home.pos.z; checkPos.z = this->dyna.actor.home.pos.z;
raycastResult = yIntersect =
BgCheck_EntityRaycastFloor4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &pos); BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &checkPos);
this->dyna.actor.floorHeight = raycastResult; this->dyna.actor.floorHeight = yIntersect;
if (this->dyna.actor.home.pos.y <= raycastResult) { if (this->dyna.actor.home.pos.y <= yIntersect) {
func_800AA000(0.0f, 0xFF, 0x3C, 4); func_800AA000(0.0f, 0xFF, 0x3C, 4);
switch (this->dyna.actor.params & 0xFF) { switch (this->dyna.actor.params & 0xFF) {

View file

@ -198,16 +198,16 @@ void BgJyaGoroiwa_Update(Actor* thisx, PlayState* play) {
BgJyaGoroiwa* this = (BgJyaGoroiwa*)thisx; BgJyaGoroiwa* this = (BgJyaGoroiwa*)thisx;
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
s32 bgId; s32 bgId;
Vec3f pos; Vec3f checkPos;
if (!(player->stateFlags1 & (PLAYER_STATE1_6 | PLAYER_STATE1_7 | PLAYER_STATE1_28 | PLAYER_STATE1_29))) { if (!(player->stateFlags1 & (PLAYER_STATE1_6 | PLAYER_STATE1_7 | PLAYER_STATE1_28 | PLAYER_STATE1_29))) {
this->actionFunc(this, play); this->actionFunc(this, play);
BgJyaGoroiwa_UpdateRotation(this); BgJyaGoroiwa_UpdateRotation(this);
pos.x = this->actor.world.pos.x; checkPos.x = this->actor.world.pos.x;
pos.y = this->actor.world.pos.y + 59.5f; checkPos.y = this->actor.world.pos.y + 59.5f;
pos.z = this->actor.world.pos.z; checkPos.z = this->actor.world.pos.z;
this->actor.floorHeight = this->actor.floorHeight =
BgCheck_EntityRaycastFloor4(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &pos); BgCheck_EntityRaycastDown4(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &checkPos);
BgJyaGoroiwa_UpdateCollider(this); BgJyaGoroiwa_UpdateCollider(this);
if (this->collider.base.atFlags & AT_ON) { if (this->collider.base.atFlags & AT_ON) {
CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base);

View file

@ -182,7 +182,7 @@ void BgPoEvent_InitBlocks(BgPoEvent* this, PlayState* play) {
} }
} }
this->dyna.actor.world.pos.y = 833.0f; this->dyna.actor.world.pos.y = 833.0f;
this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, this->dyna.actor.floorHeight = BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId,
&this->dyna.actor, &this->dyna.actor.world.pos); &this->dyna.actor, &this->dyna.actor.world.pos);
this->actionFunc = BgPoEvent_BlockWait; this->actionFunc = BgPoEvent_BlockWait;
} }

View file

@ -49,7 +49,8 @@ static Vec3f D_808B45C4[] = {
{ 770.0f, 1550.0f, -299.0f }, { 770.0f, 1550.0f, -299.0f },
}; };
static Vec3f D_808B45DC[] = { // list of ground check positions, relative to 1/10th model space
static Vec3f sBoxGroundCheckPoints[] = {
{ 29.99f, 0.01f, -29.99f }, { -29.99f, 0.01f, -29.99f }, { -29.99f, 0.01f, 29.99f }, { 29.99f, 0.01f, -29.99f }, { -29.99f, 0.01f, -29.99f }, { -29.99f, 0.01f, 29.99f },
{ 29.99f, 0.01f, 29.99f }, { 0.0f, 0.01f, 0.0f }, { 29.99f, 0.01f, 29.99f }, { 0.0f, 0.01f, 0.0f },
}; };
@ -70,10 +71,10 @@ void func_808B3960(BgSpot15Rrbox* this, PlayState* play, CollisionHeader* collis
} }
} }
void func_808B39E8(Vec3f* arg0, Vec3f* arg1, f32 arg2, f32 arg3) { void BgSpot15Rrbox_RotatePoint(Vec3f* outPos, Vec3f* pos, f32 arg2, f32 arg3) {
arg0->x = (arg1->z * arg2) + (arg1->x * arg3); outPos->x = (pos->z * arg2) + (pos->x * arg3);
arg0->y = arg1->y; outPos->y = pos->y;
arg0->z = (arg1->z * arg3) - (arg1->x * arg2); outPos->z = (pos->z * arg3) - (pos->x * arg2);
} }
void func_808B3A34(BgSpot15Rrbox* this) { void func_808B3A34(BgSpot15Rrbox* this) {
@ -140,25 +141,25 @@ void BgSpot15Rrbox_Destroy(Actor* thisx, PlayState* play) {
D_808B4590 = 0; D_808B4590 = 0;
} }
s32 func_808B3CA0(BgSpot15Rrbox* this, PlayState* play, s32 arg2) { s32 BgSpot15Rrbox_TrySnapToCheckedPoint(BgSpot15Rrbox* this, PlayState* play, s32 checkIndex) {
f32 chkDist = 0.0f; f32 chkDist = 0.0f;
Vec3f actorPosition; Vec3f checkPos;
Vec3f actorScale; Vec3f relCheckPos;
func_808B3A34(this); func_808B3A34(this);
actorScale.x = D_808B45DC[arg2].x * (this->dyna.actor.scale.x * 10.0f); relCheckPos.x = sBoxGroundCheckPoints[checkIndex].x * (this->dyna.actor.scale.x * 10.0f);
actorScale.y = D_808B45DC[arg2].y * (this->dyna.actor.scale.y * 10.0f); relCheckPos.y = sBoxGroundCheckPoints[checkIndex].y * (this->dyna.actor.scale.y * 10.0f);
actorScale.z = D_808B45DC[arg2].z * (this->dyna.actor.scale.z * 10.0f); relCheckPos.z = sBoxGroundCheckPoints[checkIndex].z * (this->dyna.actor.scale.z * 10.0f);
func_808B39E8(&actorPosition, &actorScale, this->unk_16C, this->unk_170); BgSpot15Rrbox_RotatePoint(&checkPos, &relCheckPos, this->unk_16C, this->unk_170);
actorPosition.x += this->dyna.actor.world.pos.x; checkPos.x += this->dyna.actor.world.pos.x;
actorPosition.y += this->dyna.actor.prevPos.y; checkPos.y += this->dyna.actor.prevPos.y;
actorPosition.z += this->dyna.actor.world.pos.z; checkPos.z += this->dyna.actor.world.pos.z;
this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor6(&play->colCtx, &this->dyna.actor.floorPoly, &this->bgId, this->dyna.actor.floorHeight = BgCheck_EntityRaycastDown6(&play->colCtx, &this->dyna.actor.floorPoly, &this->bgId,
&this->dyna.actor, &actorPosition, chkDist); &this->dyna.actor, &checkPos, chkDist);
if ((this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y) >= -0.001f) { if ((this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y) >= -0.001f) {
this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight;
@ -167,51 +168,51 @@ s32 func_808B3CA0(BgSpot15Rrbox* this, PlayState* play, s32 arg2) {
return false; return false;
} }
f32 func_808B3DDC(BgSpot15Rrbox* this, PlayState* play) { f32 BgSpot15Rrbox_GetFloorHeight(BgSpot15Rrbox* this, PlayState* play) {
s32 i; s32 i;
Vec3f position; Vec3f checkPos;
Vec3f scale; Vec3f relCheckPos;
Actor* actor = &this->dyna.actor; Actor* actor = &this->dyna.actor;
f32 yIntersect; f32 yIntersect;
f32 returnValue = BGCHECK_Y_MIN; f32 floorY = BGCHECK_Y_MIN;
s32 bgId; s32 bgId;
func_808B3A34(this); func_808B3A34(this);
for (i = 0; i < ARRAY_COUNT(D_808B45DC); i++) { for (i = 0; i < ARRAY_COUNT(sBoxGroundCheckPoints); i++) {
scale.x = D_808B45DC[i].x * (actor->scale.x * 10.0f); relCheckPos.x = sBoxGroundCheckPoints[i].x * (actor->scale.x * 10.0f);
scale.y = D_808B45DC[i].y * (actor->scale.y * 10.0f); relCheckPos.y = sBoxGroundCheckPoints[i].y * (actor->scale.y * 10.0f);
scale.z = D_808B45DC[i].z * (actor->scale.z * 10.0f); relCheckPos.z = sBoxGroundCheckPoints[i].z * (actor->scale.z * 10.0f);
func_808B39E8(&position, &scale, this->unk_16C, this->unk_170); BgSpot15Rrbox_RotatePoint(&checkPos, &relCheckPos, this->unk_16C, this->unk_170);
position.x += actor->world.pos.x; checkPos.x += actor->world.pos.x;
position.y += actor->prevPos.y; checkPos.y += actor->prevPos.y;
position.z += actor->world.pos.z; checkPos.z += actor->world.pos.z;
yIntersect = BgCheck_EntityRaycastFloor6(&play->colCtx, &actor->floorPoly, &bgId, actor, &position, 0); yIntersect = BgCheck_EntityRaycastDown6(&play->colCtx, &actor->floorPoly, &bgId, actor, &checkPos, 0);
if (returnValue < yIntersect) { if (floorY < yIntersect) {
returnValue = yIntersect; floorY = yIntersect;
this->bgId = bgId; this->bgId = bgId;
} }
} }
return returnValue; return floorY;
} }
s32 func_808B3F58(BgSpot15Rrbox* this, PlayState* play) { s32 BgSpot15Rrbox_TrySnapToFloor(BgSpot15Rrbox* this, PlayState* play) {
if (func_808B3CA0(this, play, 0)) { if (BgSpot15Rrbox_TrySnapToCheckedPoint(this, play, 0)) {
return true; return true;
} }
if (func_808B3CA0(this, play, 1)) { if (BgSpot15Rrbox_TrySnapToCheckedPoint(this, play, 1)) {
return true; return true;
} }
if (func_808B3CA0(this, play, 2)) { if (BgSpot15Rrbox_TrySnapToCheckedPoint(this, play, 2)) {
return true; return true;
} }
if (func_808B3CA0(this, play, 3)) { if (BgSpot15Rrbox_TrySnapToCheckedPoint(this, play, 3)) {
return true; return true;
} }
if (func_808B3CA0(this, play, 4)) { if (BgSpot15Rrbox_TrySnapToCheckedPoint(this, play, 4)) {
return true; return true;
} }
return false; return false;
@ -271,7 +272,7 @@ void func_808B4194(BgSpot15Rrbox* this, PlayState* play) {
actor->world.pos.x = actor->home.pos.x + (tempUnk178 * this->unk_16C); actor->world.pos.x = actor->home.pos.x + (tempUnk178 * this->unk_16C);
actor->world.pos.z = actor->home.pos.z + (tempUnk178 * this->unk_170); actor->world.pos.z = actor->home.pos.z + (tempUnk178 * this->unk_170);
if (!func_808B3F58(this, play)) { if (!BgSpot15Rrbox_TrySnapToFloor(this, play)) {
actor->home.pos.x = actor->world.pos.x; actor->home.pos.x = actor->world.pos.x;
actor->home.pos.z = actor->world.pos.z; actor->home.pos.z = actor->world.pos.z;
player->stateFlags2 &= ~PLAYER_STATE2_4; player->stateFlags2 &= ~PLAYER_STATE2_4;
@ -304,7 +305,7 @@ void func_808B4380(BgSpot15Rrbox* this, PlayState* play) {
this->dyna.actor.velocity.y = 0.0f; this->dyna.actor.velocity.y = 0.0f;
this->dyna.actor.velocity.z = 0.0f; this->dyna.actor.velocity.z = 0.0f;
this->dyna.actor.gravity = -1.0f; this->dyna.actor.gravity = -1.0f;
this->dyna.actor.floorHeight = func_808B3DDC(this, play); this->dyna.actor.floorHeight = BgSpot15Rrbox_GetFloorHeight(this, play);
this->actionFunc = func_808B43D0; this->actionFunc = func_808B43D0;
} }

View file

@ -431,7 +431,7 @@ void BgSpot18Basket_Update(Actor* thisx, PlayState* play) {
this->unk_216++; this->unk_216++;
this->actionFunc(this, play); this->actionFunc(this, play);
this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, this->dyna.actor.floorHeight = BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId,
&this->dyna.actor, &this->dyna.actor.world.pos); &this->dyna.actor, &this->dyna.actor.world.pos);
if (this->actionFunc != func_808B7AFC) { if (this->actionFunc != func_808B7AFC) {
CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderJntSph.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderJntSph.base);

View file

@ -3291,19 +3291,11 @@ void BossVa_UpdateEffects(PlayState* play) {
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
s16 spB6; s16 spB6;
s16 i; s16 i;
f32 floorY; f32 spB0;
s32 padAC; f32 spAC;
s16 pitch; s16 pitch;
s16 yaw;
BossVa* refActor2; BossVa* refActor2;
BossVa* refActor; BossVa* refActor;
Vec3f sp94;
CollisionPoly* sp90;
f32 pad8C;
Vec3f sp80;
CollisionPoly* sp7C;
f32 pad78;
f32 pad74;
for (i = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) { for (i = 0; i < BOSS_VA_EFFECT_COUNT; i++, effect++) {
if (effect->type != VA_NONE) { if (effect->type != VA_NONE) {
@ -3325,12 +3317,12 @@ void BossVa_UpdateEffects(PlayState* play) {
if ((effect->mode == SPARK_TETHER) || (effect->mode == SPARK_UNUSED)) { if ((effect->mode == SPARK_TETHER) || (effect->mode == SPARK_UNUSED)) {
pitch = effect->rot.x - Math_Vec3f_Pitch(&refActor->actor.world.pos, &GET_BODY(refActor)->unk_1D8); pitch = effect->rot.x - Math_Vec3f_Pitch(&refActor->actor.world.pos, &GET_BODY(refActor)->unk_1D8);
pad8C = Math_SinS(refActor->actor.world.rot.y); spAC = Math_SinS(refActor->actor.world.rot.y);
effect->pos.x = refActor->actor.world.pos.x - (effect->offset.x * pad8C); effect->pos.x = refActor->actor.world.pos.x - (effect->offset.x * spAC);
pad74 = Math_CosS(refActor->actor.world.rot.y); spB0 = Math_CosS(refActor->actor.world.rot.y);
effect->pos.z = refActor->actor.world.pos.z - (effect->offset.x * pad74); effect->pos.z = refActor->actor.world.pos.z - (effect->offset.x * spB0);
pad78 = Math_CosS(-pitch); spB0 = Math_CosS(-pitch);
effect->pos.y = (effect->offset.y * pad78) + refActor->actor.world.pos.y; effect->pos.y = (effect->offset.y * spB0) + refActor->actor.world.pos.y;
} else if ((effect->mode == SPARK_BARI) || (effect->mode == SPARK_BODY)) { } else if ((effect->mode == SPARK_BARI) || (effect->mode == SPARK_BODY)) {
effect->pos.x = effect->offset.x + refActor->actor.world.pos.x; effect->pos.x = effect->offset.x + refActor->actor.world.pos.x;
effect->pos.y = effect->offset.y + refActor->actor.world.pos.y; effect->pos.y = effect->offset.y + refActor->actor.world.pos.y;
@ -3396,10 +3388,14 @@ void BossVa_UpdateEffects(PlayState* play) {
if (effect->type == VA_BLOOD) { if (effect->type == VA_BLOOD) {
if (effect->mode < BLOOD_SPOT) { if (effect->mode < BLOOD_SPOT) {
sp94 = effect->pos; Vec3f checkPos;
sp94.y -= effect->velocity.y + 4.0f; CollisionPoly* groundPoly;
floorY = BgCheck_EntityRaycastFloor1(&play->colCtx, &sp90, &sp94); f32 floorY;
if ((sp90 != NULL) && (effect->pos.y <= floorY)) {
checkPos = effect->pos;
checkPos.y -= effect->velocity.y + 4.0f;
floorY = BgCheck_EntityRaycastDown1(&play->colCtx, &groundPoly, &checkPos);
if ((groundPoly != NULL) && (effect->pos.y <= floorY)) {
effect->mode = BLOOD_SPOT; effect->mode = BLOOD_SPOT;
effect->pos.y = floorY + 1.0f; effect->pos.y = floorY + 1.0f;
if (sCsState <= DEATH_SHELL_BURST) { if (sCsState <= DEATH_SHELL_BURST) {
@ -3429,11 +3425,15 @@ void BossVa_UpdateEffects(PlayState* play) {
if (effect->type == VA_GORE) { if (effect->type == VA_GORE) {
if (effect->mode == GORE_PERMANENT) { if (effect->mode == GORE_PERMANENT) {
sp80 = effect->pos; Vec3f checkPos;
sp80.y -= effect->velocity.y + 4.0f; CollisionPoly* groundPoly;
f32 floorY;
checkPos = effect->pos;
checkPos.y -= effect->velocity.y + 4.0f;
effect->rot.x += 0x1770; effect->rot.x += 0x1770;
floorY = BgCheck_EntityRaycastFloor1(&play->colCtx, &sp7C, &sp80); floorY = BgCheck_EntityRaycastDown1(&play->colCtx, &groundPoly, &checkPos);
if ((sp7C != NULL) && (effect->pos.y <= floorY)) { if ((groundPoly != NULL) && (effect->pos.y <= floorY)) {
effect->mode = GORE_FLOOR; effect->mode = GORE_FLOOR;
effect->timer = 30; effect->timer = 30;
effect->pos.y = floorY + 1.0f; effect->pos.y = floorY + 1.0f;
@ -3462,6 +3462,8 @@ void BossVa_UpdateEffects(PlayState* play) {
} }
if (effect->type == VA_TUMOR) { if (effect->type == VA_TUMOR) {
s16 yaw;
refActor = effect->parent; refActor = effect->parent;
effect->rot.z += 0x157C; effect->rot.z += 0x157C;

View file

@ -79,11 +79,11 @@ void EnBox_ClipToGround(EnBox* this, PlayState* play) {
f32 newY; f32 newY;
CollisionPoly* poly; CollisionPoly* poly;
s32 bgId; s32 bgId;
Vec3f pos; Vec3f checkPos;
pos = this->dyna.actor.world.pos; checkPos = this->dyna.actor.world.pos;
pos.y += 1.0f; checkPos.y += 1.0f;
newY = BgCheck_EntityRaycastFloor4(&play->colCtx, &poly, &bgId, &this->dyna.actor, &pos); newY = BgCheck_EntityRaycastDown4(&play->colCtx, &poly, &bgId, &this->dyna.actor, &checkPos);
if (newY != BGCHECK_Y_MIN) { if (newY != BGCHECK_Y_MIN) {
this->dyna.actor.world.pos.y = newY; this->dyna.actor.world.pos.y = newY;
} }

View file

@ -402,8 +402,8 @@ void EnEiyer_Ambush(EnEiyer* this, PlayState* play) {
this->collider.base.acFlags |= AC_ON; this->collider.base.acFlags |= AC_ON;
EnEiyer_SetupGlide(this); EnEiyer_SetupGlide(this);
} else { } else {
this->actor.floorHeight = BgCheck_EntityRaycastFloor4(&play->colCtx, &this->actor.floorPoly, &bgId, this->actor.floorHeight = BgCheck_EntityRaycastDown4(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor,
&this->actor, &this->actor.world.pos); &this->actor.world.pos);
} }
} }

View file

@ -1209,9 +1209,9 @@ void func_80A04D90(EnElf* this, PlayState* play) {
s32 pad; s32 pad;
s32 bgId; s32 bgId;
this->actor.floorHeight = BgCheck_EntityRaycastFloor5(play, &play->colCtx, &this->actor.floorPoly, &bgId, this->actor.floorHeight = BgCheck_EntityRaycastDown5(play, &play->colCtx, &this->actor.floorPoly, &bgId,
&this->actor, &this->actor.world.pos); &this->actor, &this->actor.world.pos);
this->actor.shape.shadowAlpha = 0x32; this->actor.shape.shadowAlpha = 50;
} }
// move to talk to player // move to talk to player

View file

@ -131,7 +131,7 @@ void EnEncount1_SpawnLeevers(EnEncount1* this, PlayState* play) {
spawnPos.y = player->actor.floorHeight + 120.0f; spawnPos.y = player->actor.floorHeight + 120.0f;
spawnPos.z = player->actor.world.pos.z + Math_CosS(spawnAngle) * spawnDist; spawnPos.z = player->actor.world.pos.z + Math_CosS(spawnAngle) * spawnDist;
floorY = BgCheck_EntityRaycastFloor4(&play->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos); floorY = BgCheck_EntityRaycastDown4(&play->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos);
if (floorY <= BGCHECK_Y_MIN) { if (floorY <= BGCHECK_Y_MIN) {
break; break;
} }
@ -192,7 +192,7 @@ void EnEncount1_SpawnTektites(EnEncount1* this, PlayState* play) {
spawnPos.x = this->actor.world.pos.x + Rand_CenteredFloat(50.0f); spawnPos.x = this->actor.world.pos.x + Rand_CenteredFloat(50.0f);
spawnPos.y = this->actor.world.pos.y + 120.0f; spawnPos.y = this->actor.world.pos.y + 120.0f;
spawnPos.z = this->actor.world.pos.z + Rand_CenteredFloat(50.0f); spawnPos.z = this->actor.world.pos.z + Rand_CenteredFloat(50.0f);
floorY = BgCheck_EntityRaycastFloor4(&play->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos); floorY = BgCheck_EntityRaycastDown4(&play->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos);
if (floorY <= BGCHECK_Y_MIN) { if (floorY <= BGCHECK_Y_MIN) {
return; return;
} }
@ -266,7 +266,7 @@ void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, PlayState* play) {
spawnPos.y = player->actor.floorHeight + 120.0f; spawnPos.y = player->actor.floorHeight + 120.0f;
spawnPos.z = spawnPos.z =
player->actor.world.pos.z + (Math_CosS(spawnAngle) * spawnDist) + Rand_CenteredFloat(40.0f); player->actor.world.pos.z + (Math_CosS(spawnAngle) * spawnDist) + Rand_CenteredFloat(40.0f);
floorY = BgCheck_EntityRaycastFloor4(&play->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos); floorY = BgCheck_EntityRaycastDown4(&play->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos);
if (floorY <= BGCHECK_Y_MIN) { if (floorY <= BGCHECK_Y_MIN) {
break; break;
} }

View file

@ -669,7 +669,7 @@ void EnFish_UpdateCutscene(EnFish* this, PlayState* play) {
this->actor.world.pos.z = (endPos.z - startPos.z) * progress + startPos.z; this->actor.world.pos.z = (endPos.z - startPos.z) * progress + startPos.z;
this->actor.floorHeight = this->actor.floorHeight =
BgCheck_EntityRaycastFloor4(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &this->actor.world.pos); BgCheck_EntityRaycastDown4(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &this->actor.world.pos);
} }
// Update functions and Draw // Update functions and Draw

View file

@ -360,7 +360,7 @@ s32 EnGoroiwa_MoveDownToNextWaypoint(EnGoroiwa* this, PlayState* play) {
f32 yDistToFloor; f32 yDistToFloor;
s32 quakeIdx; s32 quakeIdx;
CollisionPoly* floorPoly; CollisionPoly* floorPoly;
Vec3f raycastFrom; Vec3f checkPos;
f32 floorY; f32 floorY;
s32 pad2; s32 pad2;
s32 floorBgId; s32 floorBgId;
@ -386,11 +386,11 @@ s32 EnGoroiwa_MoveDownToNextWaypoint(EnGoroiwa* this, PlayState* play) {
} }
this->rollRotSpeed = 0.0f; this->rollRotSpeed = 0.0f;
if (!(this->stateFlags & ENGOROIWA_IN_WATER)) { if (!(this->stateFlags & ENGOROIWA_IN_WATER)) {
raycastFrom.x = this->actor.world.pos.x; checkPos.x = this->actor.world.pos.x;
raycastFrom.y = this->actor.world.pos.y + 50.0f; checkPos.y = this->actor.world.pos.y + 50.0f;
raycastFrom.z = this->actor.world.pos.z; checkPos.z = this->actor.world.pos.z;
floorY = BgCheck_EntityRaycastFloor5(play, &play->colCtx, &floorPoly, &floorBgId, &this->actor, floorY =
&raycastFrom); BgCheck_EntityRaycastDown5(play, &play->colCtx, &floorPoly, &floorBgId, &this->actor, &checkPos);
yDistToFloor = floorY - (this->actor.world.pos.y - 59.5f); yDistToFloor = floorY - (this->actor.world.pos.y - 59.5f);
if (fabsf(yDistToFloor) < 15.0f) { if (fabsf(yDistToFloor) < 15.0f) {
dustPos.x = this->actor.world.pos.x; dustPos.x = this->actor.world.pos.x;
@ -723,7 +723,7 @@ void EnGoroiwa_Update(Actor* thisx, PlayState* play) {
EnGoroiwa* this = (EnGoroiwa*)thisx; EnGoroiwa* this = (EnGoroiwa*)thisx;
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
s32 pad; s32 pad;
s32 sp30; s32 bgId;
if (!(player->stateFlags1 & (PLAYER_STATE1_6 | PLAYER_STATE1_7 | PLAYER_STATE1_28 | PLAYER_STATE1_29))) { if (!(player->stateFlags1 & (PLAYER_STATE1_6 | PLAYER_STATE1_7 | PLAYER_STATE1_28 | PLAYER_STATE1_29))) {
if (this->collisionDisabledTimer > 0) { if (this->collisionDisabledTimer > 0) {
@ -736,7 +736,7 @@ void EnGoroiwa_Update(Actor* thisx, PlayState* play) {
UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4); UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4);
break; break;
case 0: case 0:
this->actor.floorHeight = BgCheck_EntityRaycastFloor4(&play->colCtx, &this->actor.floorPoly, &sp30, this->actor.floorHeight = BgCheck_EntityRaycastDown4(&play->colCtx, &this->actor.floorPoly, &bgId,
&this->actor, &this->actor.world.pos); &this->actor, &this->actor.world.pos);
break; break;
} }

View file

@ -2841,7 +2841,7 @@ s32 EnHorse_CalcFloorHeight(EnHorse* this, PlayState* play, Vec3f* pos, Collisio
WaterBox* waterBox; WaterBox* waterBox;
*floorPoly = NULL; *floorPoly = NULL;
*floorHeight = BgCheck_EntityRaycastFloor3(&play->colCtx, floorPoly, &bgId, pos); *floorHeight = BgCheck_EntityRaycastDown3(&play->colCtx, floorPoly, &bgId, pos);
if (*floorHeight == BGCHECK_Y_MIN) { if (*floorHeight == BGCHECK_Y_MIN) {
return 1; // No floor return 1; // No floor
@ -2852,7 +2852,7 @@ s32 EnHorse_CalcFloorHeight(EnHorse* this, PlayState* play, Vec3f* pos, Collisio
return 2; // Water return 2; // Water
} }
if ((*floorPoly)->normal.y * COLPOLY_NORMAL_FRAC < 0.81915206f || // cos(35 degrees) if (COLPOLY_GET_NORMAL((*floorPoly)->normal.y) < 0.81915206f || // cos(35 degrees)
SurfaceType_IsHorseBlocked(&play->colCtx, *floorPoly, bgId) || SurfaceType_IsHorseBlocked(&play->colCtx, *floorPoly, bgId) ||
SurfaceType_GetFloorType(&play->colCtx, *floorPoly, bgId) == FLOOR_TYPE_7) { SurfaceType_GetFloorType(&play->colCtx, *floorPoly, bgId) == FLOOR_TYPE_7) {
return 3; // Horse blocked surface return 3; // Horse blocked surface
@ -2957,9 +2957,9 @@ void EnHorse_CheckFloors(EnHorse* this, PlayState* play) {
floorSlope = RAD_TO_BINANG(Math_FAtan2F(this->yBack - this->yFront, 60.0f)); floorSlope = RAD_TO_BINANG(Math_FAtan2F(this->yBack - this->yFront, 60.0f));
if (this->actor.floorPoly != 0) { if (this->actor.floorPoly != 0) {
nx = this->actor.floorPoly->normal.x * COLPOLY_NORMAL_FRAC; nx = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x);
ny = this->actor.floorPoly->normal.y * COLPOLY_NORMAL_FRAC; ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y);
nz = this->actor.floorPoly->normal.z * COLPOLY_NORMAL_FRAC; nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z);
pos = frontPos; pos = frontPos;
pos.y = this->yFront; pos.y = this->yFront;
dist = Math3D_DistPlaneToPos(nx, ny, nz, this->actor.floorPoly->dist, &pos); dist = Math3D_DistPlaneToPos(nx, ny, nz, this->actor.floorPoly->dist, &pos);
@ -3225,7 +3225,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) {
obstaclePos.y = this->actor.world.pos.y + 120.0f; obstaclePos.y = this->actor.world.pos.y + 120.0f;
obstaclePos.z += intersectDist * Math_CosS(this->actor.world.rot.y); obstaclePos.z += intersectDist * Math_CosS(this->actor.world.rot.y);
obstacleTop = obstaclePos; obstacleTop = obstaclePos;
obstacleTop.y = BgCheck_EntityRaycastFloor3(&play->colCtx, &obstacleFloor, &bgId, &obstaclePos); obstacleTop.y = BgCheck_EntityRaycastDown3(&play->colCtx, &obstacleFloor, &bgId, &obstaclePos);
if (obstacleTop.y == BGCHECK_Y_MIN) { if (obstacleTop.y == BGCHECK_Y_MIN) {
return; return;
} }
@ -3234,13 +3234,12 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) {
return; return;
} }
if (Math3D_DistPlaneToPos(this->actor.floorPoly->normal.x * COLPOLY_NORMAL_FRAC, if (Math3D_DistPlaneToPos(
this->actor.floorPoly->normal.y * COLPOLY_NORMAL_FRAC, COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x), COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y),
this->actor.floorPoly->normal.z * COLPOLY_NORMAL_FRAC, this->actor.floorPoly->dist, COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z), this->actor.floorPoly->dist, &obstacleTop) < -40.0f &&
&obstacleTop) < -40.0f && Math3D_DistPlaneToPos(COLPOLY_GET_NORMAL(obstacleFloor->normal.x), COLPOLY_GET_NORMAL(obstacleFloor->normal.y),
Math3D_DistPlaneToPos( COLPOLY_GET_NORMAL(obstacleFloor->normal.z), obstacleFloor->dist,
obstacleFloor->normal.x * COLPOLY_NORMAL_FRAC, obstacleFloor->normal.y * COLPOLY_NORMAL_FRAC, &this->actor.world.pos) > 40.0f) {
obstacleFloor->normal.z * COLPOLY_NORMAL_FRAC, obstacleFloor->dist, &this->actor.world.pos) > 40.0f) {
if (movingFast == true && this->action != ENHORSE_ACT_STOPPING) { if (movingFast == true && this->action != ENHORSE_ACT_STOPPING) {
this->stateFlags |= ENHORSE_FORCE_REVERSING; this->stateFlags |= ENHORSE_FORCE_REVERSING;
EnHorse_StartBraking(this, play); EnHorse_StartBraking(this, play);
@ -3249,7 +3248,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) {
return; return;
} }
ny = obstacleFloor->normal.y * COLPOLY_NORMAL_FRAC; ny = COLPOLY_GET_NORMAL(obstacleFloor->normal.y);
if (ny < 0.81915206f || // cos(35 degrees) if (ny < 0.81915206f || // cos(35 degrees)
(SurfaceType_IsHorseBlocked(&play->colCtx, obstacleFloor, bgId) != 0) || (SurfaceType_IsHorseBlocked(&play->colCtx, obstacleFloor, bgId) != 0) ||
(SurfaceType_GetFloorType(&play->colCtx, obstacleFloor, bgId) == FLOOR_TYPE_7)) { (SurfaceType_GetFloorType(&play->colCtx, obstacleFloor, bgId) == FLOOR_TYPE_7)) {
@ -3275,7 +3274,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) {
} }
obstacleTop = obstaclePos; obstacleTop = obstaclePos;
obstacleTop.y = BgCheck_EntityRaycastFloor3(&play->colCtx, &obstacleFloor, &bgId, &obstaclePos); obstacleTop.y = BgCheck_EntityRaycastDown3(&play->colCtx, &obstacleFloor, &bgId, &obstaclePos);
if (obstacleTop.y == BGCHECK_Y_MIN) { if (obstacleTop.y == BGCHECK_Y_MIN) {
return; return;
} }
@ -3286,7 +3285,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) {
return; return;
} }
ny = obstacleFloor->normal.y * COLPOLY_NORMAL_FRAC; ny = COLPOLY_GET_NORMAL(obstacleFloor->normal.y);
if (ny < 0.81915206f || // cos(35 degrees) if (ny < 0.81915206f || // cos(35 degrees)
SurfaceType_IsHorseBlocked(&play->colCtx, obstacleFloor, bgId) || SurfaceType_IsHorseBlocked(&play->colCtx, obstacleFloor, bgId) ||
SurfaceType_GetFloorType(&play->colCtx, obstacleFloor, bgId) == FLOOR_TYPE_7) { SurfaceType_GetFloorType(&play->colCtx, obstacleFloor, bgId) == FLOOR_TYPE_7) {

View file

@ -270,19 +270,16 @@ void func_80A68DB0(EnHorseGanon* this, PlayState* play) {
void func_80A68E14(EnHorseGanon* this, PlayState* play) { void func_80A68E14(EnHorseGanon* this, PlayState* play) {
s32 pad; s32 pad;
CollisionPoly* col; CollisionPoly* poly;
f32 temp_ret; s32 pad2;
Vec3f v; Vec3f checkPos;
s32 temp1; s32 bgId;
v.x = Math_SinS(this->actor.shape.rot.y) * 30.0f + this->actor.world.pos.x; checkPos.x = Math_SinS(this->actor.shape.rot.y) * 30.0f + this->actor.world.pos.x;
v.y = this->actor.world.pos.y + 60.0f; checkPos.y = this->actor.world.pos.y + 60.0f;
v.z = Math_CosS(this->actor.shape.rot.y) * 30.0f + this->actor.world.pos.z; checkPos.z = Math_CosS(this->actor.shape.rot.y) * 30.0f + this->actor.world.pos.z;
this->unk_1F4 = BgCheck_EntityRaycastDown3(&play->colCtx, &poly, &bgId, &checkPos);
temp_ret = BgCheck_EntityRaycastFloor3(&play->colCtx, &col, &temp1, &v); this->actor.shape.rot.x = RAD_TO_BINANG(Math_FAtan2F(this->actor.world.pos.y - this->unk_1F4, 30.0f));
this->unk_1F4 = temp_ret;
this->actor.shape.rot.x = RAD_TO_BINANG(Math_FAtan2F(this->actor.world.pos.y - temp_ret, 30.0f));
} }
void EnHorseGanon_Update(Actor* thisx, PlayState* play) { void EnHorseGanon_Update(Actor* thisx, PlayState* play) {

View file

@ -557,15 +557,15 @@ void EnHorseNormal_WaitClone(EnHorseNormal* this, PlayState* play) {
void func_80A6C8E0(EnHorseNormal* this, PlayState* play) { void func_80A6C8E0(EnHorseNormal* this, PlayState* play) {
s32 pad; s32 pad;
CollisionPoly* sp38; CollisionPoly* groundPoly;
s32 pad2; s32 pad2;
Vec3f sp28; Vec3f checkPos;
s32 sp24; s32 bgId;
sp28.x = (Math_SinS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.x; checkPos.x = (Math_SinS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.x;
sp28.y = this->actor.world.pos.y + 60.0f; checkPos.y = this->actor.world.pos.y + 60.0f;
sp28.z = (Math_CosS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.z; checkPos.z = (Math_CosS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.z;
this->unk_220 = BgCheck_EntityRaycastFloor3(&play->colCtx, &sp38, &sp24, &sp28); this->unk_220 = BgCheck_EntityRaycastDown3(&play->colCtx, &groundPoly, &bgId, &checkPos);
this->actor.shape.rot.x = RAD_TO_BINANG(Math_FAtan2F(this->actor.world.pos.y - this->unk_220, 30.0f)); this->actor.shape.rot.x = RAD_TO_BINANG(Math_FAtan2F(this->actor.world.pos.y - this->unk_220, 30.0f));
} }

View file

@ -217,13 +217,13 @@ void func_80A6DE38(EnHorseZelda* this, PlayState* play) {
s32 pad; s32 pad;
CollisionPoly* poly; CollisionPoly* poly;
s32 pad2; s32 pad2;
Vec3f pos; Vec3f checkPos;
s32 bgId; s32 bgId;
pos.x = (Math_SinS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.x; checkPos.x = (Math_SinS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.x;
pos.y = this->actor.world.pos.y + 60.0f; checkPos.y = this->actor.world.pos.y + 60.0f;
pos.z = (Math_CosS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.z; checkPos.z = (Math_CosS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.z;
this->unk_1F4 = BgCheck_EntityRaycastFloor3(&play->colCtx, &poly, &bgId, &pos); this->unk_1F4 = BgCheck_EntityRaycastDown3(&play->colCtx, &poly, &bgId, &checkPos);
this->actor.shape.rot.x = RAD_TO_BINANG(Math_FAtan2F(this->actor.world.pos.y - this->unk_1F4, 30.0f)); this->actor.shape.rot.x = RAD_TO_BINANG(Math_FAtan2F(this->actor.world.pos.y - this->unk_1F4, 30.0f));
} }

View file

@ -112,14 +112,14 @@ void EnIshi_InitCollider(Actor* thisx, PlayState* play) {
s32 EnIshi_SnapToFloor(EnIshi* this, PlayState* play, f32 arg2) { s32 EnIshi_SnapToFloor(EnIshi* this, PlayState* play, f32 arg2) {
CollisionPoly* poly; CollisionPoly* poly;
Vec3f pos; Vec3f checkPos;
s32 bgId; s32 bgId;
f32 floorY; f32 floorY;
pos.x = this->actor.world.pos.x; checkPos.x = this->actor.world.pos.x;
pos.y = this->actor.world.pos.y + 30.0f; checkPos.y = this->actor.world.pos.y + 30.0f;
pos.z = this->actor.world.pos.z; checkPos.z = this->actor.world.pos.z;
floorY = BgCheck_EntityRaycastFloor4(&play->colCtx, &poly, &bgId, &this->actor, &pos); floorY = BgCheck_EntityRaycastDown4(&play->colCtx, &poly, &bgId, &this->actor, &checkPos);
if (floorY > BGCHECK_Y_MIN) { if (floorY > BGCHECK_Y_MIN) {
this->actor.world.pos.y = floorY + arg2; this->actor.world.pos.y = floorY + arg2;
Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos);

View file

@ -99,7 +99,7 @@ void EnKusa_SetupAction(EnKusa* this, EnKusaActionFunc actionFunc) {
s32 EnKusa_SnapToFloor(EnKusa* this, PlayState* play, f32 yOffset) { s32 EnKusa_SnapToFloor(EnKusa* this, PlayState* play, f32 yOffset) {
s32 pad; s32 pad;
CollisionPoly* poly; CollisionPoly* groundPoly;
Vec3f pos; Vec3f pos;
s32 bgId; s32 bgId;
f32 floorY; f32 floorY;
@ -108,7 +108,7 @@ s32 EnKusa_SnapToFloor(EnKusa* this, PlayState* play, f32 yOffset) {
pos.y = this->actor.world.pos.y + 30.0f; pos.y = this->actor.world.pos.y + 30.0f;
pos.z = this->actor.world.pos.z; pos.z = this->actor.world.pos.z;
floorY = BgCheck_EntityRaycastFloor4(&play->colCtx, &poly, &bgId, &this->actor, &pos); floorY = BgCheck_EntityRaycastDown4(&play->colCtx, &groundPoly, &bgId, &this->actor, &pos);
if (floorY > BGCHECK_Y_MIN) { if (floorY > BGCHECK_Y_MIN) {
this->actor.world.pos.y = floorY + yOffset; this->actor.world.pos.y = floorY + yOffset;

View file

@ -74,7 +74,7 @@ void EnNwc_ChickNoop(EnNwcChick* chick, EnNwc* this, PlayState* play) {
} }
void EnNwc_ChickBgCheck(EnNwcChick* chick, PlayState* play) { void EnNwc_ChickBgCheck(EnNwcChick* chick, PlayState* play) {
CollisionPoly* outPoly; CollisionPoly* groundPoly;
s32 bgId; s32 bgId;
Vec3f outPos; Vec3f outPos;
f32 dy; f32 dy;
@ -90,7 +90,7 @@ void EnNwc_ChickBgCheck(EnNwcChick* chick, PlayState* play) {
//! @bug The use of outPos here is totally wrong. Even if it didn't get overwritten //! @bug The use of outPos here is totally wrong. Even if it didn't get overwritten
// by the wall check, it should add an offset to the y-value so the raycast // by the wall check, it should add an offset to the y-value so the raycast
// doesn't go through the floor and cause the chicks to ignore all floors. // doesn't go through the floor and cause the chicks to ignore all floors.
chick->floorY = BgCheck_EntityRaycastFloor3(&play->colCtx, &outPoly, &bgId, &outPos); chick->floorY = BgCheck_EntityRaycastDown3(&play->colCtx, &groundPoly, &bgId, &outPos);
dy = chick->floorY - chick->pos.y; dy = chick->floorY - chick->pos.y;
if ((0.0f <= dy) && (dy < 40.0f)) { if ((0.0f <= dy) && (dy < 40.0f)) {
chick->pos.y = chick->floorY; chick->pos.y = chick->floorY;

View file

@ -133,7 +133,7 @@ void EnOkuta_Init(Actor* thisx, PlayState* play) {
this->numShots = 1; this->numShots = 1;
} }
thisx->floorHeight = thisx->floorHeight =
BgCheck_EntityRaycastFloor4(&play->colCtx, &thisx->floorPoly, &floorBgId, thisx, &thisx->world.pos); BgCheck_EntityRaycastDown4(&play->colCtx, &thisx->floorPoly, &floorBgId, thisx, &thisx->world.pos);
//! @bug calls WaterBox_GetSurfaceImpl directly //! @bug calls WaterBox_GetSurfaceImpl directly
if (!WaterBox_GetSurfaceImpl(play, &play->colCtx, thisx->world.pos.x, thisx->world.pos.z, &ySurface, if (!WaterBox_GetSurfaceImpl(play, &play->colCtx, thisx->world.pos.x, thisx->world.pos.z, &ySurface,
&outWaterBox) || &outWaterBox) ||

View file

@ -424,7 +424,7 @@ void EnPoField_WaitForSpawn(EnPoField* this, PlayState* play) {
this->actor.world.pos.x = Math_SinS(player->actor.shape.rot.y) * spawnDist + player->actor.world.pos.x; this->actor.world.pos.x = Math_SinS(player->actor.shape.rot.y) * spawnDist + player->actor.world.pos.x;
this->actor.world.pos.z = Math_CosS(player->actor.shape.rot.y) * spawnDist + player->actor.world.pos.z; this->actor.world.pos.z = Math_CosS(player->actor.shape.rot.y) * spawnDist + player->actor.world.pos.z;
this->actor.world.pos.y = player->actor.world.pos.y + 1000.0f; this->actor.world.pos.y = player->actor.world.pos.y + 1000.0f;
this->actor.world.pos.y = BgCheck_EntityRaycastFloor4(&play->colCtx, &this->actor.floorPoly, &bgId, this->actor.world.pos.y = BgCheck_EntityRaycastDown4(&play->colCtx, &this->actor.floorPoly, &bgId,
&this->actor, &this->actor.world.pos); &this->actor, &this->actor.world.pos);
if (this->actor.world.pos.y != BGCHECK_Y_MIN) { if (this->actor.world.pos.y != BGCHECK_Y_MIN) {
this->actor.shape.rot.y = Actor_WorldYawTowardActor(&this->actor, &player->actor); this->actor.shape.rot.y = Actor_WorldYawTowardActor(&this->actor, &player->actor);

View file

@ -1195,14 +1195,14 @@ void EnPoSisters_Update(Actor* thisx, PlayState* play) {
Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 0.0f, Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 0.0f,
UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2); UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2);
} else { } else {
Vec3f vec; Vec3f checkPos;
s32 sp34; s32 bgId;
vec.x = this->actor.world.pos.x; checkPos.x = this->actor.world.pos.x;
vec.y = this->actor.world.pos.y + 10.0f; checkPos.y = this->actor.world.pos.y + 10.0f;
vec.z = this->actor.world.pos.z; checkPos.z = this->actor.world.pos.z;
this->actor.floorHeight = this->actor.floorHeight =
BgCheck_EntityRaycastFloor4(&play->colCtx, &this->actor.floorPoly, &sp34, &this->actor, &vec); BgCheck_EntityRaycastDown4(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &checkPos);
} }
Collider_UpdateCylinder(&this->actor, &this->collider); Collider_UpdateCylinder(&this->actor, &this->collider);

View file

@ -984,8 +984,8 @@ void func_80AE089C(EnPoh* this) {
void EnPoh_UpdateLiving(Actor* thisx, PlayState* play) { void EnPoh_UpdateLiving(Actor* thisx, PlayState* play) {
EnPoh* this = (EnPoh*)thisx; EnPoh* this = (EnPoh*)thisx;
s32 pad; s32 pad;
Vec3f vec; Vec3f checkPos;
s32 sp38; s32 bgId;
if (this->colliderSph.base.atFlags & AT_HIT) { if (this->colliderSph.base.atFlags & AT_HIT) {
this->colliderSph.base.atFlags &= ~AT_HIT; this->colliderSph.base.atFlags &= ~AT_HIT;
@ -1013,11 +1013,11 @@ void EnPoh_UpdateLiving(Actor* thisx, PlayState* play) {
this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.shape.rot.y = this->actor.world.rot.y;
} }
} }
vec.x = this->actor.world.pos.x; checkPos.x = this->actor.world.pos.x;
vec.y = this->actor.world.pos.y + 20.0f; checkPos.y = this->actor.world.pos.y + 20.0f;
vec.z = this->actor.world.pos.z; checkPos.z = this->actor.world.pos.z;
this->actor.floorHeight = this->actor.floorHeight =
BgCheck_EntityRaycastFloor4(&play->colCtx, &this->actor.floorPoly, &sp38, &this->actor, &vec); BgCheck_EntityRaycastDown4(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &checkPos);
func_80AE089C(this); func_80AE089C(this);
this->actor.shape.shadowAlpha = this->lightColor.a; this->actor.shape.shadowAlpha = this->lightColor.a;
} }

View file

@ -204,7 +204,7 @@ void EnRiverSound_Update(Actor* thisx, PlayState* play) {
pos = &thisx->world.pos; pos = &thisx->world.pos;
if (EnRiverSound_GetSfxPos(SEGMENTED_TO_VIRTUAL(path->points), path->count, &player->actor.world.pos, pos)) { if (EnRiverSound_GetSfxPos(SEGMENTED_TO_VIRTUAL(path->points), path->count, &player->actor.world.pos, pos)) {
if (BgCheck_EntityRaycastFloor4(&play->colCtx, &thisx->floorPoly, &bgId, thisx, pos) != BGCHECK_Y_MIN) { if (BgCheck_EntityRaycastDown4(&play->colCtx, &thisx->floorPoly, &bgId, thisx, pos) != BGCHECK_Y_MIN) {
// Get the river sfx frequency based on the speed of the river current under the actor // Get the river sfx frequency based on the speed of the river current under the actor
this->sfxFreqIndex = SurfaceType_GetConveyorSpeed(&play->colCtx, thisx->floorPoly, bgId); this->sfxFreqIndex = SurfaceType_GetConveyorSpeed(&play->colCtx, thisx->floorPoly, bgId);
} else { } else {

View file

@ -156,7 +156,7 @@ void EnVali_Init(Actor* thisx, PlayState* play) {
this->actor.flags &= ~ACTOR_FLAG_0; this->actor.flags &= ~ACTOR_FLAG_0;
this->actor.floorHeight = this->actor.floorHeight =
BgCheck_EntityRaycastFloor4(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &this->actor.world.pos); BgCheck_EntityRaycastDown4(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &this->actor.world.pos);
this->actor.params = BARI_TYPE_NORMAL; this->actor.params = BARI_TYPE_NORMAL;
if (this->actor.floorHeight == BGCHECK_Y_MIN) { if (this->actor.floorHeight == BGCHECK_Y_MIN) {

View file

@ -218,7 +218,7 @@ void func_80B32804(EnWeiyer* this, PlayState* play) {
this->actor.world.pos.y += 0.5f; this->actor.world.pos.y += 0.5f;
this->actor.floorHeight = this->actor.floorHeight =
BgCheck_EntityRaycastFloor4(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &this->actor.world.pos); BgCheck_EntityRaycastDown4(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &this->actor.world.pos);
if (!WaterBox_GetSurfaceImpl(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, if (!WaterBox_GetSurfaceImpl(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z,
&this->actor.home.pos.y, &waterBox) || &this->actor.home.pos.y, &waterBox) ||

View file

@ -162,7 +162,7 @@ void EnWood02_Init(Actor* thisx, PlayState* play2) {
f32 actorScale; f32 actorScale;
PlayState* play = play2; PlayState* play = play2;
EnWood02* this = (EnWood02*)thisx; EnWood02* this = (EnWood02*)thisx;
CollisionPoly* outPoly; CollisionPoly* poly;
s32 bgId; s32 bgId;
f32 floorY; f32 floorY;
s16 extraRot; s16 extraRot;
@ -280,7 +280,7 @@ void EnWood02_Init(Actor* thisx, PlayState* play2) {
// Snap to floor, or remove if over void // Snap to floor, or remove if over void
this->actor.world.pos.y += 200.0f; this->actor.world.pos.y += 200.0f;
floorY = BgCheck_EntityRaycastFloor4(&play->colCtx, &outPoly, &bgId, &this->actor, &this->actor.world.pos); floorY = BgCheck_EntityRaycastDown4(&play->colCtx, &poly, &bgId, &this->actor, &this->actor.world.pos);
if (floorY > BGCHECK_Y_MIN) { if (floorY > BGCHECK_Y_MIN) {
this->actor.world.pos.y = floorY; this->actor.world.pos.y = floorY;

View file

@ -151,14 +151,14 @@ void ObjBean_InitDynaPoly(ObjBean* this, PlayState* play, CollisionHeader* colli
} }
void ObjBean_FindFloor(ObjBean* this, PlayState* play) { void ObjBean_FindFloor(ObjBean* this, PlayState* play) {
Vec3f vec; Vec3f checkPos;
s32 sp20; s32 bgId;
vec.x = this->dyna.actor.world.pos.x; checkPos.x = this->dyna.actor.world.pos.x;
vec.y = this->dyna.actor.world.pos.y + 29.999998f; checkPos.y = this->dyna.actor.world.pos.y + 29.999998f;
vec.z = this->dyna.actor.world.pos.z; checkPos.z = this->dyna.actor.world.pos.z;
this->dyna.actor.floorHeight = this->dyna.actor.floorHeight =
BgCheck_EntityRaycastFloor4(&play->colCtx, &this->dyna.actor.floorPoly, &sp20, &this->dyna.actor, &vec); BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &checkPos);
} }
void func_80B8EBC8(ObjBean* this) { void func_80B8EBC8(ObjBean* this) {

View file

@ -189,13 +189,13 @@ void func_80B967C0(ObjLift* this) {
void func_80B96840(ObjLift* this, PlayState* play) { void func_80B96840(ObjLift* this, PlayState* play) {
s32 pad; s32 pad;
s32 bgId; s32 bgId;
Vec3f sp2C; Vec3f pos;
Actor_MoveForward(&this->dyna.actor); Actor_MoveForward(&this->dyna.actor);
Math_Vec3f_Copy(&sp2C, &this->dyna.actor.prevPos); Math_Vec3f_Copy(&pos, &this->dyna.actor.prevPos);
sp2C.y += sMaxFallDistances[(this->dyna.actor.params >> 1) & 1]; pos.y += sMaxFallDistances[(this->dyna.actor.params >> 1) & 1];
this->dyna.actor.floorHeight = this->dyna.actor.floorHeight =
BgCheck_EntityRaycastFloor4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &sp2C); BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &pos);
if ((this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y) >= if ((this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y) >=
(sMaxFallDistances[(this->dyna.actor.params >> 1) & 1] - 0.001f)) { (sMaxFallDistances[(this->dyna.actor.params >> 1) & 1] - 0.001f)) {

View file

@ -333,7 +333,7 @@ void ObjOshihiki_SetFloors(ObjOshihiki* this, PlayState* play) {
floorPoly = &this->floorPolys[i]; floorPoly = &this->floorPolys[i];
floorBgId = &this->floorBgIds[i]; floorBgId = &this->floorBgIds[i];
this->floorHeights[i] = this->floorHeights[i] =
BgCheck_EntityRaycastFloor6(&play->colCtx, floorPoly, floorBgId, &this->dyna.actor, &colCheckPoint, 0.0f); BgCheck_EntityRaycastDown6(&play->colCtx, floorPoly, floorBgId, &this->dyna.actor, &colCheckPoint, 0.0f);
} }
} }

View file

@ -98,17 +98,17 @@ void ObjTsubo_ApplyGravity(ObjTsubo* this) {
} }
s32 ObjTsubo_SnapToFloor(ObjTsubo* this, PlayState* play) { s32 ObjTsubo_SnapToFloor(ObjTsubo* this, PlayState* play) {
CollisionPoly* floorPoly; CollisionPoly* groundPoly;
Vec3f pos; Vec3f pos;
s32 bgID; s32 bgId;
f32 floorY; f32 groundY;
pos.x = this->actor.world.pos.x; pos.x = this->actor.world.pos.x;
pos.y = this->actor.world.pos.y + 20.0f; pos.y = this->actor.world.pos.y + 20.0f;
pos.z = this->actor.world.pos.z; pos.z = this->actor.world.pos.z;
floorY = BgCheck_EntityRaycastFloor4(&play->colCtx, &floorPoly, &bgID, &this->actor, &pos); groundY = BgCheck_EntityRaycastDown4(&play->colCtx, &groundPoly, &bgId, &this->actor, &pos);
if (floorY > BGCHECK_Y_MIN) { if (groundY > BGCHECK_Y_MIN) {
this->actor.world.pos.y = floorY; this->actor.world.pos.y = groundY;
Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos);
return true; return true;
} else { } else {

View file

@ -4274,7 +4274,7 @@ Actor* Player_SpawnFairy(PlayState* play, Player* this, Vec3f* arg2, Vec3f* arg3
f32 func_808396F4(PlayState* play, Player* this, Vec3f* arg2, Vec3f* arg3, CollisionPoly** arg4, s32* arg5) { f32 func_808396F4(PlayState* play, Player* this, Vec3f* arg2, Vec3f* arg3, CollisionPoly** arg4, s32* arg5) {
func_808395DC(this, &this->actor.world.pos, arg2, arg3); func_808395DC(this, &this->actor.world.pos, arg2, arg3);
return BgCheck_EntityRaycastFloor3(&play->colCtx, arg4, arg5, arg3); return BgCheck_EntityRaycastDown3(&play->colCtx, arg4, arg5, arg3);
} }
f32 func_8083973C(PlayState* play, Player* this, Vec3f* arg2, Vec3f* arg3) { f32 func_8083973C(PlayState* play, Player* this, Vec3f* arg2, Vec3f* arg3) {
@ -4309,8 +4309,8 @@ s32 func_80839800(Player* this, PlayState* play) {
s32 frontRoom; s32 frontRoom;
Actor* attachedActor; Actor* attachedActor;
LinkAnimationHeader* sp5C; LinkAnimationHeader* sp5C;
CollisionPoly* sp58; CollisionPoly* groundPoly;
Vec3f sp4C; Vec3f checkPos;
if ((this->doorType != PLAYER_DOORTYPE_NONE) && if ((this->doorType != PLAYER_DOORTYPE_NONE) &&
(!(this->stateFlags1 & PLAYER_STATE1_11) || (!(this->stateFlags1 & PLAYER_STATE1_11) ||
@ -4428,13 +4428,14 @@ s32 func_80839800(Player* this, PlayState* play) {
Actor_DisableLens(play); Actor_DisableLens(play);
if (ENDOOR_GET_TYPE(doorActor) == DOOR_SCENEEXIT) { if (ENDOOR_GET_TYPE(doorActor) == DOOR_SCENEEXIT) {
sp4C.x = doorActor->world.pos.x - (sp6C * sp74); checkPos.x = doorActor->world.pos.x - (sp6C * sp74);
sp4C.y = doorActor->world.pos.y + 10.0f; checkPos.y = doorActor->world.pos.y + 10.0f;
sp4C.z = doorActor->world.pos.z - (sp6C * sp78); checkPos.z = doorActor->world.pos.z - (sp6C * sp78);
BgCheck_EntityRaycastFloor1(&play->colCtx, &sp58, &sp4C); BgCheck_EntityRaycastDown1(&play->colCtx, &groundPoly, &checkPos);
if (func_80839034(play, this, sp58, BGCHECK_SCENE)) { //! @bug groundPoly's bgId is not guaranteed to be BGCHECK_SCENE
if (func_80839034(play, this, groundPoly, BGCHECK_SCENE)) {
gSaveContext.entranceSpeed = 2.0f; gSaveContext.entranceSpeed = 2.0f;
gSaveContext.entranceSound = NA_SE_OC_DOOR_OPEN; gSaveContext.entranceSound = NA_SE_OC_DOOR_OPEN;
} }
@ -9766,7 +9767,7 @@ void func_80847BA0(PlayState* play, Player* this) {
f32 wallPolyNormalY = COLPOLY_GET_NORMAL(wallPoly->normal.y); f32 wallPolyNormalY = COLPOLY_GET_NORMAL(wallPoly->normal.y);
f32 wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); f32 wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z);
f32 wallHeight; f32 wallHeight;
CollisionPoly* sp7C; CollisionPoly* groundPoly;
CollisionPoly* sp78; CollisionPoly* sp78;
s32 sp74; s32 sp74;
Vec3f sp68; Vec3f sp68;
@ -9782,7 +9783,7 @@ void func_80847BA0(PlayState* play, Player* this) {
sp68.z = this->actor.world.pos.z - (spB0 * wallPolyNormalZ); sp68.z = this->actor.world.pos.z - (spB0 * wallPolyNormalZ);
sp68.y = this->actor.world.pos.y + this->ageProperties->unk_0C; sp68.y = this->actor.world.pos.y + this->ageProperties->unk_0C;
sp64 = BgCheck_EntityRaycastFloor1(&play->colCtx, &sp7C, &sp68); sp64 = BgCheck_EntityRaycastDown1(&play->colCtx, &groundPoly, &sp68);
wallHeight = sp64 - this->actor.world.pos.y; wallHeight = sp64 - this->actor.world.pos.y;
this->wallHeight = wallHeight; this->wallHeight = wallHeight;
@ -9800,7 +9801,7 @@ void func_80847BA0(PlayState* play, Player* this) {
this->wallHeight = 399.96002f; this->wallHeight = 399.96002f;
} else if (SurfaceType_CheckWallFlag0(&play->colCtx, wallPoly, this->actor.wallBgId) == 0) { } else if (SurfaceType_CheckWallFlag0(&play->colCtx, wallPoly, this->actor.wallBgId) == 0) {
if (this->ageProperties->unk_1C <= this->wallHeight) { if (this->ageProperties->unk_1C <= this->wallHeight) {
if (ABS(sp7C->normal.y) > 28000) { if (ABS(groundPoly->normal.y) > 28000) {
if (this->ageProperties->unk_14 <= this->wallHeight) { if (this->ageProperties->unk_14 <= this->wallHeight) {
spC7 = 4; spC7 = 4;
} else if (this->ageProperties->unk_18 <= this->wallHeight) { } else if (this->ageProperties->unk_18 <= this->wallHeight) {
@ -11386,7 +11387,7 @@ static struct_80832924 D_808548A8[] = {
void func_8084C5F8(Player* this, PlayState* play) { void func_8084C5F8(Player* this, PlayState* play) {
s32 temp; s32 temp;
f32* sp38; f32* sp38;
CollisionPoly* sp34; CollisionPoly* groundPoly;
s32 sp30; s32 sp30;
Vec3f sp24; Vec3f sp24;
@ -11416,8 +11417,8 @@ void func_8084C5F8(Player* this, PlayState* play) {
sp24.x = this->actor.world.pos.x; sp24.x = this->actor.world.pos.x;
sp24.y = this->actor.world.pos.y + 20.0f; sp24.y = this->actor.world.pos.y + 20.0f;
sp24.z = this->actor.world.pos.z; sp24.z = this->actor.world.pos.z;
if (BgCheck_EntityRaycastFloor3(&play->colCtx, &sp34, &sp30, &sp24) != 0.0f) { if (BgCheck_EntityRaycastDown3(&play->colCtx, &groundPoly, &sp30, &sp24) != 0.0f) {
this->unk_89E = SurfaceType_GetSfxType(&play->colCtx, sp34, sp30); this->unk_89E = SurfaceType_GetSfxType(&play->colCtx, groundPoly, sp30);
func_808328A0(this); func_808328A0(this);
} }
} }

View file

@ -51,9 +51,9 @@ void EffectSsDeadDs_Draw(PlayState* play, u32 index, EffectSs* this) {
s32 pad1; s32 pad1;
s32 pad2; s32 pad2;
MtxF mf; MtxF mf;
f32 temp; f32 yIntersect;
Vec3f pos; Vec3f pos;
CollisionPoly* floorPoly; CollisionPoly* groundPoly;
OPEN_DISPS(play->state.gfxCtx, "../z_eff_ss_dead_ds.c", 157); OPEN_DISPS(play->state.gfxCtx, "../z_eff_ss_dead_ds.c", 157);
@ -65,21 +65,21 @@ void EffectSsDeadDs_Draw(PlayState* play, u32 index, EffectSs* this) {
if (this->rTimer == 0) { if (this->rTimer == 0) {
Vec3s rpy; Vec3s rpy;
Vec3f sp44; Vec3f prevPos;
sp44.x = pos.x - this->velocity.x; prevPos.x = pos.x - this->velocity.x;
sp44.y = pos.y - this->velocity.y; prevPos.y = pos.y - this->velocity.y;
sp44.z = pos.z - this->velocity.z; prevPos.z = pos.z - this->velocity.z;
if (BgCheck_EntitySphVsWall1(&play->colCtx, &this->pos, &pos, &sp44, 1.5f, &floorPoly, 1.0f)) { if (BgCheck_EntitySphVsWall1(&play->colCtx, &this->pos, &pos, &prevPos, 1.5f, &groundPoly, 1.0f)) {
func_80038A28(floorPoly, this->pos.x, this->pos.y, this->pos.z, &mf); func_80038A28(groundPoly, this->pos.x, this->pos.y, this->pos.z, &mf);
Matrix_Put(&mf); Matrix_Put(&mf);
} else { } else {
pos.y++; pos.y++;
temp = BgCheck_EntityRaycastFloor1(&play->colCtx, &floorPoly, &pos); yIntersect = BgCheck_EntityRaycastDown1(&play->colCtx, &groundPoly, &pos);
if (floorPoly != NULL) { if (groundPoly != NULL) {
func_80038A28(floorPoly, this->pos.x, temp + 1.5f, this->pos.z, &mf); func_80038A28(groundPoly, this->pos.x, yIntersect + 1.5f, this->pos.z, &mf);
Matrix_Put(&mf); Matrix_Put(&mf);
} else { } else {
Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW);