diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index 20d96585a4..3c5e90d2db 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -13,8 +13,9 @@ struct DynaPolyActor; #define COLPOLY_SNORMAL(x) ((s16)((x) * SHRT_MAX)) #define COLPOLY_GET_NORMAL(n) ((n) * (1.0f / SHRT_MAX)) -#define COLPOLY_VIA_FLAG_TEST(vIA, flags) ((vIA) & (((flags)&7) << 13)) -#define COLPOLY_VTX_INDEX(vI) ((vI)&0x1FFF) +#define COLPOLY_VTX_CHECK_FLAGS_ANY(vI, flags) ((vI) & (((flags) & 7) << 13)) +#define COLPOLY_VTX_FLAGS_MASKED(vI) ((vI) & 0xE000) +#define COLPOLY_VTX_INDEX(vI) ((vI) & 0x1FFF) #define COLPOLY_VTX(vtxId, flags) ((((flags) & 7) << 13) | ((vtxId) & 0x1FFF)) #define DYNAPOLY_INVALIDATE_LOOKUP (1 << 0) @@ -30,15 +31,19 @@ struct DynaPolyActor; #define BGCHECK_SUBDIV_MIN 150.0f // Macros for `WaterBox.properties` -#define WATERBOX_LIGHT_INDEX_NONE 0x1F // warns and defaults to 0 -#define WATERBOX_ROOM(p) ((((s32)p) >> 13) & 0x3F) -#define WATERBOX_ROOM_ALL 0x3F // value for "room index" indicating "all rooms" -#define WATERBOX_FLAG_19 (1 << 19) -#define WATERBOX_PROPERTIES(bgCamIndex, lightIndex, room, setFlag19) \ +#define WATERBOX_PROPERTIES(bgCamIndex, lightIndex, roomIndex, isDisabled) \ ((((bgCamIndex) & 0xFF) << 0) | \ (((lightIndex) & 0x1F) << 8) | \ - (((room) & 0x3F) << 13) | \ - (((setFlag19) & 1) << 19)) + (((roomIndex) & 0x3F) << 13) | \ + (((isDisabled) & 1) << 19)) + +#define WATERBOX_LIGHT_INDEX_NONE 0x1F // Generates a printf warning when built for debug (OOT only) and defaults to 0 +#define WATERBOX_ROOM(properties) (((properties) >> 13) & 0x3F) // retrieves the room the waterbox is active in +#define WATERBOX_ROOM_ALL 0x3F // value for "roomIndex" indicating "all rooms" + +// The original intended purpose of this flag may not be disabling a waterbox. See func_800CA6F0 (unused) which by +// contrast only considers waterboxes with this flag set. +#define WATERBOX_IS_DISABLED (1 << 19) // Disables collision for the WaterBox // bccFlags (bgcheck check flags) #define BGCHECK_CHECK_WALL (1 << 0) @@ -55,12 +60,18 @@ struct DynaPolyActor; #define BGCHECK_IGNORE_WALL (1 << 1) #define BGCHECK_IGNORE_FLOOR (1 << 2) +// flags for flags_vIA // xpFlags (poly exclusion flags) #define COLPOLY_IGNORE_NONE 0 #define COLPOLY_IGNORE_CAMERA (1 << 0) #define COLPOLY_IGNORE_ENTITY (1 << 1) #define COLPOLY_IGNORE_PROJECTILES (1 << 2) +// flags for flags_vIB +#define COLPOLY_IS_FLOOR_CONVEYOR (1 << 0) +#define COLPOLY_IS_FLOOR_DEKU_FLOWER (1 << 1) +#define COLPOLY_VIB_FLAG_4 (1 << 2) + // CollisionContext flags #define BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW 1 @@ -131,14 +142,10 @@ typedef struct { } BgCamFuncData; // size = 0x12 typedef struct { - /* 0x0 */ Vec3s minPos; + /* 0x0 */ Vec3s minPos; // y = water surface. Water is effectively infinitely deep. /* 0x6 */ s16 xLength; /* 0x8 */ s16 zLength; /* 0xC */ u32 properties; - // 0x0008_0000 = ? - // 0x0007_E000 = room index, 0x3F = all rooms - // 0x0000_1F00 = lighting setting index - // 0x0000_00FF = bgCam index } WaterBox; // size = 0x10 typedef enum FloorType { @@ -291,12 +298,12 @@ typedef struct CollisionHeader { /* 0x1C */ SurfaceType* surfaceTypeList; /* 0x20 */ BgCamInfo* bgCamList; /* 0x24 */ u16 numWaterBoxes; - /* 0x28 */ WaterBox* waterBoxes; + /* 0x28 */ WaterBox* waterBoxes; // an unsorted list of non-overlapping waterboxes } CollisionHeader; // size = 0x2C typedef struct { /* 0x0 */ s16 polyId; - /* 0x2 */ u16 next; // index of the next SSNode in the list, or SS_NULL if last element + /* 0x2 */ u16 next; // index of the next SSNode in the list, or SS_NULL if last element } SSNode; // size = 0x4 // represents a linked list of type SSNode @@ -608,20 +615,20 @@ u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 func_800C9DDC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_IsFloorDekuFlower(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); ConveyorSpeed SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetConveyorDirection(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 WaterBox_GetSurfaceImpl(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); -s32 WaterBox_GetSurface1(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); -s32 WaterBox_GetSurface1_2(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); -s32 WaterBox_GetSurface2(struct PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceCheckDist, WaterBox** outWaterBox, s32* bgId); -f32 func_800CA568(CollisionContext* colCtx, s32 waterBoxId, s32 bgId); +s32 BgCheck_GetWaterSurface(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* outWaterSurface, WaterBox** outWaterBox, s32* outBgId); +s32 BgCheck_GetWaterSurfaceNoBgIdAlt(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* outWaterSurface, WaterBox** outWaterBox); +s32 BgCheck_GetWaterSurfaceNoBgId(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* outWaterSurface, WaterBox** outWaterBox); +s32 BgCheck_FindWaterBox(struct PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceCheckDist, WaterBox** outWaterBox, s32* outBgId); +f32 WaterBox_GetSurface(CollisionContext* colCtx, s32 waterBoxId, s32 bgId); u16 WaterBox_GetBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox, s32 bgId); void WaterBox_GetSceneBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox); u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox); -s32 func_800CA6F0(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); -s32 func_800CA9D0(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); +s32 func_800CA6F0(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* outWaterSurface, WaterBox** outWaterBox, s32* outBgId); +s32 func_800CA9D0(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* outWaterSurface, WaterBox** outWaterBox); s32 func_800CAA14(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec3f* pointB, Vec3f* closestPoint); #endif diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 73a292d414..8fde0ed4a8 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1729,7 +1729,8 @@ void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight, func_800B7678(play, actor, &pos, updBgCheckInfoFlags); y = actor->world.pos.y; - if (WaterBox_GetSurface1(play, &play->colCtx, actor->world.pos.x, actor->world.pos.z, &y, &waterbox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, actor->world.pos.x, actor->world.pos.z, &y, + &waterbox)) { actor->depthInWater = y - actor->world.pos.y; if (actor->depthInWater <= 0.0f) { actor->bgCheckFlags &= ~(BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH); @@ -1759,7 +1760,8 @@ void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight, WaterBox* waterbox; f32 y = actor->world.pos.y; - if (WaterBox_GetSurface1(play, &play->colCtx, actor->world.pos.x, actor->world.pos.z, &y, &waterbox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, actor->world.pos.x, actor->world.pos.z, &y, + &waterbox)) { actor->depthInWater = y - actor->world.pos.y; if (actor->depthInWater < 0.0f) { diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 4271927fb8..c24c8e0dc1 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -561,8 +561,8 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList if (((flags & 1) && (colPoly->normal.y < 0)) || ((arg9 & 0x20) && ((colCtx->colHeader->surfaceTypeList[colPoly->type].data[0] >> 0x1E) & 1)) || - COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIB, 4) && + COLPOLY_VTX_CHECK_FLAGS_ANY(colPoly->flags_vIA, xpFlags) || + (COLPOLY_VTX_CHECK_FLAGS_ANY(colPoly->flags_vIB, COLPOLY_VIB_FLAG_4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { @@ -712,8 +712,8 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 nz = COLPOLY_GET_NORMAL(curPoly->normal.z); normalXZ = sqrtf(SQ(nx) + SQ(nz)); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, curPoly->dist, &resultPos); - if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && + if (radius < fabsf(planeDist) || COLPOLY_VTX_CHECK_FLAGS_ANY(curPoly->flags_vIA, xpFlags) || + (COLPOLY_VTX_CHECK_FLAGS_ANY(curPoly->flags_vIB, COLPOLY_VIB_FLAG_4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { @@ -800,8 +800,8 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 nz = COLPOLY_GET_NORMAL(curPoly->normal.z); normalXZ = sqrtf(SQ(nx) + SQ(nz)); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, curPoly->dist, &resultPos); - if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && + if (radius < fabsf(planeDist) || COLPOLY_VTX_CHECK_FLAGS_ANY(curPoly->flags_vIA, xpFlags) || + (COLPOLY_VTX_CHECK_FLAGS_ANY(curPoly->flags_vIB, COLPOLY_VIB_FLAG_4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { @@ -907,8 +907,8 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte curPolyId = curNode->polyId; curPoly = &polyList[curPolyId]; - if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIB, 4) && + if (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || + (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[curPolyId].flags_vIB, COLPOLY_VIB_FLAG_4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { @@ -976,9 +976,9 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { checkedPoly = &arg0->colCtx->polyNodes.polyCheckTbl[polyId]; if ((*checkedPoly == true) || - ((arg0->xpFlags2 != 0) && !COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags2)) || - COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags1) || - (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIB, 4) && + ((arg0->xpFlags2 != 0) && !COLPOLY_VTX_CHECK_FLAGS_ANY(test.poly->flags_vIA, arg0->xpFlags2)) || + COLPOLY_VTX_CHECK_FLAGS_ANY(test.poly->flags_vIA, arg0->xpFlags1) || + (COLPOLY_VTX_CHECK_FLAGS_ANY(test.poly->flags_vIB, COLPOLY_VIB_FLAG_4) && (((arg0->actor != NULL) && (arg0->actor->category != ACTORCAT_PLAYER)) || ((arg0->actor == NULL) && (arg0->xpFlags1 != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { @@ -1063,8 +1063,8 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext while (true) { curPolyId = node->polyId; curPoly = &polyList[curPolyId]; - if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIB, 4) && + if (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || + (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[curPolyId].flags_vIB, COLPOLY_VIB_FLAG_4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (node->next != SS_NULL) { @@ -2999,8 +2999,8 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3 vIB = (COLPOLY_VTX_INDEX(newPoly->flags_vIB) + *vtxStartIndex); vIC = newPoly->vIC + *vtxStartIndex; - newPoly->flags_vIA = vIA | (newPoly->flags_vIA & 0xE000); - newPoly->flags_vIB = vIB | (newPoly->flags_vIB & 0xE000); + newPoly->flags_vIA = vIA | COLPOLY_VTX_FLAGS_MASKED(newPoly->flags_vIA); + newPoly->flags_vIB = vIB | COLPOLY_VTX_FLAGS_MASKED(newPoly->flags_vIB); newPoly->vIC = vIC; dVtxList = dyna->vtxList; vtxA.x = dVtxList[vIA].x; @@ -3187,8 +3187,8 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) { while (true) { id = curNode->polyId; - if (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIA, dynaRaycast->xpFlags) || - (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIB, 4) && + if (COLPOLY_VTX_CHECK_FLAGS_ANY(polyList[id].flags_vIA, dynaRaycast->xpFlags) || + (COLPOLY_VTX_CHECK_FLAGS_ANY(polyList[id].flags_vIB, COLPOLY_VIB_FLAG_4) && (((dynaRaycast->actor != NULL) && (dynaRaycast->actor->category != ACTORCAT_PLAYER)) || ((dynaRaycast->actor == NULL) && (dynaRaycast->xpFlags != COLPOLY_IGNORE_CAMERA)))) || ((dynaRaycast->unk_24 & 0x20) && @@ -3394,9 +3394,10 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo normalXZ = sqrtf(SQ(nx) + SQ(nz)); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos); - if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || - ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { + if (radius < fabsf(planeDist) || COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIA, xpFlags) || + (COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIB, COLPOLY_VIB_FLAG_4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3470,9 +3471,10 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo normalXZ = sqrtf(SQ(nx) + SQ(nz)); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos); - if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || - ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { + if (radius < fabsf(planeDist) || COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIA, xpFlags) || + (COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIB, COLPOLY_VIB_FLAG_4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3630,9 +3632,10 @@ s32 BgCheck_CheckDynaCeilingList(CollisionContext* colCtx, u16 xpFlags, DynaColl while (true) { polyId = curNode->polyId; poly = &dyna->polyList[polyId]; - if (COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || - ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { + if (COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIA, xpFlags) || + (COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIB, COLPOLY_VIB_FLAG_4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3738,8 +3741,8 @@ s32 BgCheck_CheckLineAgainstBgActorSSList(DynaLineTest* dynaLineTest) { while (true) { polyId = curNode->polyId; test.poly = &dynaLineTest->dyna->polyList[polyId]; - if (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, dynaLineTest->xpFlags) || - (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIB, 4) && + if (COLPOLY_VTX_CHECK_FLAGS_ANY(test.poly->flags_vIA, dynaLineTest->xpFlags) || + (COLPOLY_VTX_CHECK_FLAGS_ANY(test.poly->flags_vIB, COLPOLY_VIB_FLAG_4) && (((dynaLineTest->actor != NULL) && (dynaLineTest->actor->category != ACTORCAT_PLAYER)) || ((dynaLineTest->actor == NULL) && (dynaLineTest->xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { @@ -3878,8 +3881,8 @@ s32 BgCheck_SphVsFirstDynaPolyList(CollisionContext* colCtx, u16 xpFlags, Collis while (true) { curPolyId = curNode->polyId; curPoly = &dyna->polyList[curPolyId]; - if (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && + if (COLPOLY_VTX_CHECK_FLAGS_ANY(curPoly->flags_vIA, xpFlags) || + (COLPOLY_VTX_CHECK_FLAGS_ANY(curPoly->flags_vIB, COLPOLY_VIB_FLAG_4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { @@ -4308,17 +4311,22 @@ s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s if (poly == NULL) { return false; } - flags = poly->flags_vIB & 0x2000; + flags = COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIB, COLPOLY_IS_FLOOR_CONVEYOR); return !!flags; } -s32 func_800C9DDC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +/** + * Checks if poly is a dive spot for Deku Link + * + * Returns true if the floor is a dive spot, else false + */ +s32 SurfaceType_IsFloorDekuFlower(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { u32 flags; if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) { return true; } - flags = poly->flags_vIB & 0x4000; + flags = COLPOLY_VTX_CHECK_FLAGS_ANY(poly->flags_vIB, COLPOLY_IS_FLOOR_DEKU_FLOWER); return !!flags; } @@ -4345,35 +4353,43 @@ u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 } /** - * Internal. Get the water surface at point (`x`, `ySurface`, `z`). `ySurface` doubles as position y input - * 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 + * Get the water surface at point (`x`, `z`). + * returns true if point is within the xz boundaries of an active WaterBox, else false + * `outWaterSurface` returns the WaterBox's surface + * `outWaterBox` returns a pointer to the WaterBox + * `outBgId` returns the owner of the WaterBox + * + * The search performed assumes waterboxes cannot overlap, as water has effectively infinite depth */ -s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, - WaterBox** outWaterBox, s32* bgId) { +s32 BgCheck_GetWaterSurface(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* outWaterSurface, + WaterBox** outWaterBox, s32* outBgId) { CollisionHeader* colHeader; s32 room; s32 i; WaterBox* curWaterBox; BgActor* bgActor; - *bgId = BGCHECK_SCENE; + *outBgId = BGCHECK_SCENE; colHeader = colCtx->colHeader; if ((colHeader->numWaterBoxes != 0) && (colHeader->waterBoxes != NULL)) { for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; curWaterBox++) { - room = 0x3F & (curWaterBox->properties >> 13); - if ((room == play->roomCtx.curRoom.num) || (room == 0x3F)) { - if (curWaterBox->properties & 0x80000) { - continue; - } - if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { - if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { - *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; - return true; - } + room = (s32)WATERBOX_ROOM(curWaterBox->properties); + if ((room != play->roomCtx.curRoom.num) && (room != WATERBOX_ROOM_ALL)) { + continue; + } + if (curWaterBox->properties & WATERBOX_IS_DISABLED) { + continue; + } + //! @bug: WaterBox bounds check issue. This range check excludes all points falling exactly on the border of + //! the WaterBox. Thus, when two waterboxes are flush against each other, a seam will exist between them + //! where no water is detected. + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { + *outWaterBox = curWaterBox; + *outWaterSurface = curWaterBox->minPos.y; + return true; } } } @@ -4390,14 +4406,15 @@ s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f3 curWaterBox < colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; curWaterBox++) { - if (curWaterBox->properties & 0x80000) { + if (curWaterBox->properties & WATERBOX_IS_DISABLED) { continue; } + //! @bug: WaterBox bounds check issue. if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; - *bgId = i; + *outWaterSurface = curWaterBox->minPos.y; + *outBgId = i; return true; } } @@ -4407,34 +4424,49 @@ s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f3 return false; } -// boolean -s32 WaterBox_GetSurface1(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, - WaterBox** outWaterBox) { - return WaterBox_GetSurface1_2(play, colCtx, x, z, ySurface, outWaterBox); -} - -// boolean -s32 WaterBox_GetSurface1_2(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, - WaterBox** outWaterBox) { - s32 bgId; - return WaterBox_GetSurfaceImpl(play, colCtx, x, z, ySurface, outWaterBox, &bgId); +/** + * Get the water surface at point (`x`, `z`). + * returns true if point is within the xz boundaries of an active WaterBox, else false + * `outWaterSurface` returns the WaterBox's surface + * `outWaterBox` returns a pointer to the WaterBox + * + * The search performed assumes waterboxes cannot overlap, as water has effectively infinite depth + */ +s32 BgCheck_GetWaterSurfaceNoBgIdAlt(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* outWaterSurface, + WaterBox** outWaterBox) { + return BgCheck_GetWaterSurfaceNoBgId(play, colCtx, x, z, outWaterSurface, outWaterBox); } /** - * Gets the first active WaterBox at `pos` where WaterBox.properties & 0x80000 == 0 - * `surfaceCheckDist` 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 + * Get the water surface at point (`x`, `z`). + * returns true if point is within the xz boundaries of an active WaterBox, else false + * `outWaterSurface` returns the WaterBox's surface + * `outWaterBox` returns a pointer to the WaterBox + * + * The search performed assumes waterboxes cannot overlap, as water has effectively infinite depth */ -s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceCheckDist, - WaterBox** outWaterBox, s32* bgId) { +s32 BgCheck_GetWaterSurfaceNoBgId(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* outWaterSurface, + WaterBox** outWaterBox) { + s32 bgId; + return BgCheck_GetWaterSurface(play, colCtx, x, z, outWaterSurface, outWaterBox, &bgId); +} + +/** + * Gets the first active WaterBox at `pos` + * `surfaceCheckDist` 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 + * `outBgId` returns the owner of the WaterBox + */ +s32 BgCheck_FindWaterBox(PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceCheckDist, + WaterBox** outWaterBox, s32* outBgId) { CollisionHeader* colHeader; s32 room; s32 i; WaterBox* waterBox; BgActor* bgActor; - *bgId = BGCHECK_SCENE; + *outBgId = BGCHECK_SCENE; colHeader = colCtx->colHeader; //! @bug: check skips testing BgActor waterboxes @@ -4446,14 +4478,15 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, for (i = 0; i < colHeader->numWaterBoxes; i++) { waterBox = &colHeader->waterBoxes[i]; - room = WATERBOX_ROOM(waterBox->properties); - if ((room != play->roomCtx.curRoom.num) && (room != 0x3F)) { + room = WATERBOX_ROOM((s32)waterBox->properties); + if ((room != play->roomCtx.curRoom.num) && (room != WATERBOX_ROOM_ALL)) { continue; } - if ((waterBox->properties & 0x80000)) { + if (waterBox->properties & WATERBOX_IS_DISABLED) { continue; } - if (((waterBox->minPos.x < pos->x) && (pos->x < waterBox->minPos.x + waterBox->xLength))) { + //! @bug: WaterBox bounds check issue. See BgCheck_GetWaterSurface for more details. + if ((waterBox->minPos.x < pos->x) && (pos->x < waterBox->minPos.x + waterBox->xLength)) { if ((waterBox->minPos.z < pos->z) && (pos->z < waterBox->minPos.z + waterBox->zLength)) { if ((pos->y - surfaceCheckDist < waterBox->minPos.y) && (waterBox->minPos.y < pos->y + surfaceCheckDist)) { @@ -4475,14 +4508,15 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, waterBox < colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; waterBox++) { - if (waterBox->properties & 0x80000) { + if (waterBox->properties & WATERBOX_IS_DISABLED) { continue; } + //! @bug: WaterBox bounds check issue. See BgCheck_GetWaterSurface for more details. if ((waterBox->minPos.x < pos->x) && (pos->x < waterBox->minPos.x + waterBox->xLength)) { if ((waterBox->minPos.z < pos->z) && (pos->z < waterBox->minPos.z + waterBox->zLength)) { if ((pos->y - surfaceCheckDist < waterBox->minPos.y) && (waterBox->minPos.y < pos->y + surfaceCheckDist)) { - *bgId = i; + *outBgId = i; *outWaterBox = waterBox; return i; } @@ -4495,7 +4529,7 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, return -1; } -f32 func_800CA568(CollisionContext* colCtx, s32 waterBoxId, s32 bgId) { +f32 WaterBox_GetSurface(CollisionContext* colCtx, s32 waterBoxId, s32 bgId) { CollisionHeader* colHeader; colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); @@ -4561,13 +4595,16 @@ u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox) } /** - * 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 - * 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 + * Unused. Gets the water surface? at point (`x`, `z`) for disabled? waterboxes only. + * returns true if point is within the xz boundaries of a disabled? WaterBox, else false + * `outWaterSurface` returns the WaterBox's surface + * `outWaterBox` returns a pointer to the WaterBox + * `outBgId` returns the WaterBox's owner + * + * The search performed assumes waterboxes cannot overlap. */ -s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, - s32* bgId) { +s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* outWaterSurface, WaterBox** outWaterBox, + s32* outBgId) { CollisionHeader* colHeader; s32 i; WaterBox* curWaterBox; @@ -4575,26 +4612,28 @@ s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* s32 room; *outWaterBox = NULL; - *bgId = BGCHECK_SCENE; + *outBgId = BGCHECK_SCENE; colHeader = colCtx->colHeader; + //! @bug: check skips testing BgActor waterboxes if ((colHeader->numWaterBoxes == 0) || (colHeader->waterBoxes == NULL)) { return false; } for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; curWaterBox++) { - room = WATERBOX_ROOM(curWaterBox->properties); + room = WATERBOX_ROOM((s32)curWaterBox->properties); - if ((room != play->roomCtx.curRoom.num) && (room != 0x3F)) { + if ((room != play->roomCtx.curRoom.num) && (room != WATERBOX_ROOM_ALL)) { continue; } - if (!(curWaterBox->properties & 0x80000)) { + if (!(curWaterBox->properties & WATERBOX_IS_DISABLED)) { continue; } + //! @bug: WaterBox bounds check issue. See BgCheck_GetWaterSurface for more details. if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; + *outWaterSurface = curWaterBox->minPos.y; return true; } } @@ -4609,14 +4648,15 @@ s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* curWaterBox < colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; curWaterBox++) { - if (!(curWaterBox->properties & 0x80000)) { + if (!(curWaterBox->properties & WATERBOX_IS_DISABLED)) { continue; } + //! @bug: WaterBox bounds check issue. See BgCheck_GetWaterSurface for more details. if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; - *bgId = i; + *outWaterSurface = curWaterBox->minPos.y; + *outBgId = i; return true; } } @@ -4625,10 +4665,19 @@ s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* return false; } -s32 func_800CA9D0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { +/** + * Unused. Gets the water surface? at point (`x`, `z`) for disabled? waterboxes only. + * returns true if point is within the xz boundaries of a disabled? WaterBox, else false + * `outWaterSurface` returns the WaterBox's surface + * `outWaterBox` returns a pointer to the WaterBox + * + * The search performed assumes waterboxes cannot overlap. + */ +s32 func_800CA9D0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* outWaterSurface, + WaterBox** outWaterBox) { s32 bgId; - return func_800CA6F0(play, colCtx, x, z, ySurface, outWaterBox, &bgId); + return func_800CA6F0(play, colCtx, x, z, outWaterSurface, outWaterBox, &bgId); } /** diff --git a/src/code/z_camera.c b/src/code/z_camera.c index fb732b65ee..57cc02e5cd 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -820,7 +820,7 @@ s32 Camera_GetWaterBoxBgCamSetting(Camera* camera, f32* waterY) { playerPosShape = Actor_GetWorldPosShapeRot(camera->focalActor); *waterY = playerPosShape.pos.y; - if (!WaterBox_GetSurfaceImpl(camera->play, &camera->play->colCtx, playerPosShape.pos.x, playerPosShape.pos.z, + if (!BgCheck_GetWaterSurface(camera->play, &camera->play->colCtx, playerPosShape.pos.x, playerPosShape.pos.z, waterY, &waterBox, &bgId)) { // player's position is not in a waterbox *waterY = playerPosShape.pos.y; diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index fea0190795..a3274b9f3a 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -108,7 +108,7 @@ void FireObj_UpdateStateTransitions(PlayState* play, FireObj* fire) { } if ((fire->flags & FIRE_FLAG_WATER_EXTINGUISHABLE) && (fire->state != FIRE_STATE_NOT_LIT) && - WaterBox_GetSurface1_2(play, &play->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) && + BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) && ((waterY - fire->position.y) > (6500.0f * fire->yScale))) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_NOT_LIT); } diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index b04139ba80..5e5e288ace 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -1119,7 +1119,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; } diff --git a/src/code/z_play.c b/src/code/z_play.c index 01f25afaf8..dc076fcc27 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -499,7 +499,7 @@ f32 Play_GetWaterSurface(PlayState* this, Vec3f* pos, s32* lightIndex) { WaterBox* waterBox; s32 bgId; - if (!WaterBox_GetSurfaceImpl(this, &this->colCtx, pos->x, pos->z, &waterSurfaceY, &waterBox, &bgId)) { + if (!BgCheck_GetWaterSurface(this, &this->colCtx, pos->x, pos->z, &waterSurfaceY, &waterBox, &bgId)) { return BGCHECK_Y_MIN; } @@ -1998,8 +1998,8 @@ s32 Play_IsUnderwater(PlayState* this, Vec3f* pos) { waterSurfacePos = *pos; - if ((WaterBox_GetSurface1(this, &this->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y, - &waterBox) == true) && + if ((BgCheck_GetWaterSurfaceNoBgIdAlt(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)) { return true; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index a1fa4b52e5..9d97123d6a 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c @@ -172,12 +172,12 @@ s32 func_80B82454(BgDblueBalance* this, PlayState* play) { void func_80B8259C(BgDblueBalance* this, PlayState* play) { s32 pad; WaterBox* waterBox; - f32 sp2C; + f32 waterSurface; - if (WaterBox_GetSurface1_2(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, &sp2C, - &waterBox)) { - this->dyna.actor.depthInWater = sp2C - this->dyna.actor.world.pos.y; - this->unk_228 = sp2C; + if (BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, + &waterSurface, &waterBox)) { + this->dyna.actor.depthInWater = waterSurface - this->dyna.actor.world.pos.y; + this->unk_228 = waterSurface; if ((this->dyna.actor.depthInWater < 150.0f) && (this->dyna.actor.depthInWater > -150.0f)) { this->unk_182 = true; } else { diff --git a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c index 7f836fb6a4..8f0d1bfb16 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c @@ -63,7 +63,7 @@ void BgDblueElevator_CheckWaterBoxInfo(BgDblueElevator* this, PlayState* play2) s32 bgId; this->isWithinWaterBoxXZ = - WaterBox_GetSurfaceImpl(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, + BgCheck_GetWaterSurface(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, &this->waterSurfacePosY, &waterBox, &bgId); } diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index 1df2be89c4..df7addd784 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -271,14 +271,14 @@ void func_80B84568(BgDblueWaterfall* this, PlayState* play) { WaterBox* waterBox; s32 bgId; f32 sp34 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp40, &bgId, &this->actor, &this->actor.world.pos); - f32 sp30; + f32 waterSurface; - if (WaterBox_GetSurface1_2(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, - &waterBox)) { - if (sp30 < sp34) { + if (BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox)) { + if (waterSurface < sp34) { this->unk_198 = sp34; } else { - this->unk_198 = sp30; + this->unk_198 = waterSurface; } } else { this->unk_198 = sp34; diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c index d66a8216d3..9531790c69 100644 --- a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c +++ b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c @@ -98,8 +98,8 @@ void BgGoronOyu_UpdateWaterBoxInfo(BgGoronOyu* this, PlayState* play) { WaterBox* waterBox; f32 ySurface; - if (WaterBox_GetSurface1(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, &ySurface, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &ySurface, &waterBox)) { Math_Vec3s_ToVec3f(&this->waterBoxPos, &waterBox->minPos); this->waterBoxXLength = waterBox->xLength; this->waterBoxZLength = waterBox->zLength; diff --git a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c index df88ac7836..ca95b7498b 100644 --- a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c +++ b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c @@ -120,8 +120,8 @@ void func_80AC4C34(BgIcefloe* this, PlayState* play) { this->timer--; if ((this->timer == 0) || - !WaterBox_GetSurface1_2(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, - &this->dyna.actor.home.pos.y, &waterBox)) { + !BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, + &this->dyna.actor.home.pos.y, &waterBox)) { func_80AC4CF0(this); } else { this->dyna.actor.world.pos.y = diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c index 7115fa8ca2..012ff5192a 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -148,8 +148,8 @@ void BgLotus_Update(Actor* thisx, PlayState* play) { s32 pad; WaterBox* waterBox; - WaterBox_GetSurface1_2(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, - &this->unk160, &waterBox); + BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, + &this->unk160, &waterBox); this->actionFunc(this, play); } diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index 7fd853d0a1..a0f31e1bbc 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -319,7 +319,8 @@ void func_8088AA98(EnArrow* this, PlayState* play) { Vec3f sp44; f32 temp_f0; - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, &waterBox) && + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, + &waterBox) && (this->actor.world.pos.y < sp50) && !(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { this->actor.bgCheckFlags |= BGCHECKFLAG_WATER; diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index f45b87d036..220e46a4fa 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -189,8 +189,8 @@ s32 EnBigokuta_IsInWater(EnBigokuta* this, PlayState* play) { this->picto.actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->picto.actor.floorPoly, &bgId, &this->picto.actor, &this->picto.actor.world.pos); - if (!WaterBox_GetSurface1_2(play, &play->colCtx, this->picto.actor.world.pos.x, this->picto.actor.world.pos.z, - &this->picto.actor.home.pos.y, &waterBox) || + if (!BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, this->picto.actor.world.pos.x, + this->picto.actor.world.pos.z, &this->picto.actor.home.pos.y, &waterBox) || (this->picto.actor.home.pos.y <= this->picto.actor.floorHeight)) { return false; } else { diff --git a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c index ae207cf20c..bfab700dbe 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c @@ -372,12 +372,12 @@ void func_80A281B4(EnBigpamet* this) { void func_80A281DC(EnBigpamet* this, PlayState* play) { WaterBox* waterBox; - f32 sp28; + f32 waterSurface; if (this->actor.parent->params == GEKKO_GET_SNAPPER) { - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp28, - &waterBox)) { - this->actor.depthInWater = sp28 - this->actor.world.pos.y; + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox)) { + this->actor.depthInWater = waterSurface - this->actor.world.pos.y; } else { this->actor.depthInWater = this->actor.world.pos.y; } diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index 0030bc0a58..3c1fe7a85b 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -516,8 +516,8 @@ void EnBomChu_Update(Actor* thisx, PlayState* play) { waterY = this->actor.world.pos.y; - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterY, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterY, &waterBox)) { this->actor.depthInWater = waterY - this->actor.world.pos.y; if (this->actor.depthInWater < 0.0f) { diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.c index 5fd8c3b369..e3803f7483 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -63,7 +63,8 @@ void func_808A24DC(EnBoom* this, PlayState* play) { f32 sp50 = this->actor.world.pos.y; u16 sp4E = this->actor.bgCheckFlags & BGCHECKFLAG_WATER; - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, &waterBox) && + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, + &waterBox) && (this->actor.world.pos.y < sp50)) { Vec3f sp40; diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index 0d8784cb4d..2e376073b9 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -564,7 +564,7 @@ void EnBox_Open(EnBox* this, PlayState* play) { this->unk_1A8 = 1.0f; } } - if (WaterBox_GetSurfaceImpl(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, + if (BgCheck_GetWaterSurface(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, &waterSurface, &waterBox, &bgId) && (this->dyna.actor.floorHeight < waterSurface)) { EffectSsBubble_Spawn(play, &this->dyna.actor.world.pos, 5.0f, 2.0f, 20.0f, 0.3f); diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index bee6ead5a5..c12bedb031 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -999,8 +999,8 @@ void EnClearTag_DrawEffects(Actor* thisx, PlayState* play) { * `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox */ ySurface = effect->pos.y; - if (WaterBox_GetSurface1(play, &play->colCtx, effect->pos.x + vec.x, effect->pos.z + vec.z, &ySurface, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, effect->pos.x + vec.x, effect->pos.z + vec.z, + &ySurface, &waterBox)) { if ((effect->pos.y - ySurface) < 200.0f) { // Draw the splash effect. Matrix_Translate(effect->pos.x + vec.x, ySurface, effect->pos.z + vec.z, MTXMODE_NEW); diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 1679d8eaa9..4a23870b7f 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -1168,7 +1168,7 @@ void EnDg_Swim(EnDg* this, PlayState* play) { // this code will make the dog "skip" along the water's surface, assuming the floor // height is low enough to make it try to jump out. if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { - if (!WaterBox_GetSurface1(play, &play->colCtx, pos.x, pos.z, &waterSurface, &waterBox)) { + if (!BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, pos.x, pos.z, &waterSurface, &waterBox)) { if (floorHeight > -100.0f) { this->dogFlags &= ~DOG_FLAG_SWIMMING; this->actionFunc = EnDg_JumpOutOfWater; diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index ea99f42dc1..2fc63e5ce0 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -311,8 +311,8 @@ void func_80B289DC(EnFish2* this, PlayState* play) { this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; } - } else if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->unk_334, &waterBox)) { + } else if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, + this->actor.world.pos.z, &this->unk_334, &waterBox)) { if ((this->unk_334 != BGCHECK_Y_MIN) && (this->actor.world.pos.y < (this->unk_334 - this->unk_2D8))) { this->actor.velocity.y = this->actor.world.rot.x * 0.001f * -0.1f; if (this->actionFunc == func_80B297FC) { @@ -390,8 +390,9 @@ void func_80B28C14(EnFish2* this, PlayState* play) { } } - if ((this->unk_334 == BGCHECK_Y_MIN) && !WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, - this->actor.world.pos.z, &this->unk_334, &waterbox)) { + if ((this->unk_334 == BGCHECK_Y_MIN) && + !BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_334, &waterbox)) { this->unk_334 = this->actor.world.pos.y; } @@ -922,8 +923,8 @@ void func_80B2A498(EnFish2* this, PlayState* play) { (Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 31.0f))) { WaterBox* waterBox; - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &this->unk_334, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_334, &waterBox)) { Vec3f sp6C; s32 i; @@ -1016,8 +1017,8 @@ void EnFish2_Update(Actor* thisx, PlayState* play2) { this->actor.world.pos.y = this->unk_2D4 + 0.1f; } - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->unk_334, &sp6C)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_334, &sp6C)) { if ((this->unk_334 != BGCHECK_Y_MIN) && (this->unk_334 - this->unk_2D8 < this->actor.world.pos.y)) { this->actor.world.pos.y = this->unk_334 - this->unk_2D8; } @@ -1029,8 +1030,8 @@ void EnFish2_Update(Actor* thisx, PlayState* play2) { f32 phi_f20 = 0; WaterBox* sp4C; - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->unk_334, &sp4C)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, + this->actor.world.pos.z, &this->unk_334, &sp4C)) { phi_f20 = D_80B2B3A8[temp_s0_2] + (this->unk_334 - this->unk_2D8); phi_f2 = D_80B2B3A8[temp_s0_2 + 1] + this->unk_2D4; } @@ -1152,7 +1153,8 @@ void func_80B2AF80(EnFish2* this, PlayState* play) { ptr->unk_04.y += 1.0f + ((Rand_ZeroOne() - 0.3f) * 1.2f); ptr->unk_04.z += (0.3f + (Rand_ZeroOne() * 0.5f)) - 0.55f; sp8C = ptr->unk_04.y; - if (!WaterBox_GetSurface1(play, &play->colCtx, ptr->unk_04.x, ptr->unk_04.z, &sp8C, &waterBox)) { + if (!BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, ptr->unk_04.x, ptr->unk_04.z, &sp8C, + &waterBox)) { ptr->unk_00 = 0; } else if (sp8C < ptr->unk_04.y) { Vec3f sp7C; diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index a3cddbd2b2..b208fcc35f 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -500,18 +500,18 @@ s32 func_8093F6F8(EnGoroiwa* this, PlayState* play) { if (this->unk_1CA == 0) { WaterBox* waterBox; - f32 sp40; + f32 waterSurface; - if (WaterBox_GetSurface1_2(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp40, - &waterBox)) { - if ((this->actor.world.pos.y + this->unk_1DC) <= sp40) { + if (BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox)) { + if ((this->actor.world.pos.y + this->unk_1DC) <= waterSurface) { this->unk_1E5 |= 0x20; - if (sp40 < (this->unk_1DC + sp78)) { + if (waterSurface < (this->unk_1DC + sp78)) { if (this->actor.flags & ACTOR_FLAG_INSIDE_CULLING_VOLUME) { Vec3f sp34; sp34.x = this->actor.world.pos.x; - sp34.y = sp40; + sp34.y = waterSurface; sp34.z = this->actor.world.pos.z; func_8093F198(play, &sp34, this->actor.scale.x); } diff --git a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c index c2840cc08e..b105b283fa 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c @@ -650,8 +650,8 @@ void EnGrasshopper_ApproachPlayer(EnGrasshopper* this, PlayState* play) { Math_ApproachF(&this->actor.world.pos.z, this->targetApproachPos.z, 0.3f, this->approachSpeed); Math_ApproachF(&this->approachSpeed, 7.0f, 0.3f, 1.0f); - if (WaterBox_GetSurface1(play, &play->colCtx, this->tailTipPos.x, this->tailTipPos.z, &this->waterSurface, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->tailTipPos.x, this->tailTipPos.z, + &this->waterSurface, &waterBox)) { if (this->tailTipPos.y < this->waterSurface) { if ((this->splashCount < 3) || !(play->gameplayFrames % 8)) { this->splashCount++; @@ -700,8 +700,8 @@ void EnGrasshopper_Attack(EnGrasshopper* this, PlayState* play) { EnGrasshopper_InitializeEffect(this, &this->tailTipPos); } - if (WaterBox_GetSurface1(play, &play->colCtx, this->tailTipPos.x, this->tailTipPos.z, &this->waterSurface, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->tailTipPos.x, this->tailTipPos.z, + &this->waterSurface, &waterBox)) { if (this->tailTipPos.y < this->waterSurface) { if ((this->splashCount < 3) || !(play->gameplayFrames % 8)) { this->splashCount++; @@ -861,8 +861,8 @@ void EnGrasshopper_Fall(EnGrasshopper* this, PlayState* play) { return; } - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox)) { if (this->actor.world.pos.y < waterSurface) { Vec3f splashPos; s32 i; @@ -902,8 +902,8 @@ void EnGrasshopper_Fall(EnGrasshopper* this, PlayState* play) { firePos.x += Rand_CenteredFloat(30.0f); if (!isUnderWater) { firePos.y = this->actor.floorHeight; - } else if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &waterSurface, &waterBox)) { + } else if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, + this->actor.world.pos.z, &waterSurface, &waterBox)) { firePos.y = waterSurface; } diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c index 28c02d66f9..3a0d8a2c65 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c @@ -354,15 +354,16 @@ void func_80BDBB48(EnHiddenNuts* this, PlayState* play) { s32 pad[3]; f32 curFrame = this->skelAnime.curFrame; WaterBox* waterBox; - f32 sp50; + f32 waterSurface; s16 sp4E = false; Vec3f sp40; - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, &waterBox) && - (this->actor.world.pos.y < sp50)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox) && + (this->actor.world.pos.y < waterSurface)) { this->actor.velocity.y = 0.0f; Math_Vec3f_Copy(&sp40, &this->actor.world.pos); - sp40.y = sp50; + sp40.y = waterSurface; this->actor.gravity = 0.0f; if ((play->gameplayFrames % 8) == 0) { diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index b5ff9a88e4..7591c1eabd 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -3484,7 +3484,7 @@ s32 EnHorse_CalcFloorHeight(EnHorse* this, PlayState* play, Vec3f* pos, Collisio return 1; // No floor } - if ((WaterBox_GetSurface1_2(play, &play->colCtx, pos->x, pos->z, &waterY, &waterbox) == 1) && + if ((BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, pos->x, pos->z, &waterY, &waterbox) == true) && (*floorHeight < waterY)) { return 2; // Water } @@ -3563,8 +3563,8 @@ void EnHorse_CheckFloors(EnHorse* this, PlayState* play) { WaterBox* waterbox; f32 dist; - if ((WaterBox_GetSurface1_2(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterHeight, - &waterbox) == true) && + if ((BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterHeight, &waterbox) == true) && (this->actor.floorHeight < waterHeight)) { EnHorse_ObstructMovement(this, play, 1, galloping); return; diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 483ae5d609..3735a10a7a 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -395,7 +395,7 @@ s32 EnIshi_IsUnderwater(EnIshi* this, PlayState* play) { f32 waterSurface; s32 bgId; - if (WaterBox_GetSurfaceImpl(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, + if (BgCheck_GetWaterSurface(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, &waterBox, &bgId) && (this->actor.world.pos.y < waterSurface)) { return true; diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 003fbc751a..00a7a8334f 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -341,7 +341,7 @@ s32 EnKusa_IsUnderwater(EnKusa* this, PlayState* play) { f32 waterSurface; s32 bgId; - if (WaterBox_GetSurfaceImpl(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, + if (BgCheck_GetWaterSurface(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, &waterBox, &bgId) && (this->actor.world.pos.y < waterSurface)) { return true; diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index 8e59bfb550..5464c5beaa 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -127,14 +127,14 @@ s32 func_80A68860(EnMushi2* this, PlayState* play) { CollisionPoly* sp3C; f32 temp_f0 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp3C, &bgId, &this->actor, &this->actor.world.pos); WaterBox* waterBox; - f32 sp30; + f32 waterSurface; if ((temp_f0 > (BGCHECK_Y_MIN + 1)) && ((this->actor.world.pos.y - 150.0f) < temp_f0)) { return true; } - return WaterBox_GetSurface1_2(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, - &waterBox); + return BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox); } s32 func_80A68910(EnMushi2* this, PlayState* play) { @@ -528,16 +528,16 @@ void func_80A697C4(EnMushi2* this, PlayState* play) { if (!(this->unk_30C & (0x10 | 0x4))) { WaterBox* waterBox; - f32 sp2C; + f32 waterSurface; this->unk_30C &= ~(0x40 | 0x8 | 0x2); if (!func_80A69468(this, play) && !func_80A6958C(this, play)) { func_80A6969C(this, play); } - if (WaterBox_GetSurface1_2(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, - &waterBox)) { - this->actor.depthInWater = sp2C - this->actor.world.pos.y; + if (BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox)) { + this->actor.depthInWater = waterSurface - this->actor.world.pos.y; if (this->actor.depthInWater >= 1.0f) { this->unk_30C |= 0x20; } else { @@ -577,14 +577,14 @@ void func_80A697C4(EnMushi2* this, PlayState* play) { s32 func_80A699E4(EnMushi2* this, PlayState* play) { s32 pad; WaterBox* waterBox; - f32 sp3C; + f32 waterSurface; if (this->unk_328.y < 0.0f) { f32 x = (2.0f * this->unk_328.x) + this->actor.world.pos.x; f32 y = (2.0f * this->unk_328.y) + this->actor.world.pos.y; f32 z = (2.0f * this->unk_328.z) + this->actor.world.pos.z; - if (WaterBox_GetSurface1_2(play, &play->colCtx, x, z, &sp3C, &waterBox) && (y <= sp3C)) { + if (BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, x, z, &waterSurface, &waterBox) && (y <= waterSurface)) { return true; } } @@ -680,7 +680,7 @@ s32 EnMushi2_IsUnderwater(EnMushi2* this, PlayState* play) { f32 waterSurface; s32 bgId; - if (WaterBox_GetSurfaceImpl(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, + if (BgCheck_GetWaterSurface(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, &waterBox, &bgId) && (this->actor.world.pos.y < waterSurface)) { return true; diff --git a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c index 8c5744f6c7..b0fe9cf41f 100644 --- a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c +++ b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c @@ -166,8 +166,8 @@ void EnOkuta_Init(Actor* thisx, PlayState* play2) { thisx->floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &thisx->floorPoly, &bgId, thisx, &thisx->world.pos); - if (!WaterBox_GetSurface1_2(play, &play->colCtx, thisx->world.pos.x, thisx->world.pos.z, &waterSurface, - &waterBox) || + if (!BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, thisx->world.pos.x, thisx->world.pos.z, &waterSurface, + &waterBox) || waterSurface <= thisx->floorHeight) { Actor_Kill(thisx); } else { diff --git a/src/overlays/actors/ovl_En_Pp/z_en_pp.c b/src/overlays/actors/ovl_En_Pp/z_en_pp.c index f71bb29219..aa40aba7ee 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.c +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.c @@ -1050,8 +1050,8 @@ void EnPp_Dead(EnPp* this, PlayState* play) { isUnderWater = false; if ((this->action == EN_PP_ACTION_DEAD) && - (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, - &waterBox))) { + (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox))) { if (this->actor.world.pos.y < waterSurface) { for (i = 0; i < 5; i++) { Math_Vec3f_Copy(&splashPos, &this->actor.world.pos); @@ -1218,8 +1218,8 @@ void EnPp_Fragment_Move(EnPp* this, PlayState* play) { this->actor.shape.rot.z += this->fragmentAngularVelocity.z; } - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, - &waterBox) && + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox) && (this->actor.world.pos.y < (waterSurface + 5.0f))) { this->timer = 0; if (EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_FRAGMENT_BODY) { @@ -1418,8 +1418,8 @@ void EnPp_Update(Actor* thisx, PlayState* play) { } if ((this->action < EN_PP_ACTION_DEAD) && - (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, - &waterBox)) && + (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox)) && (this->actor.world.pos.y < waterSurface)) { EnPp_SetupDead(this, play); return; diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index 2bfb008f60..c3003b850c 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -221,8 +221,8 @@ s32 func_80A324E0(EnPr* this, PlayState* play) { return 1; } - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &this->unk_2B4, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_2B4, &waterBox)) { if ((this->unk_2B4 - 30.0f) < this->actor.world.pos.y) { this->unk_2B8 = this->unk_2B4 - 30.0f; return 2; @@ -341,8 +341,8 @@ void func_80A32A40(EnPr* this, PlayState* play) { Math_Vec3f_Copy(&sp34, &this->actor.world.pos); sp34.y = Rand_CenteredFloat(50.0f) + this->actor.home.pos.y; - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &this->unk_2B4, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_2B4, &waterBox)) { if (sp34.y < (this->unk_2B4 - 30.0f)) { this->unk_2B8 = sp34.y; } else { @@ -448,8 +448,8 @@ void func_80A32F48(EnPr* this, PlayState* play) { this->unk_208 = 0; } - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &this->unk_2B4, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_2B4, &waterBox)) { if ((this->unk_2B4 - 100.0f) < this->actor.world.pos.y) { this->unk_212 += 0xBB8; this->unk_2C4 = 2.0f * Math_SinS(this->unk_212); diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c index 57bb0a65b7..d71646bbab 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -522,8 +522,8 @@ void EnPr2_Attack(EnPr2* this, PlayState* play) { Math_Vec3f_Copy(&this->newHome, &this->actor.world.pos); } - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->waterSurfaceHeight, &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->waterSurfaceHeight, &waterBox)) { if (this->waypointPos.y > (this->waterSurfaceHeight - 40.0f)) { this->waypointPos.y = this->waterSurfaceHeight - 40.0f; } @@ -609,8 +609,8 @@ void EnPr2_Die(EnPr2* this, PlayState* play) { this->bubbleToggle = true; } - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, - &this->waterSurfaceHeight, &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->waterSurfaceHeight, &waterBox)) { if (this->actor.world.pos.y >= (this->waterSurfaceHeight - 15.0f)) { nearSurface = true; } else { diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index 83d882dd44..b11346a616 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -158,8 +158,8 @@ s32 func_80A75FA4(EnPrz* this, PlayState* play) { WaterBox* waterBox; f32 temp_f0; - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &this->unk_210, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_210, &waterBox)) { temp_f0 = BREG(10) + (this->unk_210 - 10.0f); if (temp_f0 < this->actor.world.pos.y) { this->unk_1D8.y = temp_f0; @@ -407,8 +407,8 @@ void func_80A76B14(EnPrz* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.z, this->unk_1FC, 5, 0x2710, 0x3E8); Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_1FE, 5, 0x2710, 0x3E8); - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &this->unk_210, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_210, &waterBox)) { if ((this->unk_210 - 15.0f) <= this->actor.world.pos.y) { phi_s0 = true; } else { diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index e0e11bf69d..f66468c0ea 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -739,8 +739,8 @@ void EnRaf_Update(Actor* thisx, PlayState* play) { if (this->mainType != CARNIVOROUS_LILY_TYPE_NO_WATER_INTERACTIONS) { ySurface = BREG(60) + (this->dyna.actor.world.pos.y - 60.0f); - if (WaterBox_GetSurface1(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, - &ySurface, &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &ySurface, &waterBox)) { ySurface -= this->bobOffset + BREG(59); Math_ApproachF(&this->dyna.actor.world.pos.y, this->heightDiffFromPlayer + ySurface, 0.5f, 40.0f); if (this->rippleTimer == 0) { diff --git a/src/overlays/actors/ovl_En_Rat/z_en_rat.c b/src/overlays/actors/ovl_En_Rat/z_en_rat.c index 12f91d1316..4c6bbd8420 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.c +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.c @@ -356,7 +356,7 @@ s32 EnRat_IsOnCollisionPoly(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* po s32 isOnWater; f32 waterSurface; - if (WaterBox_GetSurface1(play, &play->colCtx, posB->x, posB->z, &waterSurface, &waterBox) && + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, posB->x, posB->z, &waterSurface, &waterBox) && (waterSurface <= posA->y) && (posB->y <= waterSurface)) { isOnWater = true; } else { diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c index 41032de1f3..8b64c2f979 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c @@ -100,8 +100,8 @@ void EnSyatekiOkuta_Init(Actor* thisx, PlayState* play) { this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &this->actor.world.pos); - if (!WaterBox_GetSurface1_2(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &ySurface, - &waterbox) || + if (!BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &ySurface, + &waterbox) || (ySurface <= this->actor.floorHeight)) { Actor_Kill(&this->actor); } else { diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c index 79941fe4bf..301a11d734 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c @@ -343,7 +343,8 @@ void func_80BB5318(EnTanron1* this, PlayState* play) { } ptr->unk_3C = BgCheck_EntityRaycastFloor1(&play->colCtx, &sp98, &ptr->unk_00); sp9C = ptr->unk_00.y; - WaterBox_GetSurface1(play, &play->colCtx, ptr->unk_00.x, ptr->unk_00.z, &sp9C, &waterBox); + BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, ptr->unk_00.x, ptr->unk_00.z, &sp9C, + &waterBox); if ((sp9C < ptr->unk_00.y) && (ptr->unk_3C < sp9C)) { ptr->unk_3C = sp9C; } diff --git a/src/overlays/actors/ovl_En_Test5/z_en_test5.c b/src/overlays/actors/ovl_En_Test5/z_en_test5.c index cdc9c2e197..70eaf23b73 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.c +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.c @@ -37,8 +37,8 @@ void EnTest5_Init(Actor* thisx, PlayState* play2) { f32 ySurface; // If not spawned above a water source, immediately despawn - if (!WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &ySurface, - &waterBox)) { + if (!BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &ySurface, &waterBox)) { Actor_Kill(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index 5a66eb4757..af25ebfdcd 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -897,7 +897,7 @@ void func_80B94E34(EnZog* this, PlayState* play) { sp38.x += Rand_CenteredFloat(30.0f); sp38.y += 20.0f; sp38.z += Rand_CenteredFloat(30.0f); - if (WaterBox_GetSurface1(play, &play->colCtx, sp38.x, sp38.z, &sp38.y, &waterBox) && + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, sp38.x, sp38.z, &sp38.y, &waterBox) && (this->actor.world.pos.y < sp38.y)) { EffectSsGSplash_Spawn(play, &sp38, NULL, NULL, 1, Rand_ZeroFloat(this->actor.speed * 40.0f) + (this->actor.speed * 60.0f)); diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c index 3220b4823a..c28d51bd4c 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -598,7 +598,8 @@ void func_80B32C34(EnZoraegg* this, PlayState* play) { this->actor.focus.pos.y += 10.0f; sp30 = this->actor.world.pos.y; - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, + &waterBox)) { if ((this->actor.world.pos.y + 50.0f) < sp30) { this->actionFunc = func_80B32BB8; } @@ -619,7 +620,8 @@ void func_80B32D08(EnZoraegg* this, PlayState* play) { this->actor.focus.pos.y += 10.0f; sp40 = this->actor.world.pos.y; - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp40, &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp40, + &waterBox)) { if (this->actor.world.pos.y < sp40) { sp34.x = this->actor.world.pos.x; sp34.y = sp40; diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c index 7deb602c84..158921a47d 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -133,7 +133,7 @@ s32 ObjAqua_IsUnderwater(ObjAqua* this, PlayState* play) { f32 waterSurface; s32 bgId; - if (WaterBox_GetSurfaceImpl(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, + if (BgCheck_GetWaterSurface(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, &waterBox, &bgId) && (this->actor.world.pos.y < waterSurface)) { return true; diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c index fc63831c03..fe561cc777 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -150,7 +150,7 @@ s32 ObjBombiwa_IsUnderwater(ObjBombiwa* this, PlayState* play) { f32 waterSurface; s32 bgId; - if (WaterBox_GetSurfaceImpl(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, + if (BgCheck_GetWaterSurface(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, &waterBox, &bgId) && (this->actor.world.pos.y < waterSurface)) { return true; diff --git a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c index a8d31172af..66c285eb4e 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c +++ b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c @@ -92,7 +92,7 @@ s32 ObjGrassUnit_IsUnderwater(PlayState* play, Vec3f* pos) { f32 waterSurface; s32 bgId; - if (WaterBox_GetSurfaceImpl(play, &play->colCtx, pos->x, pos->z, &waterSurface, &waterBox, &bgId) && + if (BgCheck_GetWaterSurface(play, &play->colCtx, pos->x, pos->z, &waterSurface, &waterBox, &bgId) && (pos->y < waterSurface)) { return true; } diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index 69a4a3eea5..fe64a9bcc5 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -150,7 +150,7 @@ s32 ObjHamishi_IsUnderwater(ObjHamishi* this, PlayState* play) { f32 waterSurface; s32 bgId; - if (WaterBox_GetSurfaceImpl(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, + if (BgCheck_GetWaterSurface(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, &waterBox, &bgId) && (this->actor.world.pos.y < waterSurface)) { return true; diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index ccf0b491e0..265ec28940 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -347,7 +347,7 @@ s32 func_80A23D08(ObjIceblock* this, PlayState* play) { } } - if (WaterBox_GetSurface1_2(play, &play->colCtx, spA4.x, spA4.z, &ptr->unk_0C, &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, spA4.x, spA4.z, &ptr->unk_0C, &waterBox)) { if (phi_f20 < ptr->unk_0C) { spB8 = i; phi_f20 = ptr->unk_0C; diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index cac6a4bcd9..6557b08aca 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -155,8 +155,8 @@ void ObjSyokudai_Update(Actor* thisx, PlayState* play2) { this->pendingAction = OBJ_SYOKUDAI_PENDING_ACTION_NONE; } } else { - if (WaterBox_GetSurface1_2(play, &play->colCtx, thisx->world.pos.x, thisx->world.pos.z, &waterSurface, - &waterBox) && + if (BgCheck_GetWaterSurfaceNoBgId(play, &play->colCtx, thisx->world.pos.x, thisx->world.pos.z, &waterSurface, + &waterBox) && ((waterSurface - thisx->world.pos.y) > OBJ_SYOKUDAI_FLAME_HEIGHT)) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_OUT; diff --git a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c index 16b8377554..bbc235383a 100644 --- a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c +++ b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c @@ -39,8 +39,8 @@ void ObjWind_Init(Actor* thisx, PlayState* play) { f32 ySurface; Actor_ProcessInitChain(&this->actor, sInitChain); - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &ySurface, - &waterbox) && + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &ySurface, &waterbox) && (this->actor.world.pos.y < ySurface)) { this->isUnderWater = true; } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 482fe7d8fd..34d30a937a 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -6977,7 +6977,7 @@ void func_80836D8C(Player* this) { } s32 func_80836DC0(PlayState* play, Player* this) { - if ((MREG(48) != 0) || func_800C9DDC(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + if ((MREG(48) != 0) || SurfaceType_IsFloorDekuFlower(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { Player_SetAction(play, this, Player_Action_93, 0); this->stateFlags1 &= ~(PLAYER_STATE1_PARALLEL | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE); Player_Anim_PlayOnceMorph(play, this, &gPlayerAnim_pn_attack); @@ -7231,7 +7231,7 @@ s32 func_80837730(PlayState* play, Player* this, f32 arg2, s32 scale) { Math_Vec3f_Copy(&pos, &this->bodyPartsPos[PLAYER_BODYPART_WAIST]); pos.y += 20.0f; - if (WaterBox_GetSurface1(play, &play->colCtx, pos.x, pos.z, &pos.y, &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, pos.x, pos.z, &pos.y, &waterBox)) { sp34 = pos.y - this->bodyPartsPos[PLAYER_BODYPART_LEFT_FOOT].y; if ((sp34 > -2.0f) && (sp34 < 100.0f)) { EffectSsGSplash_Spawn(play, &pos, NULL, NULL, @@ -7548,7 +7548,8 @@ void func_8083827C(Player* this, PlayState* play) { sp48 = func_80835CD8(play, this, &D_8085D154, &sp4C, &sp60, &sp5C); sp44 = this->actor.world.pos.y; - if (WaterBox_GetSurface1(play, &play->colCtx, sp4C.x, sp4C.z, &sp44, &waterBox) && + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, sp4C.x, sp4C.z, &sp44, + &waterBox) && ((sp44 - sp48) > 50.0f)) { func_80834DB8(this, &gPlayerAnim_link_normal_run_jump_water_fall, 6.0f, play); Player_SetAction(play, this, Player_Action_27, 0); @@ -8532,8 +8533,8 @@ s32 func_8083A878(PlayState* play, Player* this, f32 arg2) { WaterBox* waterBox; f32 ySurface = this->actor.world.pos.y; - if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &ySurface, - &waterBox)) { + if (BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &ySurface, &waterBox)) { ySurface -= this->actor.world.pos.y; if (this->ageProperties->unk_24 <= ySurface) { Player_SetAction(play, this, Player_Action_55, 0); @@ -11550,7 +11551,7 @@ void Player_UpdateInterface(PlayState* play, Player* this) { (sp38 || ((this->stateFlags1 & PLAYER_STATE1_8000000) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)))) || ((this->transformation == PLAYER_FORM_DEKU) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && - func_800C9DDC(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { + SurfaceType_IsFloorDekuFlower(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { doActionA = (this->transformation == PLAYER_FORM_ZORA) ? DO_ACTION_SWIM : ((this->stateFlags1 & PLAYER_STATE1_8000000) && (interactRangeActor != NULL) && (interactRangeActor->id == ACTOR_EN_ZOG)) diff --git a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c index 8c6bfb7218..fe0847c536 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c @@ -74,7 +74,7 @@ void EffectSsBubble_Update(PlayState* play2, u32 index, EffectSs* this) { Vec3f ripplePos; PlayState* play = play2; - if (!WaterBox_GetSurface1(play, &play->colCtx, this->pos.x, this->pos.z, &waterSurfaceY, &waterBox)) { + if (!BgCheck_GetWaterSurfaceNoBgIdAlt(play, &play->colCtx, this->pos.x, this->pos.z, &waterSurfaceY, &waterBox)) { this->life = -1; return; } diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c index 918da4a773..54bd8d83c0 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c @@ -57,7 +57,7 @@ u32 EffectSsGRipple_Init(PlayState* play, u32 index, EffectSs* this, void* initP this->rEnvColorG = 255; this->rEnvColorB = 255; this->rEnvColorA = 255; - this->rWaterBoxNum = WaterBox_GetSurface2(play, &play->colCtx, &initParams->pos, 3.0f, &waterBox, &bgId); + this->rWaterBoxNum = BgCheck_FindWaterBox(play, &play->colCtx, &initParams->pos, 3.0f, &waterBox, &bgId); this->rBgId = bgId; return 1; @@ -80,7 +80,7 @@ void EffectSsGRipple_DrawRipple(PlayState* play2, EffectSs* this, TexturePtr tex colHeader = BgCheck_GetCollisionHeader(&play->colCtx, this->rBgId); if ((this->rWaterBoxNum != -1) && (colHeader != NULL) && (this->rWaterBoxNum < colHeader->numWaterBoxes)) { - yPos = func_800CA568(&play->colCtx, this->rWaterBoxNum, this->rBgId); + yPos = WaterBox_GetSurface(&play->colCtx, this->rWaterBoxNum, this->rBgId); } else { yPos = this->pos.y; } @@ -118,7 +118,7 @@ void EffectSsGRipple_Update(PlayState* play, u32 index, EffectSs* this) { WaterBox* waterBox; s32 bgId; - this->rWaterBoxNum = WaterBox_GetSurface2(play, &play->colCtx, &this->pos, 3.0f, &waterBox, &bgId); + this->rWaterBoxNum = BgCheck_FindWaterBox(play, &play->colCtx, &this->pos, 3.0f, &waterBox, &bgId); this->rBgId = bgId; if (DECR(this->rLifespan) == 0) { diff --git a/tools/disasm/n64-jp-1.1/functions.txt b/tools/disasm/n64-jp-1.1/functions.txt index 27a2aa128b..4afde9685f 100644 --- a/tools/disasm/n64-jp-1.1/functions.txt +++ b/tools/disasm/n64-jp-1.1/functions.txt @@ -1083,15 +1083,15 @@ SurfaceType_IsHookshotSurface = 0x800CB80C; // type:func size:0x28 SurfaceType_IsIgnoredByEntities = 0x800CB834; // type:func size:0x3C SurfaceType_IsIgnoredByProjectiles = 0x800CB870; // type:func size:0x3C SurfaceType_IsFloorConveyor = 0x800CB8AC; // type:func size:0x54 -func_800C9DDC = 0x800CB900; // type:func size:0x3C +SurfaceType_IsFloorDekuFlower = 0x800CB900; // type:func size:0x3C SurfaceType_GetConveyorSpeed = 0x800CB93C; // type:func size:0x28 SurfaceType_GetConveyorDirection = 0x800CB964; // type:func size:0x48 SurfaceType_IsWallDamage = 0x800CB9AC; // type:func size:0x34 -WaterBox_GetSurfaceImpl = 0x800CB9E0; // type:func size:0x2F0 -WaterBox_GetSurface1 = 0x800CBCD0; // type:func size:0x3C -WaterBox_GetSurface1_2 = 0x800CBD0C; // type:func size:0x44 -WaterBox_GetSurface2 = 0x800CBD50; // type:func size:0x33C -func_800CA568 = 0x800CC08C; // type:func size:0xCC +BgCheck_GetWaterSurface = 0x800CB9E0; // type:func size:0x2F0 +BgCheck_GetWaterSurfaceNoBgIdAlt = 0x800CBCD0; // type:func size:0x3C +BgCheck_GetWaterSurfaceNoBgId = 0x800CBD0C; // type:func size:0x44 +BgCheck_FindWaterBox = 0x800CBD50; // type:func size:0x33C +WaterBox_GetSurface = 0x800CC08C; // type:func size:0xCC WaterBox_GetBgCamIndex = 0x800CC158; // type:func size:0x14 WaterBox_GetBgCamSetting = 0x800CC16C; // type:func size:0x70 WaterBox_GetSceneBgCamSetting = 0x800CC1DC; // type:func size:0x20 diff --git a/tools/disasm/n64-us/functions.txt b/tools/disasm/n64-us/functions.txt index 5683abf807..8142d85cd6 100644 --- a/tools/disasm/n64-us/functions.txt +++ b/tools/disasm/n64-us/functions.txt @@ -1073,15 +1073,15 @@ SurfaceType_IsHookshotSurface = 0x800C9CEC; // type:func SurfaceType_IsIgnoredByEntities = 0x800C9D14; // type:func SurfaceType_IsIgnoredByProjectiles = 0x800C9D50; // type:func SurfaceType_IsFloorConveyor = 0x800C9D8C; // type:func -func_800C9DDC = 0x800C9DDC; // type:func +SurfaceType_IsFloorDekuFlower = 0x800C9DDC; // type:func SurfaceType_GetConveyorSpeed = 0x800C9E18; // type:func SurfaceType_GetConveyorDirection = 0x800C9E40; // type:func SurfaceType_IsWallDamage = 0x800C9E88; // type:func -WaterBox_GetSurfaceImpl = 0x800C9EBC; // type:func -WaterBox_GetSurface1 = 0x800CA1AC; // type:func -WaterBox_GetSurface1_2 = 0x800CA1E8; // type:func -WaterBox_GetSurface2 = 0x800CA22C; // type:func -func_800CA568 = 0x800CA568; // type:func +BgCheck_GetWaterSurface = 0x800C9EBC; // type:func +BgCheck_GetWaterSurfaceNoBgIdAlt = 0x800CA1AC; // type:func +BgCheck_GetWaterSurfaceNoBgId = 0x800CA1E8; // type:func +BgCheck_FindWaterBox = 0x800CA22C; // type:func +WaterBox_GetSurface = 0x800CA568; // type:func WaterBox_GetBgCamIndex = 0x800CA634; // type:func WaterBox_GetBgCamSetting = 0x800CA648; // type:func WaterBox_GetSceneBgCamSetting = 0x800CA6B8; // type:func diff --git a/tools/namefixer.py b/tools/namefixer.py index 9d9e494235..8e9e42c507 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -572,10 +572,10 @@ wordReplace = { "func_800C9E18": "SurfaceType_GetConveyorSpeed", "func_800C9E40": "SurfaceType_GetConveyorDirection", "func_800C9E88": "SurfaceType_IsWallDamage", - "func_800C9EBC": "WaterBox_GetSurfaceImpl", - "func_800CA1AC": "WaterBox_GetSurface1", - "func_800CA1E8": "WaterBox_GetSurface1_2", - "func_800CA22C": "WaterBox_GetSurface2", + "func_800C9EBC": "BgCheck_GetWaterSurface", + "func_800CA1AC": "BgCheck_GetWaterSurfaceNoBgIdAlt", + "func_800CA1E8": "BgCheck_GetWaterSurfaceNoBgId", + "func_800CA22C": "BgCheck_FindWaterBox", "func_800CA6D8": "WaterBox_GetLightSettingIndex", "func_8017D668": "Math3D_PointDistSqToLine2DImpl", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 126b0ab666..8cac453238 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -590,15 +590,15 @@ asm/non_matchings/code/z_bgcheck/SurfaceType_IsHookshotSurface.s,SurfaceType_IsH asm/non_matchings/code/z_bgcheck/SurfaceType_IsIgnoredByEntities.s,SurfaceType_IsIgnoredByEntities,0x800C9D14,0xF asm/non_matchings/code/z_bgcheck/SurfaceType_IsIgnoredByProjectiles.s,SurfaceType_IsIgnoredByProjectiles,0x800C9D50,0xF asm/non_matchings/code/z_bgcheck/SurfaceType_IsFloorConveyor.s,SurfaceType_IsFloorConveyor,0x800C9D8C,0x14 -asm/non_matchings/code/z_bgcheck/func_800C9DDC.s,func_800C9DDC,0x800C9DDC,0xF +asm/non_matchings/code/z_bgcheck/SurfaceType_IsFloorDekuFlower.s,SurfaceType_IsFloorDekuFlower,0x800C9DDC,0xF asm/non_matchings/code/z_bgcheck/SurfaceType_GetConveyorSpeed.s,SurfaceType_GetConveyorSpeed,0x800C9E18,0xA asm/non_matchings/code/z_bgcheck/SurfaceType_GetConveyorDirection.s,SurfaceType_GetConveyorDirection,0x800C9E40,0x12 asm/non_matchings/code/z_bgcheck/SurfaceType_IsWallDamage.s,SurfaceType_IsWallDamage,0x800C9E88,0xD -asm/non_matchings/code/z_bgcheck/WaterBox_GetSurfaceImpl.s,WaterBox_GetSurfaceImpl,0x800C9EBC,0xBC -asm/non_matchings/code/z_bgcheck/WaterBox_GetSurface1.s,WaterBox_GetSurface1,0x800CA1AC,0xF -asm/non_matchings/code/z_bgcheck/WaterBox_GetSurface1_2.s,WaterBox_GetSurface1_2,0x800CA1E8,0x11 -asm/non_matchings/code/z_bgcheck/WaterBox_GetSurface2.s,WaterBox_GetSurface2,0x800CA22C,0xCF -asm/non_matchings/code/z_bgcheck/func_800CA568.s,func_800CA568,0x800CA568,0x33 +asm/non_matchings/code/z_bgcheck/BgCheck_GetWaterSurface.s,BgCheck_GetWaterSurface,0x800C9EBC,0xBC +asm/non_matchings/code/z_bgcheck/BgCheck_GetWaterSurfaceNoBgIdAlt.s,BgCheck_GetWaterSurfaceNoBgIdAlt,0x800CA1AC,0xF +asm/non_matchings/code/z_bgcheck/BgCheck_GetWaterSurfaceNoBgId.s,BgCheck_GetWaterSurfaceNoBgId,0x800CA1E8,0x11 +asm/non_matchings/code/z_bgcheck/BgCheck_FindWaterBox.s,BgCheck_FindWaterBox,0x800CA22C,0xCF +asm/non_matchings/code/z_bgcheck/WaterBox_GetSurface.s,WaterBox_GetSurface,0x800CA568,0x33 asm/non_matchings/code/z_bgcheck/func_800CA634.s,func_800CA634,0x800CA634,0x5 asm/non_matchings/code/z_bgcheck/func_800CA648.s,func_800CA648,0x800CA648,0x1C asm/non_matchings/code/z_bgcheck/WaterBox_GetSceneBgCamSetting.s,WaterBox_GetSceneBgCamSetting,0x800CA6B8,0x8