1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-28 07:46:18 +00:00

Small bgcheck documentation pass (#816)

* implement some documentation

* remove unnecessary comments related to decomp

* eliminate comment function prototypes
This commit is contained in:
mzxrules 2021-05-22 17:50:05 -04:00 committed by GitHub
parent 54f13007ca
commit 5c4fdb706b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 88 additions and 149 deletions

View file

@ -540,54 +540,16 @@ void ActorOverlayTable_LogPrint(void);
void ActorOverlayTable_Init(void); void ActorOverlayTable_Init(void);
void ActorOverlayTable_Cleanup(void); void ActorOverlayTable_Cleanup(void);
// ? func_80038600(?); // ? func_80038600(?);
// ? SSNode_SetValue(?);
// ? SSNode_SetNull(?);
// ? func_80038728(?);
// ? func_80038780(?);
// ? DynaSSNodeList_Initialize(?);
// ? DynaSSNodeList_Alloc(?);
// ? DynaSSNodeList_ResetCount(?);
u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList*); u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList*);
// ? func_800388A8(?);
// ? func_800388E8(?);
// ? func_800389D4(?);
void func_80038A28(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest); void func_80038A28(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest);
f32 CollisionPoly_GetPointDistanceFromPlane(CollisionPoly* poly, Vec3f* point); f32 CollisionPoly_GetPointDistanceFromPlane(CollisionPoly* poly, Vec3f* point);
void CollisionPoly_GetVerticesByBgId(CollisionPoly* poly, s32 bgId, CollisionContext* colCtx, Vec3f* dest); void CollisionPoly_GetVerticesByBgId(CollisionPoly* poly, s32 bgId, CollisionContext* colCtx, Vec3f* dest);
// ? func_80038BE0(?);
// ? CollisionPoly_CheckYIntersectApprox1(?);
// ? CollisionPoly_CheckYIntersect(?);
// ? CollisionPoly_CheckYIntersectApprox2(?);
// ? CollisionPoly_CheckXIntersectApprox(?);
// ? CollisionPoly_CheckZIntersectApprox(?);
// ? CollisionPoly_LineVsPoly(?);
// ? CollisionPoly_SphVsPoly(?);
// ? StaticLookup_AddPolyToNodeList(?);
// ? func_8003965C(?);
// ? func_800396F0(?);
// ? func_8003992C(?);
// ? BgCheck_ComputeWallDisplacement(?);
// ? BgCheck_SphVsStaticWall(?);
s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionContext* colCtx, f32* outY, Vec3f* pos, s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionContext* colCtx, f32* outY, Vec3f* pos,
f32 checkHeight, CollisionPoly** outPoly); f32 checkHeight, CollisionPoly** outPoly);
s32 func_8003A5B8(SSList* headNodeId, CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB, s32 BgCheck_CheckLineAgainstSSList(SSList* headNodeId, CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB,
Vec3f* outPos, CollisionPoly** outPoly, f32* outDistSq, f32 chkDist, s32 bccFlags); Vec3f* outPos, CollisionPoly** outPoly, f32* outDistSq, f32 chkDist, s32 bccFlags);
// ? func_8003A7D8(?);
// ? BgCheck_SphVsFirstStaticPolyList(?);
// ? BgCheck_SphVsFirstStaticPoly(?);
// ? BgCheck_GetNearestStaticLookup(?);
// ? BgCheck_GetStaticLookup(?);
void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* arg2); void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* arg2);
// ? func_8003AEA8(?);
// ? func_8003B04C(?);
// ? func_8003B218(?);
// ? func_8003B3C8(?);
// ? func_8003BB18(?);
// ? BgCheck_IsSpotScene(?);
// ? BgCheck_TryGetCustomMemsize(?);
// ? BgCheck_SetSubdivisionDimension(?);
void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader); void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader);
// ? BgCheck_GetCollisionHeader(?);
s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos); s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos);
f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos);
f32 BgCheck_EntityRaycastFloor2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, f32 BgCheck_EntityRaycastFloor2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly,
@ -605,7 +567,7 @@ f32 BgCheck_AnyRaycastFloor2(CollisionContext* colCtx, CollisionPoly* outPoly, s
f32 BgCheck_CameraRaycastFloor2(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos); f32 BgCheck_CameraRaycastFloor2(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos);
f32 BgCheck_EntityRaycastFloor8(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); f32 BgCheck_EntityRaycastFloor8(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos);
f32 BgCheck_EntityRaycastFloor9(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos); f32 BgCheck_EntityRaycastFloor9(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos);
s32 BgCheck_SphVsWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev,
f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight, u8 argA); f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight, u8 argA);
s32 BgCheck_EntitySphVsWall1(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, s32 BgCheck_EntitySphVsWall1(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius,
CollisionPoly** outPoly, f32 checkHeight); CollisionPoly** outPoly, f32 checkHeight);
@ -615,11 +577,10 @@ s32 BgCheck_EntitySphVsWall3(CollisionContext* colCtx, Vec3f* posResult, Vec3f*
CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight); CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight);
s32 BgCheck_EntitySphVsWall4(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, s32 BgCheck_EntitySphVsWall4(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius,
CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight); CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight);
// ? BgCheck_CheckCeilingImpl(?);
s32 BgCheck_AnyCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight); s32 BgCheck_AnyCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight);
s32 BgCheck_EntityCheckCeiling(CollisionContext* colCtx, f32* arg1, Vec3f* arg2, f32 arg3, CollisionPoly** outPoly, s32 BgCheck_EntityCheckCeiling(CollisionContext* colCtx, f32* arg1, Vec3f* arg2, f32 arg3, CollisionPoly** outPoly,
s32* outBgId, Actor* actor); s32* outBgId, Actor* actor);
s32 BgCheck_LineTestImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB, s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB,
Vec3f* posResult, CollisionPoly** outPoly, s32* bgId, Actor* actor, f32 chkDist, u32 bccFlags); Vec3f* posResult, CollisionPoly** outPoly, s32* bgId, Actor* actor, f32 chkDist, u32 bccFlags);
s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId);
@ -642,25 +603,10 @@ s32 BgCheck_AnyLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec
s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace); s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace);
s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly,
s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId);
// ? BgCheck_SphVsFirstPolyImpl(?);
s32 BgCheck_SphVsFirstPoly(CollisionContext* colCtx, Vec3f* center, f32 radius); s32 BgCheck_SphVsFirstPoly(CollisionContext* colCtx, Vec3f* center, f32 radius);
void SSNodeList_Initialize(SSNodeList*); void SSNodeList_Initialize(SSNodeList*);
void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* this, s32 tblMax, s32 numPolys); void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* this, s32 tblMax, s32 numPolys);
u16 SSNodeList_GetNextNodeIdx(SSNodeList* this); u16 SSNodeList_GetNextNodeIdx(SSNodeList* this);
// ? ScaleRotPos_Initialize(?);
// ? ScaleRotPos_SetValue(?);
// ? ScaleRotPos_Equals(?);
// ? DynaLookup_ResetLists(?);
// ? DynaLookup_Reset(?);
// ? DynaLookup_ResetVtxStartIndex(?);
// ? BgActor_Initialize(?);
// ? BgActor_SetActor(?);
// ? BgActor_HasTransformChanged(?);
// ? DynaPoly_NullPolyList(?);
// ? DynaPoly_AllocPolyList(?);
// ? DynaPoly_NullVtxList(?);
// ? DynaPoly_AllocVtxList(?);
// ? DynaPoly_SetBgActorPrevTransform(?);
s32 DynaPoly_IsBgIdBgActor(s32 bgId); s32 DynaPoly_IsBgIdBgActor(s32 bgId);
void DynaPoly_Init(GlobalContext* globalCtx, DynaCollisionContext* dyna); void DynaPoly_Init(GlobalContext* globalCtx, DynaCollisionContext* dyna);
void DynaPoly_Alloc(GlobalContext* globalCtx, DynaCollisionContext* dyna); void DynaPoly_Alloc(GlobalContext* globalCtx, DynaCollisionContext* dyna);
@ -674,38 +620,27 @@ void func_8003EE6C(GlobalContext* globalCtx, DynaCollisionContext* dyna);
void func_8003F8EC(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor); void func_8003F8EC(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor);
void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna); void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna);
void DynaPoly_UpdateBgActorTransforms(GlobalContext* globalCtx, DynaCollisionContext* dyna); void DynaPoly_UpdateBgActorTransforms(GlobalContext* globalCtx, DynaCollisionContext* dyna);
// ? BgCheck_RaycastFloorDynaList(?);
f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast); f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast);
// ? BgCheck_SphVsDynaWallInBgActor(?);
s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* outZ, Vec3f* pos, f32 radius, s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* outZ, Vec3f* pos, f32 radius,
CollisionPoly** outPoly, s32* outBgId, Actor* actor); CollisionPoly** outPoly, s32* outBgId, Actor* actor);
// ? BgCheck_CheckDynaCeilingList(?);
s32 BgCheck_CheckDynaCeiling(CollisionContext* colCtx, u16 xpFlags, f32* outY, Vec3f* pos, f32 chkDist, s32 BgCheck_CheckDynaCeiling(CollisionContext* colCtx, u16 xpFlags, f32* outY, Vec3f* pos, f32 chkDist,
CollisionPoly** outPoly, s32* outBgId, Actor* actor); CollisionPoly** outPoly, s32* outBgId, Actor* actor);
// ? func_80040FA4(?); s32 BgCheck_CheckLineAgainstDyna(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
// ? func_80041128(?);
s32 func_80041240(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
CollisionPoly** outPoly, f32* distSq, s32* outBgId, Actor* actor, f32 chkDist, s32 bccFlags); CollisionPoly** outPoly, f32* distSq, s32* outBgId, Actor* actor, f32 chkDist, s32 bccFlags);
// ? BgCheck_SphVsFirstDynaPolyList(?);
// ? BgCheck_SphVsFirstDynaPolyInBgActor(?);
s32 BgCheck_SphVsFirstDynaPoly(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, s32 BgCheck_SphVsFirstDynaPoly(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId,
Vec3f* center, f32 radius, Actor* actor, u16 bciFlags); Vec3f* center, f32 radius, Actor* actor, u16 bciFlags);
// ? CollisionHeader_SegmentedToVirtual(?);
void CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest); void CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest);
void func_800418D0(CollisionContext* colCtx, GlobalContext* globalCtx); void func_800418D0(CollisionContext* colCtx, GlobalContext* globalCtx);
void BgCheck_ResetPolyCheckTbl(SSNodeList* nodeList, s32 numPolys); void BgCheck_ResetPolyCheckTbl(SSNodeList* nodeList, s32 numPolys);
// ? SurfaceType_GetData(?);
u32 SurfaceType_GetCamDataIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetCamDataIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u16 func_80041A4C(CollisionContext* colCtx, u32 camId, s32 bgId); u16 func_80041A4C(CollisionContext* colCtx, u32 camId, s32 bgId);
u16 SurfaceType_GetCameraSType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u16 SurfaceType_GetCameraSType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
// ? func_80041B24(?);
u16 SurfaceType_GetNumCameras(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u16 SurfaceType_GetNumCameras(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
Vec3s* func_80041C10(CollisionContext* colCtx, s32 camId, s32 bgId); Vec3s* func_80041C10(CollisionContext* colCtx, s32 camId, s32 bgId);
Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u32 SurfaceType_GetSceneExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetSceneExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u32 func_80041D4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 func_80041D4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
u32 func_80041D70(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 func_80041D70(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
// ? func_80041D94(?);
s32 func_80041DB8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 func_80041DB8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
s32 func_80041DE4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 func_80041DE4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
s32 func_80041E18(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 func_80041E18(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId);
@ -736,14 +671,8 @@ u16 WaterBox_GetCameraSType(CollisionContext* colCtx, WaterBox* waterBox);
u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox); u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox);
s32 func_80042708(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* point, Vec3f* closestPoint); s32 func_80042708(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* point, Vec3f* closestPoint);
s32 func_800427B4(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec3f* pointB, Vec3f* closestPoint); s32 func_800427B4(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec3f* pointB, Vec3f* closestPoint);
// ? BgCheck_DrawDynaPolyList(?);
// ? BgCheck_DrawBgActor(?);
void BgCheck_DrawDynaCollision(GlobalContext*, CollisionContext*); void BgCheck_DrawDynaCollision(GlobalContext*, CollisionContext*);
// ? BgCheck_DrawStaticPoly(?);
// ? BgCheck_DrawStaticPolyList(?);
void BgCheck_DrawStaticCollision(GlobalContext*, CollisionContext*); void BgCheck_DrawStaticCollision(GlobalContext*, CollisionContext*);
// ? func_800430A0(?);
// ? func_800432A0(?);
void func_80043334(CollisionContext* colCtx, Actor* actor, s32 bgId); void func_80043334(CollisionContext* colCtx, Actor* actor, s32 bgId);
s32 func_800433A4(CollisionContext* colCtx, s32 bgId, Actor* actor); s32 func_800433A4(CollisionContext* colCtx, s32 bgId, Actor* actor);
void DynaPolyActor_Init(DynaPolyActor* dynaActor, DynaPolyMoveFlag flags); void DynaPolyActor_Init(DynaPolyActor* dynaActor, DynaPolyMoveFlag flags);

View file

@ -158,6 +158,8 @@ s16 CollisionPoly_GetMinY(CollisionPoly* poly, Vec3s* vtxList) {
s32 c; s32 c;
s16 min; s16 min;
//! @bug Due to rounding errors, some polys with a slight slope have a y normal of 1.0f/-1.0f. As such, this
//! optimization returns the wrong minimum y for a subset of these polys.
if (poly->normal.y == COLPOLY_SNORMAL(1.0f) || poly->normal.y == COLPOLY_SNORMAL(-1.0f)) { if (poly->normal.y == COLPOLY_SNORMAL(1.0f) || poly->normal.y == COLPOLY_SNORMAL(-1.0f)) {
return vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)].y; return vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)].y;
} }
@ -458,8 +460,6 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll
} }
polyYMin = CollisionPoly_GetMinY(&polyList[polyId], vtxList); polyYMin = CollisionPoly_GetMinY(&polyList[polyId], vtxList);
// Swapped operands on this pointer addition
curNode = &colCtx->polyNodes.tbl[ssList->head]; curNode = &colCtx->polyNodes.tbl[ssList->head];
curPolyId = curNode->polyId; curPolyId = curNode->polyId;
@ -907,8 +907,9 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte
* `posB` and `outPos` returns the point of intersection with `outPoly` * `posB` and `outPos` returns the point of intersection with `outPoly`
* `outDistSq` returns the squared distance from `posA` to the point of intersect * `outDistSq` returns the squared distance from `posA` to the point of intersect
*/ */
s32 func_8003A5B8(SSList* ssList, CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB, s32 BgCheck_CheckLineAgainstSSList(SSList* ssList, CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA,
Vec3f* outPos, CollisionPoly** outPoly, f32* outDistSq, f32 chkDist, s32 bccFlags) { Vec3f* posB, Vec3f* outPos, CollisionPoly** outPoly, f32* outDistSq, f32 chkDist,
s32 bccFlags) {
SSNode* curNode; SSNode* curNode;
u8* checkedPoly; u8* checkedPoly;
Vec3f polyIntersect; Vec3f polyIntersect;
@ -973,27 +974,28 @@ s32 func_8003A5B8(SSList* ssList, CollisionContext* colCtx, u16 xpFlags1, u16 xp
* `posB` and `outPos` returns the point of intersection with `outPoly` * `posB` and `outPos` returns the point of intersection with `outPoly`
* `outDistSq` returns the squared distance from `posA` to the point of intersect * `outDistSq` returns the squared distance from `posA` to the point of intersect
*/ */
s32 func_8003A7D8(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB, s32 BgCheck_CheckLineInSubdivision(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2,
Vec3f* outPos, CollisionPoly** outPoly, f32 chkDist, f32* outDistSq, u32 bccFlags) { Vec3f* posA, Vec3f* posB, Vec3f* outPos, CollisionPoly** outPoly, f32 chkDist,
f32* outDistSq, u32 bccFlags) {
s32 result = false; s32 result = false;
if ((bccFlags & BGCHECK_CHECK_FLOOR) && lookup->floor.head != SS_NULL) { if ((bccFlags & BGCHECK_CHECK_FLOOR) && lookup->floor.head != SS_NULL) {
if (func_8003A5B8(&lookup->floor, colCtx, xpFlags1, xpFlags2, posA, posB, outPos, outPoly, outDistSq, chkDist, if (BgCheck_CheckLineAgainstSSList(&lookup->floor, colCtx, xpFlags1, xpFlags2, posA, posB, outPos, outPoly,
bccFlags)) { outDistSq, chkDist, bccFlags)) {
result = true; result = true;
} }
} }
if ((bccFlags & BGCHECK_CHECK_WALL) && lookup->wall.head != SS_NULL) { if ((bccFlags & BGCHECK_CHECK_WALL) && lookup->wall.head != SS_NULL) {
if (func_8003A5B8(&lookup->wall, colCtx, xpFlags1, xpFlags2, posA, posB, outPos, outPoly, outDistSq, chkDist, if (BgCheck_CheckLineAgainstSSList(&lookup->wall, colCtx, xpFlags1, xpFlags2, posA, posB, outPos, outPoly,
bccFlags)) { outDistSq, chkDist, bccFlags)) {
result = true; result = true;
} }
} }
if ((bccFlags & BGCHECK_CHECK_CEILING) && lookup->ceiling.head != SS_NULL) { if ((bccFlags & BGCHECK_CHECK_CEILING) && lookup->ceiling.head != SS_NULL) {
if (func_8003A5B8(&lookup->ceiling, colCtx, xpFlags1, xpFlags2, posA, posB, outPos, outPoly, outDistSq, chkDist, if (BgCheck_CheckLineAgainstSSList(&lookup->ceiling, colCtx, xpFlags1, xpFlags2, posA, posB, outPos, outPoly,
bccFlags)) { outDistSq, chkDist, bccFlags)) {
result = true; result = true;
} }
} }
@ -1080,7 +1082,7 @@ StaticLookup* BgCheck_GetNearestStaticLookup(CollisionContext* colCtx, StaticLoo
s32 subdivAmountX; s32 subdivAmountX;
BgCheck_GetStaticLookupIndicesFromPos(colCtx, pos, &sector); BgCheck_GetStaticLookupIndicesFromPos(colCtx, pos, &sector);
subdivAmountX = colCtx->subdivAmount.x; // fix regalloc subdivAmountX = colCtx->subdivAmount.x;
return (sector.z * subdivAmountX) * colCtx->subdivAmount.y + lookupTbl + sector.x + sector.y * subdivAmountX; return (sector.z * subdivAmountX) * colCtx->subdivAmount.y + lookupTbl + sector.x + sector.y * subdivAmountX;
} }
@ -1096,7 +1098,7 @@ StaticLookup* BgCheck_GetStaticLookup(CollisionContext* colCtx, StaticLookup* lo
return NULL; return NULL;
} }
BgCheck_GetStaticLookupIndicesFromPos(colCtx, pos, &sector); BgCheck_GetStaticLookupIndicesFromPos(colCtx, pos, &sector);
subdivAmountX = colCtx->subdivAmount.x; // fix regalloc subdivAmountX = colCtx->subdivAmount.x;
return (sector.z * subdivAmountX) * colCtx->subdivAmount.y + lookupTbl + sector.x + sector.y * subdivAmountX; return (sector.z * subdivAmountX) * colCtx->subdivAmount.y + lookupTbl + sector.x + sector.y * subdivAmountX;
} }
@ -1133,7 +1135,7 @@ void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos,
* decrements indices if `pos` is within BGCHECK_SUBDIV_OVERLAP units of the negative subdivision boundary * decrements indices if `pos` is within BGCHECK_SUBDIV_OVERLAP units of the negative subdivision boundary
* `sx`, `sy`, `sz` returns the subdivision x, y, z indices * `sx`, `sy`, `sz` returns the subdivision x, y, z indices
*/ */
void func_8003AEA8(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32* sz) { void BgCheck_GetSubdivisionMinBounds(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32* sz) {
f32 dx = pos->x - colCtx->minBounds.x; f32 dx = pos->x - colCtx->minBounds.x;
f32 dy = pos->y - colCtx->minBounds.y; f32 dy = pos->y - colCtx->minBounds.y;
f32 dz = pos->z - colCtx->minBounds.z; f32 dz = pos->z - colCtx->minBounds.z;
@ -1159,7 +1161,7 @@ void func_8003AEA8(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32*
* increments indicies if `pos` is within BGCHECK_SUBDIV_OVERLAP units of the postive subdivision boundary * increments indicies if `pos` is within BGCHECK_SUBDIV_OVERLAP units of the postive subdivision boundary
* `sx`, `sy`, `sz` returns the subdivision x, y, z indices * `sx`, `sy`, `sz` returns the subdivision x, y, z indices
*/ */
void func_8003B04C(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32* sz) { void BgCheck_GetSubdivisionMaxBounds(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32* sz) {
f32 dx = pos->x - colCtx->minBounds.x; f32 dx = pos->x - colCtx->minBounds.x;
f32 dy = pos->y - colCtx->minBounds.y; f32 dy = pos->y - colCtx->minBounds.y;
f32 dz = pos->z - colCtx->minBounds.z; f32 dz = pos->z - colCtx->minBounds.z;
@ -1188,8 +1190,9 @@ void func_8003B04C(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32*
* `subdivMinX`, `subdivMinY`, `subdivMinZ` returns the minimum subdivision x, y, z indices * `subdivMinX`, `subdivMinY`, `subdivMinZ` returns the minimum subdivision x, y, z indices
* `subdivMaxX`, `subdivMaxY`, `subdivMaxZ` returns the maximum subdivision x, y, z indices * `subdivMaxX`, `subdivMaxY`, `subdivMaxZ` returns the maximum subdivision x, y, z indices
*/ */
void func_8003B218(CollisionContext* colCtx, Vec3s* vtxList, CollisionPoly* polyList, s32* subdivMinX, s32* subdivMinY, void BgCheck_GetPolySubdivisionBounds(CollisionContext* colCtx, Vec3s* vtxList, CollisionPoly* polyList,
s32* subdivMinZ, s32* subdivMaxX, s32* subdivMaxY, s32* subdivMaxZ, s16 polyId) { s32* subdivMinX, s32* subdivMinY, s32* subdivMinZ, s32* subdivMaxX,
s32* subdivMaxY, s32* subdivMaxZ, s16 polyId) {
u16* vtxDataTemp; u16* vtxDataTemp;
Vec3f minVtx; Vec3f minVtx;
Vec3f maxVtx; Vec3f maxVtx;
@ -1229,15 +1232,15 @@ void func_8003B218(CollisionContext* colCtx, Vec3s* vtxList, CollisionPoly* poly
maxVtx.z = z; maxVtx.z = z;
} }
} }
func_8003AEA8(colCtx, &minVtx, subdivMinX, subdivMinY, subdivMinZ); BgCheck_GetSubdivisionMinBounds(colCtx, &minVtx, subdivMinX, subdivMinY, subdivMinZ);
func_8003B04C(colCtx, &maxVtx, subdivMaxX, subdivMaxY, subdivMaxZ); BgCheck_GetSubdivisionMaxBounds(colCtx, &maxVtx, subdivMaxX, subdivMaxY, subdivMaxZ);
} }
/** /**
* Test if poly `polyList`[`polyId`] intersects cube `min` `max` * Test if poly `polyList`[`polyId`] intersects cube `min` `max`
* returns true if the poly intersects the cube, else false * returns true if the poly intersects the cube, else false
*/ */
s32 func_8003B3C8(Vec3f* min, Vec3f* max, CollisionPoly* polyList, Vec3s* vtxList, s16 polyId) { s32 BgCheck_PolyIntersectsSubdivision(Vec3f* min, Vec3f* max, CollisionPoly* polyList, Vec3s* vtxList, s16 polyId) {
f32 intersect; f32 intersect;
Vec3f va2; Vec3f va2;
Vec3f vb2; Vec3f vb2;
@ -1339,7 +1342,7 @@ s32 func_8003B3C8(Vec3f* min, Vec3f* max, CollisionPoly* polyList, Vec3s* vtxLis
* Initialize StaticLookup Table * Initialize StaticLookup Table
* returns size of table, in bytes * returns size of table, in bytes
*/ */
u32 func_8003BB18(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLookup* lookupTbl) { u32 BgCheck_InitializeStaticLookup(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLookup* lookupTbl) {
Vec3s* vtxList; Vec3s* vtxList;
CollisionPoly* polyList; CollisionPoly* polyList;
s32 polyMax; s32 polyMax;
@ -1383,7 +1386,8 @@ u32 func_8003BB18(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLook
subdivLengthZ = colCtx->subdivLength.z + (2 * BGCHECK_SUBDIV_OVERLAP); subdivLengthZ = colCtx->subdivLength.z + (2 * BGCHECK_SUBDIV_OVERLAP);
for (polyIdx = 0; polyIdx < polyMax; polyIdx++) { for (polyIdx = 0; polyIdx < polyMax; polyIdx++) {
func_8003B218(colCtx, vtxList, polyList, &sxMin, &syMin, &szMin, &sxMax, &syMax, &szMax, polyIdx); BgCheck_GetPolySubdivisionBounds(colCtx, vtxList, polyList, &sxMin, &syMin, &szMin, &sxMax, &syMax, &szMax,
polyIdx);
spA4 = szMin * sp98 + lookupTbl; spA4 = szMin * sp98 + lookupTbl;
curSubdivMin.z = (colCtx->subdivLength.z * szMin + colCtx->minBounds.z) - BGCHECK_SUBDIV_OVERLAP; curSubdivMin.z = (colCtx->subdivLength.z * szMin + colCtx->minBounds.z) - BGCHECK_SUBDIV_OVERLAP;
curSubdivMax.z = curSubdivMin.z + subdivLengthZ; curSubdivMax.z = curSubdivMin.z + subdivLengthZ;
@ -1399,7 +1403,7 @@ u32 func_8003BB18(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLook
curSubdivMax.x = curSubdivMin.x + subdivLengthX; curSubdivMax.x = curSubdivMin.x + subdivLengthX;
for (sx = sxMin; sx < sxMax + 1; sx++) { for (sx = sxMin; sx < sxMax + 1; sx++) {
if (func_8003B3C8(&curSubdivMin, &curSubdivMax, polyList, vtxList, polyIdx)) { if (BgCheck_PolyIntersectsSubdivision(&curSubdivMin, &curSubdivMax, polyList, vtxList, polyIdx)) {
StaticLookup_AddPoly(phi_s0, colCtx, polyList, vtxList, polyIdx); StaticLookup_AddPoly(phi_s0, colCtx, polyList, vtxList, polyIdx);
} }
curSubdivMin.x += colCtx->subdivLength.x; curSubdivMin.x += colCtx->subdivLength.x;
@ -1594,7 +1598,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
SSNodeList_Initialize(&colCtx->polyNodes); SSNodeList_Initialize(&colCtx->polyNodes);
SSNodeList_Alloc(globalCtx, &colCtx->polyNodes, tblMax, colCtx->colHeader->nbPolygons); SSNodeList_Alloc(globalCtx, &colCtx->polyNodes, tblMax, colCtx->colHeader->nbPolygons);
lookupTblMemSize = func_8003BB18(colCtx, globalCtx, colCtx->lookupTbl); lookupTblMemSize = BgCheck_InitializeStaticLookup(colCtx, globalCtx, colCtx->lookupTbl);
osSyncPrintf(VT_FGCOL(GREEN)); osSyncPrintf(VT_FGCOL(GREEN));
osSyncPrintf("/*---結局 BG使用サイズ %dbyte---*/\n", memSize + lookupTblMemSize); osSyncPrintf("/*---結局 BG使用サイズ %dbyte---*/\n", memSize + lookupTblMemSize);
osSyncPrintf(VT_RST); osSyncPrintf(VT_RST);
@ -1842,7 +1846,7 @@ f32 BgCheck_EntityRaycastFloor9(CollisionContext* colCtx, CollisionPoly** outPol
* returns true if a collision is detected, else false * returns true if a collision is detected, else false
* `outPoly` returns the closest poly detected, while `outBgId` returns the poly owner * `outPoly` returns the closest poly detected, while `outBgId` returns the poly owner
*/ */
s32 BgCheck_SphVsWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev,
f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight, u8 argA) { f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight, u8 argA) {
StaticLookup* lookupTbl; StaticLookup* lookupTbl;
f32 temp_f0; f32 temp_f0;
@ -1885,7 +1889,8 @@ s32 BgCheck_SphVsWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul
// if there's movement on the xz plane, and argA flag is 0, // if there's movement on the xz plane, and argA flag is 0,
if ((dx != 0.0f || dz != 0.0f) && (argA & 1) == 0) { if ((dx != 0.0f || dz != 0.0f) && (argA & 1) == 0) {
if ((checkHeight + dy) < 5.0f) { if ((checkHeight + dy) < 5.0f) {
result = BgCheck_LineTestImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posNext, &posIntersect, &poly, //! @bug checkHeight is not applied to posPrev/posNext
result = BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posNext, &posIntersect, &poly,
&bgId, actor, 1.0f, BGCHECK_CHECK_ALL & ~BGCHECK_CHECK_CEILING); &bgId, actor, 1.0f, BGCHECK_CHECK_ALL & ~BGCHECK_CHECK_CEILING);
if (result) { if (result) {
ny = COLPOLY_GET_NORMAL(poly->normal.y); ny = COLPOLY_GET_NORMAL(poly->normal.y);
@ -1922,7 +1927,7 @@ s32 BgCheck_SphVsWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul
checkLineNext.y += checkHeight; checkLineNext.y += checkHeight;
checkLinePrev = *posPrev; checkLinePrev = *posPrev;
checkLinePrev.y = checkLineNext.y; checkLinePrev.y = checkLineNext.y;
result = BgCheck_LineTestImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, &checkLinePrev, &checkLineNext, result = BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, &checkLinePrev, &checkLineNext,
&posIntersect, &poly, &bgId, actor, 1.0f, bccFlags); &posIntersect, &poly, &bgId, actor, 1.0f, bccFlags);
if (result) { if (result) {
@ -1967,7 +1972,7 @@ s32 BgCheck_SphVsWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul
} }
// if a collision with a dyna poly was detected // if a collision with a dyna poly was detected
if (dynaPolyCollision == true || *outBgId != BGCHECK_SCENE) { if (dynaPolyCollision == true || *outBgId != BGCHECK_SCENE) {
if (BgCheck_LineTestImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posResult, &posIntersect2, &poly, if (BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posResult, &posIntersect2, &poly,
&bgId2, actor, 1.0f, BGCHECK_CHECK_ONE_FACE | BGCHECK_CHECK_WALL)) { &bgId2, actor, 1.0f, BGCHECK_CHECK_ONE_FACE | BGCHECK_CHECK_WALL)) {
nx3 = COLPOLY_GET_NORMAL(poly->normal.x); nx3 = COLPOLY_GET_NORMAL(poly->normal.x);
nz3 = COLPOLY_GET_NORMAL(poly->normal.z); nz3 = COLPOLY_GET_NORMAL(poly->normal.z);
@ -2000,7 +2005,7 @@ s32 BgCheck_EntitySphVsWall1(CollisionContext* colCtx, Vec3f* posResult, Vec3f*
CollisionPoly** outPoly, f32 checkHeight) { CollisionPoly** outPoly, f32 checkHeight) {
s32 bgId; s32 bgId;
return BgCheck_SphVsWallImpl(colCtx, COLPOLY_IGNORE_ENTITY, posResult, posNext, posPrev, radius, outPoly, &bgId, return BgCheck_CheckWallImpl(colCtx, COLPOLY_IGNORE_ENTITY, posResult, posNext, posPrev, radius, outPoly, &bgId,
NULL, checkHeight, 0); NULL, checkHeight, 0);
} }
@ -2013,7 +2018,7 @@ s32 BgCheck_EntitySphVsWall1(CollisionContext* colCtx, Vec3f* posResult, Vec3f*
*/ */
s32 BgCheck_EntitySphVsWall2(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, s32 BgCheck_EntitySphVsWall2(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius,
CollisionPoly** outPoly, s32* outBgId, f32 checkHeight) { CollisionPoly** outPoly, s32* outBgId, f32 checkHeight) {
return BgCheck_SphVsWallImpl(colCtx, COLPOLY_IGNORE_ENTITY, posResult, posNext, posPrev, radius, outPoly, outBgId, return BgCheck_CheckWallImpl(colCtx, COLPOLY_IGNORE_ENTITY, posResult, posNext, posPrev, radius, outPoly, outBgId,
NULL, checkHeight, 0); NULL, checkHeight, 0);
} }
@ -2027,7 +2032,7 @@ s32 BgCheck_EntitySphVsWall2(CollisionContext* colCtx, Vec3f* posResult, Vec3f*
*/ */
s32 BgCheck_EntitySphVsWall3(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, s32 BgCheck_EntitySphVsWall3(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius,
CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight) { CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight) {
return BgCheck_SphVsWallImpl(colCtx, COLPOLY_IGNORE_ENTITY, posResult, posNext, posPrev, radius, outPoly, outBgId, return BgCheck_CheckWallImpl(colCtx, COLPOLY_IGNORE_ENTITY, posResult, posNext, posPrev, radius, outPoly, outBgId,
actor, checkHeight, 0); actor, checkHeight, 0);
} }
@ -2042,7 +2047,7 @@ s32 BgCheck_EntitySphVsWall3(CollisionContext* colCtx, Vec3f* posResult, Vec3f*
*/ */
s32 BgCheck_EntitySphVsWall4(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, s32 BgCheck_EntitySphVsWall4(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius,
CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight) { CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight) {
return BgCheck_SphVsWallImpl(colCtx, COLPOLY_IGNORE_ENTITY, posResult, posNext, posPrev, radius, outPoly, outBgId, return BgCheck_CheckWallImpl(colCtx, COLPOLY_IGNORE_ENTITY, posResult, posNext, posPrev, radius, outPoly, outBgId,
actor, checkHeight, 1); actor, checkHeight, 1);
} }
@ -2117,7 +2122,7 @@ s32 BgCheck_EntityCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos,
* `posB`? `posResult` returns the point of intersection * `posB`? `posResult` returns the point of intersection
* `outPoly` returns the pointer to the intersected poly, while `outBgId` returns the entity the poly belongs to * `outPoly` returns the pointer to the intersected poly, while `outBgId` returns the entity the poly belongs to
*/ */
s32 BgCheck_LineTestImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB, s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, Vec3f* posA, Vec3f* posB,
Vec3f* posResult, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 chkDist, Vec3f* posResult, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 chkDist,
u32 bccFlags) { u32 bccFlags) {
StaticLookup* lookupTbl = colCtx->lookupTbl; StaticLookup* lookupTbl = colCtx->lookupTbl;
@ -2179,8 +2184,8 @@ s32 BgCheck_LineTestImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, V
for (k = subdivMin[0]; k < subdivMax[0] + 1; k++) { for (k = subdivMin[0]; k < subdivMax[0] + 1; k++) {
if (Math3D_LineVsCube(&sectorMin, &sectorMax, posA, &posBTemp) == true && if (Math3D_LineVsCube(&sectorMin, &sectorMax, posA, &posBTemp) == true &&
func_8003A7D8(lookup, colCtx, xpFlags1, xpFlags2, posA, &posBTemp, posResult, outPoly, chkDist, BgCheck_CheckLineInSubdivision(lookup, colCtx, xpFlags1, xpFlags2, posA, &posBTemp, posResult,
&distSq, bccFlags)) { outPoly, chkDist, &distSq, bccFlags)) {
result = true; result = true;
} }
@ -2201,14 +2206,16 @@ s32 BgCheck_LineTestImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, V
} else if (BgCheck_PosInStaticBoundingBox(colCtx, posA) == false) { } else if (BgCheck_PosInStaticBoundingBox(colCtx, posA) == false) {
return false; return false;
} else { } else {
result = func_8003A7D8(BgCheck_GetNearestStaticLookup(colCtx, lookupTbl, posA), colCtx, xpFlags1, xpFlags2, result =
posA, &posBTemp, posResult, outPoly, chkDist, &distSq, bccFlags); BgCheck_CheckLineInSubdivision(BgCheck_GetNearestStaticLookup(colCtx, lookupTbl, posA), colCtx, xpFlags1,
xpFlags2, posA, &posBTemp, posResult, outPoly, chkDist, &distSq, bccFlags);
if (result == true) { if (result == true) {
distSq = Math3D_Vec3fDistSq(posResult, posA); distSq = Math3D_Vec3fDistSq(posResult, posA);
} }
} }
if ((bccFlags & BGCHECK_CHECK_DYNA) && func_80041240(colCtx, xpFlags1, posA, &posBTemp, posResult, outPoly, &distSq, if ((bccFlags & BGCHECK_CHECK_DYNA) &&
outBgId, actor, chkDist, bccFlags)) { BgCheck_CheckLineAgainstDyna(colCtx, xpFlags1, posA, &posBTemp, posResult, outPoly, &distSq, outBgId, actor,
chkDist, bccFlags)) {
result = true; result = true;
} }
return result; return result;
@ -2245,7 +2252,7 @@ u32 BgCheck_GetBccFlags(s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace,
s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace,
s32* bgId) { s32* bgId) {
return BgCheck_LineTestImpl(colCtx, COLPOLY_IGNORE_CAMERA, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_CAMERA, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly,
bgId, NULL, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true)); bgId, NULL, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true));
} }
@ -2256,7 +2263,7 @@ s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB,
s32 BgCheck_CameraLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, s32 BgCheck_CameraLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace,
s32* bgId) { s32* bgId) {
return BgCheck_LineTestImpl(colCtx, COLPOLY_IGNORE_NONE, COLPOLY_IGNORE_CAMERA, posA, posB, posResult, outPoly, return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_NONE, COLPOLY_IGNORE_CAMERA, posA, posB, posResult, outPoly,
bgId, NULL, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true)); bgId, NULL, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true));
} }
@ -2267,7 +2274,7 @@ s32 BgCheck_CameraLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB,
s32 BgCheck_EntityLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, s32 BgCheck_EntityLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace,
s32* bgId) { s32* bgId) {
return BgCheck_LineTestImpl(colCtx, COLPOLY_IGNORE_ENTITY, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_ENTITY, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly,
bgId, NULL, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true)); bgId, NULL, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true));
} }
@ -2278,7 +2285,7 @@ s32 BgCheck_EntityLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB,
s32 BgCheck_EntityLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, s32 BgCheck_EntityLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId,
Actor* actor) { Actor* actor) {
return BgCheck_LineTestImpl(colCtx, COLPOLY_IGNORE_ENTITY, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_ENTITY, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly,
bgId, actor, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true)); bgId, actor, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true));
} }
@ -2289,7 +2296,7 @@ s32 BgCheck_EntityLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB,
s32 BgCheck_EntityLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, s32 BgCheck_EntityLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId,
Actor* actor, f32 chkDist) { Actor* actor, f32 chkDist) {
return BgCheck_LineTestImpl(colCtx, COLPOLY_IGNORE_ENTITY, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_ENTITY, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly,
bgId, actor, chkDist, bgId, actor, chkDist,
BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true)); BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true));
} }
@ -2301,8 +2308,9 @@ s32 BgCheck_EntityLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB,
s32 BgCheck_ProjectileLineTest(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, s32 BgCheck_ProjectileLineTest(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace,
s32* bgId) { s32* bgId) {
return BgCheck_LineTestImpl(colCtx, COLPOLY_IGNORE_PROJECTILES, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_PROJECTILES, COLPOLY_IGNORE_NONE, posA, posB, posResult,
bgId, NULL, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true)); outPoly, bgId, NULL, 1.0f,
BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true));
} }
/** /**
@ -2322,8 +2330,8 @@ s32 BgCheck_AnyLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec
s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace) { s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace) {
s32 bgId; s32 bgId;
return BgCheck_LineTestImpl(colCtx, COLPOLY_IGNORE_NONE, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, &bgId, return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_NONE, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly,
NULL, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true)); &bgId, NULL, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true));
} }
/** /**
@ -2332,7 +2340,7 @@ s32 BgCheck_AnyLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec
*/ */
s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly,
s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId) { s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId) {
return BgCheck_LineTestImpl(colCtx, COLPOLY_IGNORE_NONE, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, bgId, return BgCheck_CheckLineImpl(colCtx, COLPOLY_IGNORE_NONE, COLPOLY_IGNORE_NONE, posA, posB, posResult, outPoly, bgId,
NULL, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true)); NULL, 1.0f, BgCheck_GetBccFlags(chkWall, chkFloor, chkCeil, chkOneFace, true));
} }
@ -3520,7 +3528,7 @@ s32 BgCheck_CheckDynaCeiling(CollisionContext* colCtx, u16 xpFlags, f32* outY, V
* Tests if DynaLineTest intersects with a poly * Tests if DynaLineTest intersects with a poly
* returns true if a poly was intersected, else false * returns true if a poly was intersected, else false
*/ */
s32 func_80040FA4(DynaLineTest* dynaLineTest) { s32 BgCheck_CheckLineAgainstBgActorSSList(DynaLineTest* dynaLineTest) {
f32 distSq; f32 distSq;
s32 result; s32 result;
CollisionPoly* curPoly; CollisionPoly* curPoly;
@ -3574,7 +3582,7 @@ s32 func_80040FA4(DynaLineTest* dynaLineTest) {
* `outPoly` returns the poly intersected * `outPoly` returns the poly intersected
* `distSq` returns the squared distance of the intersection * `distSq` returns the squared distance of the intersection
*/ */
s32 func_80041128(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* posB, Vec3f* posResult, s32 BgCheck_CheckLineAgainstBgActor(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* posB, Vec3f* posResult,
CollisionPoly** outPoly, f32* distSq, s32 bgId, f32 chkDist, s32 bccFlags) { CollisionPoly** outPoly, f32* distSq, s32 bgId, f32 chkDist, s32 bccFlags) {
s32 result = false; s32 result = false;
DynaLineTest dynaLineTest; DynaLineTest dynaLineTest;
@ -3592,19 +3600,19 @@ s32 func_80041128(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* pos
dynaLineTest.ssList = &colCtx->dyna.bgActors[bgId].dynaLookup.wall; dynaLineTest.ssList = &colCtx->dyna.bgActors[bgId].dynaLookup.wall;
if (bccFlags & BGCHECK_CHECK_WALL) { if (bccFlags & BGCHECK_CHECK_WALL) {
if (func_80040FA4(&dynaLineTest)) { if (BgCheck_CheckLineAgainstBgActorSSList(&dynaLineTest)) {
result = true; result = true;
} }
} }
dynaLineTest.ssList = &colCtx->dyna.bgActors[bgId].dynaLookup.floor; dynaLineTest.ssList = &colCtx->dyna.bgActors[bgId].dynaLookup.floor;
if (bccFlags & BGCHECK_CHECK_FLOOR) { if (bccFlags & BGCHECK_CHECK_FLOOR) {
if (func_80040FA4(&dynaLineTest)) { if (BgCheck_CheckLineAgainstBgActorSSList(&dynaLineTest)) {
result = true; result = true;
} }
} }
dynaLineTest.ssList = &colCtx->dyna.bgActors[bgId].dynaLookup.ceiling; dynaLineTest.ssList = &colCtx->dyna.bgActors[bgId].dynaLookup.ceiling;
if (bccFlags & BGCHECK_CHECK_CEILING) { if (bccFlags & BGCHECK_CHECK_CEILING) {
if (func_80040FA4(&dynaLineTest)) { if (BgCheck_CheckLineAgainstBgActorSSList(&dynaLineTest)) {
result = true; result = true;
} }
} }
@ -3617,8 +3625,9 @@ s32 func_80041128(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* pos
* `outPoly` returns the pointer of the poly intersected. * `outPoly` returns the pointer of the poly intersected.
* `outBgId` returns the BgActor index of the poly * `outBgId` returns the BgActor index of the poly
*/ */
s32 func_80041240(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* posB, Vec3f* posResult, 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) { CollisionPoly** outPoly, f32* distSq, s32* outBgId, Actor* actor, f32 chkDist,
s32 bccFlags) {
s32 pad; s32 pad;
s32 i; s32 i;
s32 result = false; s32 result = false;
@ -3636,8 +3645,8 @@ s32 func_80041240(CollisionContext* colCtx, u16 xpFlags, Vec3f* posA, Vec3f* pos
line.a = *posA; line.a = *posA;
line.b = *posB; line.b = *posB;
if (Math3D_LineVsSph(&colCtx->dyna.bgActors[i].boundingSphere, &line) != 0) { if (Math3D_LineVsSph(&colCtx->dyna.bgActors[i].boundingSphere, &line) != 0) {
if (func_80041128(colCtx, xpFlags, posA, posB, posResult, outPoly, distSq, i, chkDist, if (BgCheck_CheckLineAgainstBgActor(colCtx, xpFlags, posA, posB, posResult, outPoly, distSq,
bccFlags) == true) { i, chkDist, bccFlags) == true) {
*outBgId = i; *outBgId = i;
result = true; result = true;
} }

View file

@ -394,7 +394,8 @@ void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) {
func_80038290(globalCtx, &this->actor, &this->headRot, &this->bodyRot, this->actor.focus.pos); func_80038290(globalCtx, &this->actor, &this->headRot, &this->bodyRot, this->actor.focus.pos);
} }
s32 EnSyatekiMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { s32 EnSyatekiMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
void* thisx) {
EnSyatekiMan* this = THIS; EnSyatekiMan* this = THIS;
s32 turnDirection; s32 turnDirection;