Collision tweaks

This commit is contained in:
mzxrules 2025-06-03 20:49:22 -04:00
parent f456bc6bf8
commit 6bdf619a62
11 changed files with 26 additions and 19 deletions

View File

@ -361,7 +361,7 @@ typedef struct DynaLineTest {
/* 0x28 */ f32 chkDist; // distance from poly
} DynaLineTest;
void func_80038A28(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest);
void CollisionPoly_GetGroundMtxF(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest);
f32 CollisionPoly_GetPointDistanceFromPlane(CollisionPoly* poly, Vec3f* point);
void CollisionPoly_GetVerticesByBgId(CollisionPoly* poly, s32 bgId, CollisionContext* colCtx, Vec3f* dest);
void BgCheck_Allocate(CollisionContext* colCtx, struct PlayState* play, CollisionHeader* colHeader);

View File

@ -534,6 +534,7 @@ s32 CollisionCheck_SetOC(struct PlayState* play, CollisionCheckContext* colChkCt
s32 CollisionCheck_SetOC_SAC(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index);
s32 CollisionCheck_SetOCLine(struct PlayState* play, CollisionCheckContext* colChkCtx, OcLine* collider);
void CollisionCheck_BlueBlood(struct PlayState* play, Collider* collider, Vec3f* v);
void CollisionCheck_GreenBlood(struct PlayState* play, Collider* collider, Vec3f* v);
void CollisionCheck_AT(struct PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_OC(struct PlayState* play, CollisionCheckContext* colChkCtx);
void CollisionCheck_InitInfo(CollisionCheckInfo* info);

View File

@ -30,7 +30,7 @@ s32 Math3D_PlaneVsLineSegClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32
static InfiniteLine planeIntersectLine;
static Linef planeIntersectSeg;
Vec3f sp34; // unused
Vec3f _point; // discarded
if (!Math3D_PlaneVsPlaneNewLine(planeAA, planeAB, planeAC, planeADist, planeBA, planeBB, planeBC, planeBDist,
&planeIntersectLine)) {
@ -44,9 +44,9 @@ s32 Math3D_PlaneVsLineSegClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32
planeIntersectSeg.b.y = (planeIntersectLine.dir.y * 100.0f) + planeIntersectLine.point.y;
planeIntersectSeg.b.z = (planeIntersectLine.dir.z * 100.0f) + planeIntersectLine.point.z;
// closestPoint is a point on planeIntersect, sp34 is a point on linePointA, linePointB
// closestPoint is a point on planeIntersect, _point is a point on linePointA, linePointB
if (!Math3D_LineVsLineClosestTwoPoints(&planeIntersectSeg.a, &planeIntersectSeg.b, linePointA, linePointB,
closestPoint, &sp34)) {
closestPoint, &_point)) {
return false;
}
return true;

View File

@ -97,7 +97,8 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, PlayState* play, Gfx* dlist,
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u32)(actor->shape.shadowAlpha * temp2) & 0xFF);
}
func_80038A28(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &sp60);
CollisionPoly_GetGroundMtxF(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z,
&sp60);
Matrix_Put(&sp60);
if (dlist != gCircleShadowDL) {
@ -4053,7 +4054,7 @@ void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) {
yIntersect = BgCheck_EntityRaycastDown2(play, &play->colCtx, &groundPoly, &checkPos);
if (groundPoly != NULL) {
func_80038A28(groundPoly, arg0->x, yIntersect, arg0->z, &sp60);
CollisionPoly_GetGroundMtxF(groundPoly, arg0->x, yIntersect, arg0->z, &sp60);
Matrix_Put(&sp60);
} else {
Matrix_Translate(arg0->x, arg0->y, arg0->z, MTXMODE_NEW);

View File

@ -243,7 +243,7 @@ void CollisionPoly_GetNormalF(CollisionPoly* poly, f32* nx, f32* ny, f32* nz) {
/**
* Compute transform matrix mapping +y (up) to the collision poly's normal
*/
void func_80038A28(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest) {
void CollisionPoly_GetGroundMtxF(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest) {
f32 nx;
f32 ny;
f32 nz;
@ -3919,7 +3919,10 @@ void CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest) {
}
/**
* SEGMENT_TO_VIRTUAL all active BgActor CollisionHeaders
* SEGMENTED_TO_VIRTUAL all active BgActor CollisionHeaders
*
* When the game is paused, object data is clobbered to make space for the pause menu assets.
* Once the object data is restored, pointers in the CollisionHeader must be linked again before the game can resume.
*/
void func_800418D0(CollisionContext* colCtx, PlayState* play) {
DynaCollisionContext* dyna = &colCtx->dyna;

View File

@ -1012,7 +1012,7 @@ s32 func_80045508(Camera* camera, VecGeo* diffGeo, CamColChk* eyeChk, CamColChk*
eyeChk->geoNorm = OLib_Vec3fToVecGeo(&eyeChk->norm);
if (eyeChk->geoNorm.pitch >= 0x2EE1) {
if (eyeChk->geoNorm.pitch > 0x2EE0) {
eyeChk->geoNorm.yaw = diffGeo->yaw;
}
@ -1042,7 +1042,7 @@ s32 func_80045508(Camera* camera, VecGeo* diffGeo, CamColChk* eyeChk, CamColChk*
atChk->geoNorm = OLib_Vec3fToVecGeo(&atChk->norm);
if (atChk->geoNorm.pitch >= 0x2EE1) {
if (atChk->geoNorm.pitch > 0x2EE0) {
atChk->geoNorm.yaw = diffGeo->yaw - 0x7FFF;
}
@ -1961,7 +1961,7 @@ s32 Camera_Normal2(Camera* camera) {
camera->dist = adjGeo.r = Camera_ClampDist(camera, sp90.r, roData->unk_04, roData->unk_08, 0);
if (!(rwData->unk_28 & 1)) {
if (adjGeo.pitch >= 0xE39) {
if (adjGeo.pitch > 0xE38) {
adjGeo.pitch += ((s16)(0xE38 - adjGeo.pitch) >> 2);
}
@ -5684,7 +5684,7 @@ s32 Camera_Unique9(Camera* camera) {
scratchGeo.yaw += CAM_DEG_TO_BINANG(rwData->curKeyFrame->eyeTargetInit.y);
// 3A98 ~ 82.40 degrees
if (scratchGeo.pitch >= 0x3A99) {
if (scratchGeo.pitch > 0x3A98) {
scratchGeo.pitch = 0x3A98;
}

View File

@ -1266,7 +1266,8 @@ void EnDekubaba_DrawBaseShadow(EnDekubaba* this, PlayState* play) {
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255);
func_80038A28(this->boundFloor, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, &mtx);
CollisionPoly_GetGroundMtxF(this->boundFloor, this->actor.home.pos.x, this->actor.home.pos.y,
this->actor.home.pos.z, &mtx);
Matrix_Mult(&mtx, MTXMODE_NEW);
horizontalScale = this->size * 0.15f;

View File

@ -459,7 +459,8 @@ void EnKarebaba_DrawBaseShadow(EnKarebaba* this, PlayState* play) {
Gfx_SetupDL_44Xlu(play->state.gfxCtx);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255);
func_80038A28(this->boundFloor, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, &mf);
CollisionPoly_GetGroundMtxF(this->boundFloor, this->actor.home.pos.x, this->actor.home.pos.y,
this->actor.home.pos.z, &mf);
Matrix_Mult(&mf, MTXMODE_NEW);
Matrix_Scale(0.15f, 1.0f, 0.15f, MTXMODE_APPLY);
MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_en_karebaba.c", 1029);

View File

@ -197,7 +197,7 @@ void EnNwc_DrawChicks(EnNwc* this, PlayState* play) {
for (i = 0; i < this->count; i++, chick++) {
if ((chick->type != CHICK_NONE) && (chick->floorPoly != NULL)) {
func_80038A28(chick->floorPoly, chick->pos.x, chick->floorY, chick->pos.z, &floorMat);
CollisionPoly_GetGroundMtxF(chick->floorPoly, chick->pos.x, chick->floorY, chick->pos.z, &floorMat);
Matrix_Put(&floorMat);
Matrix_RotateY(BINANG_TO_RAD(chick->rot.y), MTXMODE_APPLY);
Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY);

View File

@ -608,8 +608,8 @@ void EnWallmas_DrawXlu(EnWallmas* this, PlayState* play) {
Gfx_SetupDL_44Xlu(play->state.gfxCtx);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255);
func_80038A28(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z,
&mf);
CollisionPoly_GetGroundMtxF(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight,
this->actor.world.pos.z, &mf);
Matrix_Mult(&mf, MTXMODE_NEW);
if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_ReturnToCeiling) &&

View File

@ -79,14 +79,14 @@ void EffectSsDeadDs_Draw(PlayState* play, u32 index, EffectSs* this) {
prevPos.z = pos.z - this->velocity.z;
if (BgCheck_EntitySphVsWall1(&play->colCtx, &this->pos, &pos, &prevPos, 1.5f, &groundPoly, 1.0f)) {
func_80038A28(groundPoly, this->pos.x, this->pos.y, this->pos.z, &mf);
CollisionPoly_GetGroundMtxF(groundPoly, this->pos.x, this->pos.y, this->pos.z, &mf);
Matrix_Put(&mf);
} else {
pos.y++;
yIntersect = BgCheck_EntityRaycastDown1(&play->colCtx, &groundPoly, &pos);
if (groundPoly != NULL) {
func_80038A28(groundPoly, this->pos.x, yIntersect + 1.5f, this->pos.z, &mf);
CollisionPoly_GetGroundMtxF(groundPoly, this->pos.x, yIntersect + 1.5f, this->pos.z, &mf);
Matrix_Put(&mf);
} else {
Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW);