1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-13 19:35:28 +00:00

Merge branch 'master' into doc_pause_menu

This commit is contained in:
Dragorn421 2022-08-30 21:37:59 +02:00
commit 0678609c48
No known key found for this signature in database
GPG key ID: 32B53D2D16FC4118
64 changed files with 1480 additions and 1257 deletions

View file

@ -1246,7 +1246,7 @@ OcarinaStaff sPlayingStaff;
OcarinaStaff sPlaybackStaff;
OcarinaStaff sRecordingStaff;
u32 sOcarinaUpdateTaskStart;
OcarinaStick sOcarinaInputStickRel;
OcarinaStick sOcarinaInputStickAdj;
u32 sOcarinaInputButtonCur;
u32 sOcarinaInputButtonStart;
u32 sOcarinaInputButtonPrev;
@ -1299,8 +1299,8 @@ void AudioOcarina_ReadControllerInput(void) {
PadMgr_RequestPadData(&gPadMgr, inputs, 0);
sOcarinaInputButtonCur = input->cur.button;
sOcarinaInputButtonPrev = ocarinaInputButtonPrev;
sOcarinaInputStickRel.x = input->rel.stick_x;
sOcarinaInputStickRel.y = input->rel.stick_y;
sOcarinaInputStickAdj.x = input->rel.stick_x;
sOcarinaInputStickAdj.y = input->rel.stick_y;
}
/**
@ -1719,11 +1719,11 @@ void AudioOcarina_PlayControllerInput(u8 unused) {
if (sRecordingState != OCARINA_RECORD_SCARECROW_SPAWN) {
// Bend the pitch of the note based on y control stick
sCurOcarinaBendIndex = sOcarinaInputStickRel.y;
sCurOcarinaBendIndex = sOcarinaInputStickAdj.y;
sCurOcarinaBendFreq = AudioOcarina_BendPitchTwoSemitones(sCurOcarinaBendIndex);
// Add vibrato of the ocarina note based on the x control stick
sCurOcarinaVibrato = ABS_ALT(sOcarinaInputStickRel.x) >> 2;
sCurOcarinaVibrato = ABS_ALT(sOcarinaInputStickAdj.x) >> 2;
// Sets vibrato to io port 6
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 6, sCurOcarinaVibrato);
} else {

View file

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

View file

@ -1,6 +1,29 @@
#include "global.h"
#include "vt.h"
u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* nodeList);
void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector);
s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos);
s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB,
Vec3f* posResult, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 chkDist,
u32 bccFlags);
void SSNodeList_Initialize(SSNodeList* this);
void SSNodeList_Alloc(PlayState* play, SSNodeList* this, s32 tblMax, s32 numPolys);
u16 SSNodeList_GetNextNodeIdx(SSNodeList* this);
void DynaPoly_Init(PlayState* play, DynaCollisionContext* dyna);
void DynaPoly_Alloc(PlayState* play, DynaCollisionContext* dyna);
f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown);
s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* outZ, Vec3f* pos, f32 radius,
CollisionPoly** outPoly, s32* outBgId, Actor* actor);
s32 BgCheck_CheckDynaCeiling(CollisionContext* colCtx, u16 xpFlags, f32* outY, Vec3f* pos, f32 chkDist,
CollisionPoly** outPoly, s32* outBgId, Actor* actor);
s32 BgCheck_CheckLineAgainstDyna(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
CollisionPoly** outPoly, f32* distSq, s32* outBgId, Actor* actor, f32 chkDist,
s32 bccFlags);
s32 BgCheck_SphVsFirstDynaPoly(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId,
Vec3f* center, f32 radius, Actor* actor, u16 bciFlags);
void BgCheck_ResetPolyCheckTbl(SSNodeList* nodeList, s32 numPolys);
#define SS_NULL 0xFFFF
// bccFlags
@ -24,6 +47,16 @@
#define COLPOLY_IGNORE_ENTITY (1 << 1)
#define COLPOLY_IGNORE_PROJECTILES (1 << 2)
// raycast down flags (downChkFlags)
#define BGCHECK_RAYCAST_DOWN_CHECK_CEILINGS (1 << 0)
#define BGCHECK_RAYCAST_DOWN_CHECK_WALLS (1 << 1)
#define BGCHECK_RAYCAST_DOWN_CHECK_FLOORS (1 << 2)
#define BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE (1 << 3) // stops checking dyna walls on finding first candidate result
#define BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY (1 << 4) // skips walls and ceilings with normal.y < 0
// raycast down groundChk flag. When enabled, search range is limited to floors and walls with a normal.y >= 0
#define BGCHECK_GROUND_CHECK_ON (1 << 0)
s32 D_80119D90[WALL_TYPE_MAX] = {
0, // WALL_TYPE_0
WALL_FLAG_0, // WALL_TYPE_1
@ -527,10 +560,10 @@ void StaticLookup_AddPoly(StaticLookup* lookup, CollisionContext* colCtx, Collis
* Locates the closest static poly directly underneath `pos`, starting at list `ssList`
* returns yIntersect of the closest poly, or `yIntersectMin`
* stores the pointer of the closest poly to `outPoly`
* if (flags & 1), ignore polys with a normal.y < 0 (from vertical walls to ceilings)
* if BGCHECK_GROUND_CHECK_ON is set, ignore polys with a normal.y < 0 (from vertical walls to ceilings)
*/
f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList* ssList, CollisionPoly** outPoly,
Vec3f* pos, f32 yIntersectMin, f32 chkDist, s32 flags) {
f32 BgCheck_RaycastDownStaticList(CollisionContext* colCtx, u16 xpFlags, SSList* ssList, CollisionPoly** outPoly,
Vec3f* pos, f32 yIntersectMin, f32 chkDist, s32 groundChk) {
SSNode* curNode;
s32 polyId;
f32 result;
@ -547,7 +580,7 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList
polyId = curNode->polyId;
if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[polyId].flags_vIA, xpFlags) ||
((flags & 1) && colCtx->colHeader->polyList[polyId].normal.y < 0)) {
((groundChk & BGCHECK_GROUND_CHECK_ON) && colCtx->colHeader->polyList[polyId].normal.y < 0)) {
if (curNode->next == SS_NULL) {
break;
}
@ -565,7 +598,6 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList
pos->z, &yIntersect, chkDist) == true) {
// if poly is closer to pos without going over
if (yIntersect < pos->y && result < yIntersect) {
result = yIntersect;
*outPoly = &colCtx->colHeader->polyList[polyId];
}
@ -584,31 +616,31 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList
* returns yIntersect of the closest poly, or `yIntersectMin`
* stores the pointer of the closest poly to `outPoly`
*/
f32 BgCheck_RaycastFloorStatic(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** poly,
Vec3f* pos, u32 arg5, f32 chkDist, f32 yIntersectMin) {
s32 flag; // skip polys with normal.y < 0
f32 BgCheck_RaycastDownStatic(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** poly,
Vec3f* pos, u32 downChkFlags, f32 chkDist, f32 yIntersectMin) {
f32 yIntersect = yIntersectMin;
s32 groundChk;
if (arg5 & 4) {
yIntersect = BgCheck_RaycastFloorStaticList(colCtx, xpFlags, &lookup->floor, poly, pos, yIntersect, chkDist, 0);
if (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_FLOORS) {
yIntersect = BgCheck_RaycastDownStaticList(colCtx, xpFlags, &lookup->floor, poly, pos, yIntersect, chkDist, 0);
}
if ((arg5 & 2) || (arg5 & 8)) {
flag = 0;
if (arg5 & 0x10) {
flag = 1;
if ((downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_WALLS) || (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE)) {
groundChk = 0;
if (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY) {
groundChk |= BGCHECK_GROUND_CHECK_ON;
}
yIntersect =
BgCheck_RaycastFloorStaticList(colCtx, xpFlags, &lookup->wall, poly, pos, yIntersect, chkDist, flag);
BgCheck_RaycastDownStaticList(colCtx, xpFlags, &lookup->wall, poly, pos, yIntersect, chkDist, groundChk);
}
if (arg5 & 1) {
flag = 0;
if (arg5 & 0x10) {
flag = 1;
if (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_CEILINGS) {
groundChk = 0;
if (downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY) {
groundChk |= BGCHECK_GROUND_CHECK_ON;
}
yIntersect =
BgCheck_RaycastFloorStaticList(colCtx, xpFlags, &lookup->ceiling, poly, pos, yIntersect, chkDist, flag);
BgCheck_RaycastDownStaticList(colCtx, xpFlags, &lookup->ceiling, poly, pos, yIntersect, chkDist, groundChk);
}
return yIntersect;
@ -1662,19 +1694,19 @@ s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos) {
}
/**
* Raycast Toward Floor
* Raycast Downward
* If `actor` != null, bgcheck will be skipped for that actor
* returns the yIntersect of the nearest poly found directly below `pos`, or BGCHECK_Y_MIN if no floor detected
* returns the poly found in `outPoly`, and the bgId of the entity in `outBgId`
*/
f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly,
s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 chkDist) {
f32 BgCheck_RaycastDownImpl(PlayState* play, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly,
s32* outBgId, Vec3f* pos, Actor* actor, u32 downChkFlags, f32 chkDist) {
f32 yIntersectDyna;
s32* temp_a0;
StaticLookup* lookupTbl;
Vec3f checkPos;
StaticLookup* lookup;
DynaRaycast dynaRaycast;
DynaRaycastDown dynaRaycastDown;
f32 yIntersect;
*outBgId = BGCHECK_SCENE;
@ -1697,25 +1729,26 @@ f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFl
checkPos.y -= colCtx->subdivLength.y;
continue;
}
yIntersect = BgCheck_RaycastFloorStatic(lookup, colCtx, xpFlags, outPoly, pos, arg7, chkDist, BGCHECK_Y_MIN);
yIntersect =
BgCheck_RaycastDownStatic(lookup, colCtx, xpFlags, outPoly, pos, downChkFlags, chkDist, BGCHECK_Y_MIN);
if (yIntersect > BGCHECK_Y_MIN) {
break;
}
checkPos.y -= colCtx->subdivLength.y;
}
dynaRaycast.colCtx = colCtx;
dynaRaycast.xpFlags = xpFlags;
dynaRaycast.yIntersect = yIntersect;
dynaRaycast.pos = pos;
dynaRaycast.actor = actor;
dynaRaycast.unk_20 = arg7;
dynaRaycast.chkDist = chkDist;
dynaRaycast.play = play;
dynaRaycast.resultPoly = outPoly;
dynaRaycast.bgId = outBgId;
dynaRaycastDown.colCtx = colCtx;
dynaRaycastDown.xpFlags = xpFlags;
dynaRaycastDown.yIntersect = yIntersect;
dynaRaycastDown.pos = pos;
dynaRaycastDown.actor = actor;
dynaRaycastDown.downChkFlags = downChkFlags;
dynaRaycastDown.chkDist = chkDist;
dynaRaycastDown.play = play;
dynaRaycastDown.resultPoly = outPoly;
dynaRaycastDown.bgId = outBgId;
yIntersectDyna = BgCheck_RaycastFloorDyna(&dynaRaycast);
yIntersectDyna = BgCheck_RaycastDownDyna(&dynaRaycastDown);
if (yIntersect < yIntersectDyna) {
yIntersect = yIntersectDyna;
@ -1728,133 +1761,171 @@ f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFl
}
/**
* Public raycast toward floor
* Public raycast downward, ground check (UNUSED)
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_CameraRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) {
f32 BgCheck_CameraRaycastDown1(CollisionContext* colCtx, CollisionPoly** outGroundPoly, Vec3f* pos) {
s32 bgId;
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_CAMERA, outPoly, &bgId, pos, NULL, 0x1C, 1.0f);
return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_CAMERA, outGroundPoly, &bgId, pos, NULL,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
1.0f);
}
/**
* Public raycast toward floor
* Public raycast downward, ground check
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) {
f32 BgCheck_EntityRaycastDown1(CollisionContext* colCtx, CollisionPoly** outGroundPoly, Vec3f* pos) {
s32 bgId;
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f);
return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outGroundPoly, &bgId, pos, NULL,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
1.0f);
}
/**
* Public raycast toward floor
* Public raycast downward, ground check
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) {
f32 BgCheck_EntityRaycastDown2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outGroundPoly, Vec3f* pos) {
s32 bgId;
return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f);
return BgCheck_RaycastDownImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outGroundPoly, &bgId, pos, NULL,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
1.0f);
}
/**
* Public raycast toward floor
* Public raycast downward, ground check
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor3(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) {
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, NULL, 0x1C, 1.0f);
f32 BgCheck_EntityRaycastDown3(CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId, Vec3f* pos) {
return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outGroundPoly, bgId, pos, NULL,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
1.0f);
}
/**
* Public raycast toward floor
* Public raycast downward, ground check
* If `actor` != null, bgcheck will be skipped for that actor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor4(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor,
Vec3f* pos) {
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f);
f32 BgCheck_EntityRaycastDown4(CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId, Actor* actor,
Vec3f* pos) {
return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outGroundPoly, bgId, pos, actor,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
1.0f);
}
/**
* Public raycast toward floor
* Public raycast downward, ground check
* If `actor` != null, bgcheck will be skipped for that actor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor5(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId,
Actor* actor, Vec3f* pos) {
return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f);
f32 BgCheck_EntityRaycastDown5(PlayState* play, CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId,
Actor* actor, Vec3f* pos) {
return BgCheck_RaycastDownImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outGroundPoly, bgId, pos, actor,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
1.0f);
}
/**
* Public raycast toward floor
* Public raycast downward, ground check
* If `actor` != null, bgcheck will be skipped for that actor
* `chkDist` is the distance beyond the poly's boundary where the check will still pass
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor6(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos,
f32 chkDist) {
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, chkDist);
f32 BgCheck_EntityRaycastDown6(CollisionContext* colCtx, CollisionPoly** outGroundPoly, s32* bgId, Actor* actor,
Vec3f* pos, f32 chkDist) {
return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outGroundPoly, bgId, pos, actor,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
chkDist);
}
/**
* Public raycast toward floor
* Public raycast downward, floor and exhaustive wall check (UNUSED)
* If `actor` != null, bgcheck will be skipped for that actor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor,
Vec3f* pos) {
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x06, 1.0f);
f32 BgCheck_EntityRaycastDown7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos) {
return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS, 1.0f);
}
/**
* Public raycast toward floor
* Public raycast downward, ground check
* `outGroundPoly` returns original value if no poly detected
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_AnyRaycastFloor1(CollisionContext* colCtx, CollisionPoly* outPoly, Vec3f* pos) {
CollisionPoly* tempPoly;
f32 BgCheck_AnyRaycastDown1(CollisionContext* colCtx, CollisionPoly* outGroundPoly, Vec3f* pos) {
CollisionPoly* checkResultPoly;
f32 result;
s32 bgId;
result = BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &tempPoly, &bgId, pos, NULL, 0x1C, 1.0f);
result = BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &checkResultPoly, &bgId, pos, NULL,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
1.0f);
if (tempPoly != NULL) {
*outPoly = *tempPoly;
if (checkResultPoly != NULL) {
*outGroundPoly = *checkResultPoly;
}
return result;
}
/**
* Public raycast toward floor
* Public raycast downward, ground check (UNUSED)
* `outGroundPoly` returns original value if no poly detected
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_AnyRaycastFloor2(CollisionContext* colCtx, CollisionPoly* outPoly, s32* bgId, Vec3f* pos) {
CollisionPoly* tempPoly;
f32 result = BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &tempPoly, bgId, pos, NULL, 0x1C, 1.0f);
f32 BgCheck_AnyRaycastDown2(CollisionContext* colCtx, CollisionPoly* outGroundPoly, s32* bgId, Vec3f* pos) {
CollisionPoly* checkResultPoly;
f32 result = BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_NONE, &checkResultPoly, bgId, pos, NULL,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS |
BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY,
1.0f);
if (tempPoly != NULL) {
*outPoly = *tempPoly;
if (checkResultPoly != NULL) {
*outGroundPoly = *checkResultPoly;
}
return result;
}
/**
* Public raycast toward floor
* Public raycast downward, floor and exhaustive wall check
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_CameraRaycastFloor2(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) {
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_CAMERA, outPoly, bgId, pos, NULL, 0x06, 1.0f);
f32 BgCheck_CameraRaycastDown2(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) {
return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_CAMERA, outPoly, bgId, pos, NULL,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS, 1.0f);
}
/**
* Public raycast toward floor
* Public raycast downward, exhaustive wall check (UNUSED)
* If `actor` != null, bgcheck will be skipped for that actor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor8(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor,
Vec3f* pos) {
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x02, 1.0f);
f32 BgCheck_EntityRaycastDownWalls(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor,
Vec3f* pos) {
return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS, 1.0f);
}
/**
* Public raycast toward floor
* Public raycast downward, floor and exhaustive wall check (UNUSED)
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor9(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) {
return BgCheck_RaycastFloorImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, NULL, 0x06, 1.0f);
f32 BgCheck_EntityRaycastDown9(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos) {
return BgCheck_RaycastDownImpl(NULL, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, NULL,
BGCHECK_RAYCAST_DOWN_CHECK_WALLS | BGCHECK_RAYCAST_DOWN_CHECK_FLOORS, 1.0f);
}
/**
@ -3014,52 +3085,54 @@ void DynaPoly_UpdateBgActorTransforms(PlayState* play, DynaCollisionContext* dyn
#define DYNA_RAYCAST_CEILINGS 4
/**
* Perform dyna poly raycast toward floor on a list of floor, wall, or ceiling polys
* Performs a downward raycast check on a list of floor, wall, or ceiling dyna polys
* `listType` specifies the poly list type (e.g. DYNA_RAYCAST_FLOORS)
*/
f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) {
f32 BgCheck_RaycastDownDynaList(DynaRaycastDown* dynaRaycastDown, u32 listType) {
CollisionPoly* polyList;
SSNode* curNode;
f32 result;
f32 yIntersect;
s16 id;
result = dynaRaycast->yIntersect;
if (dynaRaycast->ssList->head == SS_NULL) {
result = dynaRaycastDown->yIntersect;
if (dynaRaycastDown->ssList->head == SS_NULL) {
return result;
}
polyList = dynaRaycast->dyna->polyList;
curNode = &dynaRaycast->dyna->polyNodes.tbl[dynaRaycast->ssList->head];
polyList = dynaRaycastDown->dyna->polyList;
curNode = &dynaRaycastDown->dyna->polyNodes.tbl[dynaRaycastDown->ssList->head];
while (true) {
id = curNode->polyId;
if (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIA, dynaRaycast->xpFlags)) {
if (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIA, dynaRaycastDown->xpFlags)) {
if (curNode->next == SS_NULL) {
break;
} else {
curNode = &dynaRaycast->dyna->polyNodes.tbl[curNode->next];
curNode = &dynaRaycastDown->dyna->polyNodes.tbl[curNode->next];
continue;
}
}
if ((listType & (DYNA_RAYCAST_WALLS | DYNA_RAYCAST_CEILINGS)) && (dynaRaycast->unk_20 & 0x10) &&
if ((listType & (DYNA_RAYCAST_WALLS | DYNA_RAYCAST_CEILINGS)) &&
(dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_GROUND_ONLY) &&
COLPOLY_GET_NORMAL(polyList[id].normal.y) < 0.0f) {
if (curNode->next == SS_NULL) {
break;
} else {
curNode = &dynaRaycast->dyna->polyNodes.tbl[curNode->next];
curNode = &dynaRaycastDown->dyna->polyNodes.tbl[curNode->next];
continue;
}
}
if (CollisionPoly_CheckYIntersectApprox1(&polyList[id], dynaRaycast->dyna->vtxList, dynaRaycast->pos->x,
dynaRaycast->pos->z, &yIntersect, dynaRaycast->chkDist) == true &&
yIntersect < dynaRaycast->pos->y && result < yIntersect) {
if (CollisionPoly_CheckYIntersectApprox1(&polyList[id], dynaRaycastDown->dyna->vtxList, dynaRaycastDown->pos->x,
dynaRaycastDown->pos->z, &yIntersect,
dynaRaycastDown->chkDist) == true &&
yIntersect < dynaRaycastDown->pos->y && result < yIntersect) {
result = yIntersect;
*dynaRaycast->resultPoly = &dynaRaycast->dyna->polyList[id];
*dynaRaycastDown->resultPoly = &dynaRaycastDown->dyna->polyList[id];
}
if (curNode->next == SS_NULL) {
break;
} else {
curNode = &dynaRaycast->dyna->polyNodes.tbl[curNode->next];
curNode = &dynaRaycastDown->dyna->polyNodes.tbl[curNode->next];
continue;
}
}
@ -3067,10 +3140,10 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) {
}
/**
* Perform dyna poly raycast toward floor
* Performs a downward raycast check on dyna polys
* returns the yIntersect of the poly found, or BGCHECK_Y_MIN if no poly is found
*/
f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) {
f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown) {
s32 i;
f32 result;
f32 intersect2;
@ -3092,75 +3165,76 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) {
CollisionPoly* poly;
result = BGCHECK_Y_MIN;
*dynaRaycast->bgId = BGCHECK_SCENE;
*dynaRaycastDown->bgId = BGCHECK_SCENE;
for (i = 0; i < BG_ACTOR_MAX; i++) {
if (!(dynaRaycast->colCtx->dyna.bgActorFlags[i] & BGACTOR_IN_USE)) {
if (!(dynaRaycastDown->colCtx->dyna.bgActorFlags[i] & BGACTOR_IN_USE)) {
continue;
}
if (dynaRaycast->actor == dynaRaycast->colCtx->dyna.bgActors[i].actor ||
dynaRaycast->pos->y < dynaRaycast->colCtx->dyna.bgActors[i].minY ||
Math3D_XZInSphere(&dynaRaycast->colCtx->dyna.bgActors[i].boundingSphere, dynaRaycast->pos->x,
dynaRaycast->pos->z) == false) {
if (dynaRaycastDown->actor == dynaRaycastDown->colCtx->dyna.bgActors[i].actor ||
dynaRaycastDown->pos->y < dynaRaycastDown->colCtx->dyna.bgActors[i].minY ||
Math3D_XZInSphere(&dynaRaycastDown->colCtx->dyna.bgActors[i].boundingSphere, dynaRaycastDown->pos->x,
dynaRaycastDown->pos->z) == false) {
continue;
}
dynaRaycast->dyna = &dynaRaycast->colCtx->dyna;
if (dynaRaycast->unk_20 & BGCHECK_IGNORE_FLOOR) {
dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.floor;
intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_FLOORS);
dynaRaycastDown->dyna = &dynaRaycastDown->colCtx->dyna;
if (dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_FLOORS) {
dynaRaycastDown->ssList = &dynaRaycastDown->colCtx->dyna.bgActors[i].dynaLookup.floor;
intersect2 = BgCheck_RaycastDownDynaList(dynaRaycastDown, DYNA_RAYCAST_FLOORS);
if (dynaRaycast->yIntersect < intersect2) {
dynaRaycast->yIntersect = intersect2;
*dynaRaycast->bgId = i;
if (dynaRaycastDown->yIntersect < intersect2) {
dynaRaycastDown->yIntersect = intersect2;
*dynaRaycastDown->bgId = i;
result = intersect2;
}
}
if ((dynaRaycast->unk_20 & BGCHECK_IGNORE_WALL) ||
(*dynaRaycast->resultPoly == NULL && (dynaRaycast->unk_20 & 8))) {
dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.wall;
intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_WALLS);
if (dynaRaycast->yIntersect < intersect2) {
if ((dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_WALLS) ||
(*dynaRaycastDown->resultPoly == NULL &&
(dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_WALLS_SIMPLE))) {
dynaRaycastDown->ssList = &dynaRaycastDown->colCtx->dyna.bgActors[i].dynaLookup.wall;
intersect2 = BgCheck_RaycastDownDynaList(dynaRaycastDown, DYNA_RAYCAST_WALLS);
dynaRaycast->yIntersect = intersect2;
*dynaRaycast->bgId = i;
if (dynaRaycastDown->yIntersect < intersect2) {
dynaRaycastDown->yIntersect = intersect2;
*dynaRaycastDown->bgId = i;
result = intersect2;
}
}
if (dynaRaycast->unk_20 & BGCHECK_IGNORE_CEILING) {
dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.ceiling;
intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_CEILINGS);
if (dynaRaycast->yIntersect < intersect2) {
if (dynaRaycastDown->downChkFlags & BGCHECK_RAYCAST_DOWN_CHECK_CEILINGS) {
dynaRaycastDown->ssList = &dynaRaycastDown->colCtx->dyna.bgActors[i].dynaLookup.ceiling;
intersect2 = BgCheck_RaycastDownDynaList(dynaRaycastDown, DYNA_RAYCAST_CEILINGS);
dynaRaycast->yIntersect = intersect2;
*dynaRaycast->bgId = i;
if (dynaRaycastDown->yIntersect < intersect2) {
dynaRaycastDown->yIntersect = intersect2;
*dynaRaycastDown->bgId = i;
result = intersect2;
}
}
}
dynaActor = DynaPoly_GetActor(dynaRaycast->colCtx, *dynaRaycast->bgId);
if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->play != NULL)) {
pauseState = dynaRaycast->play->pauseCtx.state != PAUSE_STATE_OFF;
dynaActor = DynaPoly_GetActor(dynaRaycastDown->colCtx, *dynaRaycastDown->bgId);
if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycastDown->play != NULL)) {
pauseState = dynaRaycastDown->play->pauseCtx.state != PAUSE_STATE_OFF;
if (!pauseState) {
pauseState = dynaRaycast->play->pauseCtx.debugState != 0;
pauseState = dynaRaycastDown->play->pauseCtx.debugState != 0;
}
if (!pauseState && (dynaRaycast->colCtx->dyna.bgActorFlags[*dynaRaycast->bgId] & BGACTOR_1)) {
curTransform = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].curTransform;
if (!pauseState && (dynaRaycastDown->colCtx->dyna.bgActorFlags[*dynaRaycastDown->bgId] & BGACTOR_1)) {
curTransform = &dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].curTransform;
polyMin =
&dynaRaycast->dyna->polyList[dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].dynaLookup.polyStartIndex];
polyIndex = *dynaRaycast->resultPoly - polyMin;
poly = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].colHeader->polyList[polyIndex];
&dynaRaycastDown->dyna
->polyList[dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].dynaLookup.polyStartIndex];
polyIndex = *dynaRaycastDown->resultPoly - polyMin;
poly = &dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].colHeader->polyList[polyIndex];
SkinMatrix_SetTranslateRotateYXZScale(&srpMtx, curTransform->scale.x, curTransform->scale.y,
curTransform->scale.z, curTransform->rot.x, curTransform->rot.y,
curTransform->rot.z, curTransform->pos.x, curTransform->pos.y,
curTransform->pos.z);
vtxList = dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].colHeader->vtxList;
vtxList = dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].colHeader->vtxList;
for (i2 = 0; i2 < 3; i2++) {
Math_Vec3s_ToVec3f(&vtx, &vtxList[COLPOLY_VTX_INDEX(poly->vtxData[i2])]);
@ -3174,9 +3248,9 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) {
polyNorm.y *= 1.0f / magnitude;
polyNorm.z *= 1.0f / magnitude;
polyDist = -DOTXYZ(polyNorm, polyVtx[0]);
if (Math3D_TriChkPointParaYIntersectInsideTri(&polyVtx[0], &polyVtx[1], &polyVtx[2], polyNorm.x,
polyNorm.y, polyNorm.z, polyDist, dynaRaycast->pos->z,
dynaRaycast->pos->x, &intersect, dynaRaycast->chkDist)) {
if (Math3D_TriChkPointParaYIntersectInsideTri(
&polyVtx[0], &polyVtx[1], &polyVtx[2], polyNorm.x, polyNorm.y, polyNorm.z, polyDist,
dynaRaycastDown->pos->z, dynaRaycastDown->pos->x, &intersect, dynaRaycastDown->chkDist)) {
if (fabsf(intersect - result) < 1.0f) {
result = intersect;
@ -4174,9 +4248,9 @@ s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f3
for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes;
curWaterBox++) {
room = (curWaterBox->properties >> 13) & 0x3F;
if (room == (u32)play->roomCtx.curRoom.num || room == 0x3F) {
if ((curWaterBox->properties & 0x80000) == 0) {
room = WATERBOX_ROOM(curWaterBox->properties);
if (room == (u32)play->roomCtx.curRoom.num || room == WATERBOX_ROOM_ALL) {
if (!(curWaterBox->properties & WATERBOX_FLAG_19)) {
if (curWaterBox->xMin < x && x < curWaterBox->xMin + curWaterBox->xLength) {
if (curWaterBox->zMin < z && z < curWaterBox->zMin + curWaterBox->zLength) {
*outWaterBox = curWaterBox;
@ -4191,7 +4265,7 @@ s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f3
}
/**
* Gets the first active WaterBox at `pos` where WaterBox.properties & 0x80000 == 0
* Gets the first active WaterBox at `pos` with WATERBOX_FLAG_19 not set
* `surfaceChkDist` is the absolute y distance from the water surface to check
* returns the index of the waterbox found, or -1 if no waterbox is found
* `outWaterBox` returns the pointer to the waterbox found, or NULL if none is found
@ -4213,10 +4287,10 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos,
waterBox = &colHeader->waterBoxes[i];
room = WATERBOX_ROOM(waterBox->properties);
if (!(room == play->roomCtx.curRoom.num || room == 0x3F)) {
if (!(room == play->roomCtx.curRoom.num || room == WATERBOX_ROOM_ALL)) {
continue;
}
if (waterBox->properties & 0x80000) {
if (waterBox->properties & WATERBOX_FLAG_19) {
continue;
}
if (!(waterBox->xMin < pos->x && pos->x < waterBox->xMin + waterBox->xLength)) {
@ -4239,9 +4313,9 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos,
* WaterBox get BgCam index
*/
u32 WaterBox_GetBgCamIndex(CollisionContext* colCtx, WaterBox* waterBox) {
u32 prop = waterBox->properties >> 0;
u32 bgCamIndex = WATERBOX_BGCAM_INDEX(waterBox->properties);
return prop & 0xFF;
return bgCamIndex;
}
/**
@ -4261,15 +4335,15 @@ u16 WaterBox_GetBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox) {
/**
* WaterBox get lighting settings
*/
u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox) {
u32 prop = waterBox->properties >> 8;
u32 WaterBox_GetLightIndex(CollisionContext* colCtx, WaterBox* waterBox) {
u32 lightIndex = WATERBOX_LIGHT_INDEX(waterBox->properties);
return prop & 0x1F;
return lightIndex;
}
/**
* Get the water surface at point (`x`, `ySurface`, `z`). `ySurface` doubles as position y input
* same as WaterBox_GetSurfaceImpl, but tests if WaterBox properties & 0x80000 != 0
* same as WaterBox_GetSurfaceImpl, but tests if WATERBOX_FLAG_19 is set
* returns true if point is within the xz boundaries of an active water box, else false
* `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox
*/
@ -4284,9 +4358,9 @@ s32 func_800425B0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32*
for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes;
curWaterBox++) {
room = (curWaterBox->properties >> 0xD) & 0x3F;
if ((room == (u32)play->roomCtx.curRoom.num) || (room == 0x3F)) {
if ((curWaterBox->properties & 0x80000) != 0) {
room = WATERBOX_ROOM(curWaterBox->properties);
if ((room == (u32)play->roomCtx.curRoom.num) || (room == WATERBOX_ROOM_ALL)) {
if (curWaterBox->properties & WATERBOX_FLAG_19) {
if (curWaterBox->xMin < x && x < (curWaterBox->xMin + curWaterBox->xLength)) {
if (curWaterBox->zMin < z && z < (curWaterBox->zMin + curWaterBox->zLength)) {
*outWaterBox = curWaterBox;

View file

@ -233,7 +233,7 @@ s32 Camera_BGCheckInfo(Camera* camera, Vec3f* from, CamColChk* to) {
toNewPos = to->pos;
toNewPos.y += 5.0f;
floorPolyY = BgCheck_CameraRaycastFloor2(colCtx, &floorPoly, &floorBgId, &toNewPos);
floorPolyY = BgCheck_CameraRaycastDown2(colCtx, &floorPoly, &floorBgId, &toNewPos);
if ((to->pos.y - floorPolyY) > 5.0f) {
// if the y distance from the check point to the floor is more than 5 units
@ -293,7 +293,7 @@ s32 func_80043F94(Camera* camera, Vec3f* from, CamColChk* to) {
to->norm.z = -fromToNorm.z;
toNewPos = to->pos;
toNewPos.y += 5.0f;
floorY = BgCheck_CameraRaycastFloor2(colCtx, &floorPoly, &bgId, &toNewPos);
floorY = BgCheck_CameraRaycastDown2(colCtx, &floorPoly, &bgId, &toNewPos);
if ((to->pos.y - floorY) > 5.0f) {
// to is not on the ground or below it.
to->pos.x += to->norm.x;
@ -377,7 +377,7 @@ s32 Camera_CheckOOB(Camera* camera, Vec3f* from, Vec3f* to) {
f32 Camera_GetFloorYNorm(Camera* camera, Vec3f* floorNorm, Vec3f* chkPos, s32* bgId) {
s32 pad;
CollisionPoly* floorPoly;
f32 floorY = BgCheck_EntityRaycastFloor3(&camera->play->colCtx, &floorPoly, bgId, chkPos);
f32 floorY = BgCheck_EntityRaycastDown3(&camera->play->colCtx, &floorPoly, bgId, chkPos);
if (floorY == BGCHECK_Y_MIN) {
// no floor
@ -418,7 +418,7 @@ f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, s32* bgId) {
s32 i;
for (i = 3; i > 0; i--) {
floorY = BgCheck_CameraRaycastFloor2(colCtx, &floorPoly, bgId, pos);
floorY = BgCheck_CameraRaycastDown2(colCtx, &floorPoly, bgId, pos);
if (floorY == BGCHECK_Y_MIN ||
(camera->playerGroundY < floorY && !(COLPOLY_GET_NORMAL(floorPoly->normal.y) > 0.5f))) {
// no floor, or player is below the floor and floor is not considered steep
@ -492,7 +492,7 @@ Vec3s* Camera_GetBgCamFuncDataUnderPlayer(Camera* camera, u16* bgCamCount) {
Actor_GetWorldPosShapeRot(&playerPosShape, &camera->player->actor);
playerPosShape.pos.y += Player_GetHeight(camera->player);
if (BgCheck_EntityRaycastFloor3(&camera->play->colCtx, &floorPoly, &bgId, &playerPosShape.pos) == BGCHECK_Y_MIN) {
if (BgCheck_EntityRaycastDown3(&camera->play->colCtx, &floorPoly, &bgId, &playerPosShape.pos) == BGCHECK_Y_MIN) {
// no floor
return NULL;
}
@ -540,11 +540,11 @@ s32 Camera_GetWaterBoxBgCamIndex(Camera* camera, f32* waterY) {
}
/**
* Checks if `chkPos` is inside a waterbox. If there is no water box below `chkPos`
* or if `chkPos` is above the water surface, return BGCHECK_Y_MIN, output
* environment properites to `envProp` if `chkPos` is inside the waterbox.
* Checks if `chkPos` is inside a waterbox.
* If there is no water box below `chkPos` or if `chkPos` is above the water surface, return BGCHECK_Y_MIN.
* If `chkPos` is inside the waterbox, output light index to `lightIndex`.
*/
f32 Camera_GetWaterSurface(Camera* camera, Vec3f* chkPos, s32* envProp) {
f32 Camera_GetWaterSurface(Camera* camera, Vec3f* chkPos, s32* lightIndex) {
PosRot playerPosRot;
f32 waterY;
WaterBox* waterBox;
@ -563,7 +563,7 @@ f32 Camera_GetWaterSurface(Camera* camera, Vec3f* chkPos, s32* envProp) {
return BGCHECK_Y_MIN;
}
*envProp = WaterBox_GetLightSettingIndex(&camera->play->colCtx, waterBox);
*lightIndex = WaterBox_GetLightIndex(&camera->play->colCtx, waterBox);
return waterY;
}
@ -641,62 +641,55 @@ s16 func_80044ADC(Camera* camera, s16 yaw, s16 arg2) {
return temp_s0 + temp_s1;
}
Vec3f* Camera_CalcUpFromPitchYawRoll(Vec3f* dest, s16 pitch, s16 yaw, s16 roll) {
f32 sinPitch;
f32 cosPitch;
f32 sinYaw;
f32 cosYaw;
f32 sinNegRoll;
f32 cosNegRoll;
Vec3f spA4;
/**
* Calculates a new Up vector from the pitch, yaw, roll
*/
Vec3f* Camera_CalcUpFromPitchYawRoll(Vec3f* viewUp, s16 pitch, s16 yaw, s16 roll) {
f32 sinP = Math_SinS(pitch);
f32 cosP = Math_CosS(pitch);
f32 sinY = Math_SinS(yaw);
f32 cosY = Math_CosS(yaw);
f32 sinR = Math_SinS(-roll);
f32 cosR = Math_CosS(-roll);
Vec3f up;
Vec3f baseUp;
Vec3f u;
Vec3f rollMtxRow1;
Vec3f rollMtxRow2;
Vec3f rollMtxRow3;
f32 pad;
f32 sp54;
f32 sp4C;
f32 cosPitchCosYawSinRoll;
f32 negSinPitch;
f32 temp_f10_2;
f32 cosPitchcosYaw;
f32 temp_f14;
f32 negSinPitchSinYaw;
f32 negSinPitchCosYaw;
f32 cosPitchSinYaw;
f32 temp_f4_2;
f32 temp_f6;
f32 temp_f8;
f32 temp_f8_2;
f32 temp_f8_3;
sinPitch = Math_SinS(pitch);
cosPitch = Math_CosS(pitch);
sinYaw = Math_SinS(yaw);
cosYaw = Math_CosS(yaw);
negSinPitch = -sinPitch;
sinNegRoll = Math_SinS(-roll);
cosNegRoll = Math_CosS(-roll);
negSinPitchSinYaw = negSinPitch * sinYaw;
temp_f14 = 1.0f - cosNegRoll;
cosPitchSinYaw = cosPitch * sinYaw;
sp54 = SQ(cosPitchSinYaw);
sp4C = (cosPitchSinYaw * sinPitch) * temp_f14;
cosPitchcosYaw = cosPitch * cosYaw;
temp_f4_2 = ((1.0f - sp54) * cosNegRoll) + sp54;
cosPitchCosYawSinRoll = cosPitchcosYaw * sinNegRoll;
negSinPitchCosYaw = negSinPitch * cosYaw;
temp_f6 = (cosPitchcosYaw * cosPitchSinYaw) * temp_f14;
temp_f10_2 = sinPitch * sinNegRoll;
spA4.x = ((negSinPitchSinYaw * temp_f4_2) + (cosPitch * (sp4C - cosPitchCosYawSinRoll))) +
(negSinPitchCosYaw * (temp_f6 + temp_f10_2));
sp54 = SQ(sinPitch);
temp_f4_2 = (sinPitch * cosPitchcosYaw) * temp_f14;
temp_f8_3 = cosPitchSinYaw * sinNegRoll;
temp_f8 = sp4C + cosPitchCosYawSinRoll;
spA4.y = ((negSinPitchSinYaw * temp_f8) + (cosPitch * (((1.0f - sp54) * cosNegRoll) + sp54))) +
(negSinPitchCosYaw * (temp_f4_2 - temp_f8_3));
temp_f8_2 = temp_f6 - temp_f10_2;
spA4.z = ((negSinPitchSinYaw * temp_f8_2) + (cosPitch * (temp_f4_2 + temp_f8_3))) +
(negSinPitchCosYaw * (((1.0f - SQ(cosPitchcosYaw)) * cosNegRoll) + SQ(cosPitchcosYaw)));
*dest = spA4;
return dest;
// Axis to roll around
u.x = cosP * sinY;
u.y = sinP;
u.z = cosP * cosY;
// Matrix to apply the roll to the Up vector without roll
rollMtxRow1.x = ((1.0f - SQ(u.x)) * cosR) + SQ(u.x);
rollMtxRow1.y = ((u.x * u.y) * (1.0f - cosR)) - (u.z * sinR);
rollMtxRow1.z = ((u.z * u.x) * (1.0f - cosR)) + (u.y * sinR);
rollMtxRow2.x = ((u.x * u.y) * (1.0f - cosR)) + (u.z * sinR);
rollMtxRow2.y = ((1.0f - SQ(u.y)) * cosR) + SQ(u.y);
rollMtxRow2.z = ((u.y * u.z) * (1.0f - cosR)) - (u.x * sinR);
rollMtxRow3.x = ((u.z * u.x) * (1.0f - cosR)) - (u.y * sinR);
rollMtxRow3.y = ((u.y * u.z) * (1.0f - cosR)) + (u.x * sinR);
rollMtxRow3.z = ((1.0f - SQ(u.z)) * cosR) + SQ(u.z);
// Up without roll
baseUp.x = -sinP * sinY;
baseUp.y = cosP;
baseUp.z = -sinP * cosY;
// rollMtx * baseUp
up.x = DOTXYZ(baseUp, rollMtxRow1);
up.y = DOTXYZ(baseUp, rollMtxRow2);
up.z = DOTXYZ(baseUp, rollMtxRow3);
*viewUp = up;
return viewUp;
}
f32 Camera_ClampLERPScale(Camera* camera, f32 maxLERPScale) {
@ -3654,7 +3647,7 @@ s32 Camera_KeepOn4(Camera* camera) {
OLib_Vec3fDiffToVecSphGeo(&spA8, at, eyeNext);
D_8015BD50 = playerPosRot->pos;
D_8015BD50.y += playerHeight;
temp_f0_2 = BgCheck_CameraRaycastFloor2(&camera->play->colCtx, &spC0, &i, &D_8015BD50);
temp_f0_2 = BgCheck_CameraRaycastDown2(&camera->play->colCtx, &spC0, &i, &D_8015BD50);
if (temp_f0_2 > (roData->unk_00 + D_8015BD50.y)) {
D_8015BD50.y = temp_f0_2 + 10.0f;
} else {
@ -7414,7 +7407,7 @@ Vec3s Camera_Update(Camera* camera) {
Vec3f viewEye;
Vec3f viewUp;
f32 viewFov;
Vec3f spAC;
Vec3f pos;
s32 bgId;
f32 playerGroundY;
f32 playerXZSpeed;
@ -7448,11 +7441,11 @@ Vec3s Camera_Update(Camera* camera) {
camera->playerPosDelta.x = curPlayerPosRot.pos.x - camera->playerPosRot.pos.x;
camera->playerPosDelta.y = curPlayerPosRot.pos.y - camera->playerPosRot.pos.y;
camera->playerPosDelta.z = curPlayerPosRot.pos.z - camera->playerPosRot.pos.z;
spAC = curPlayerPosRot.pos;
spAC.y += Player_GetHeight(camera->player);
pos = curPlayerPosRot.pos;
pos.y += Player_GetHeight(camera->player);
playerGroundY = BgCheck_EntityRaycastFloor5(camera->play, &camera->play->colCtx, &playerFloorPoly, &bgId,
&camera->player->actor, &spAC);
playerGroundY = BgCheck_EntityRaycastDown5(camera->play, &camera->play->colCtx, &playerFloorPoly, &bgId,
&camera->player->actor, &pos);
if (playerGroundY != BGCHECK_Y_MIN) {
// player is above ground.
sOOBTimer = 0;

View file

@ -783,7 +783,7 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon
}
void Environment_EnableUnderwaterLights(PlayState* play, s32 waterLightsIndex) {
if (waterLightsIndex == 0x1F) {
if (waterLightsIndex == WATERBOX_LIGHT_INDEX_NONE) {
waterLightsIndex = 0;
// "Underwater color is not set in the water poly data!"
osSyncPrintf(VT_COL(YELLOW, BLACK) "\n水ポリゴンデータに水中カラーが設定されておりません!" VT_RST);

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);
}
f32 OnePointCutscene_RaycastFloor(CollisionContext* colCtx, Vec3f* pos) {
f32 OnePointCutscene_RaycastDown(CollisionContext* colCtx, Vec3f* pos) {
CollisionPoly* outPoly;
s32 bgId;
return BgCheck_EntityRaycastFloor3(colCtx, &outPoly, &bgId, pos);
return BgCheck_EntityRaycastDown3(colCtx, &outPoly, &bgId, pos);
}
void OnePointCutscene_SetCsCamPoints(Camera* camera, s16 actionParameters, s16 initTimer, CutsceneCameraPoint* atPoints,
@ -292,7 +292,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act
case 4500:
Actor_GetFocus(&spA0, actor);
spC0 = spA0.pos;
spC0.y = OnePointCutscene_RaycastFloor(&play->colCtx, &spC0) + 40.0f;
spC0.y = OnePointCutscene_RaycastDown(&play->colCtx, &spC0) + 40.0f;
spD0.r = 150.0f;
spD0.yaw = spA0.rot.y;
spD0.pitch = 0x3E8;

View file

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

View file

@ -997,7 +997,7 @@ void func_8008F87C(PlayState* play, Player* this, SkelAnime* skelAnime, Vec3f* p
footprintPos.y += 15.0f;
sp80 = BgCheck_EntityRaycastFloor4(&play->colCtx, &sp88, &sp84, &this->actor, &footprintPos) + sp74;
sp80 = BgCheck_EntityRaycastDown4(&play->colCtx, &sp88, &sp84, &this->actor, &footprintPos) + sp74;
if (sp98.y < sp80) {
sp70 = sp98.x - spA4.x;