Improve sanity check for torsoPos (fixes PVP when using non-player-models)

This commit is contained in:
MysterD 2022-03-25 21:36:46 -07:00
parent e1000f32fc
commit 0b48fb139a
3 changed files with 4 additions and 3 deletions

View File

@ -293,6 +293,7 @@ struct MarioBodyState
/*0x18*/ Vec3f heldObjLastPosition; /// also known as HOLP
/*????*/ Vec3f torsoPos;
/*????*/ Vec3f handFootPos[4];
/*????*/ u32 updateTorsoTime;
//u8 padding[4];
};

View File

@ -516,6 +516,7 @@ Gfx* geo_mario_tilt_torso(s32 callContext, struct GraphNode* node, Mat4* mtx) {
}
// update torso position in bodyState
get_pos_from_transform_mtx(bodyState->torsoPos, *curTransform, *gCurGraphNodeCamera->matrixPtr);
bodyState->updateTorsoTime = gGlobalTimer;
}
return NULL;
}

View File

@ -276,9 +276,8 @@ void bhv_mario_update(void) {
gMarioState = &gMarioStates[stateIndex];
// sanity check torsoPos, it isn't updated off-screen otherwise
Vec3f torsoDiff = { 0 };
vec3f_dif(torsoDiff, gMarioState->pos, gMarioState->marioBodyState->torsoPos);
if (vec3f_length(torsoDiff) > 300) {
extern u32 gGlobalTimer;
if (gMarioState->marioBodyState->updateTorsoTime != (gGlobalTimer - 1)) {
vec3f_copy(gMarioState->marioBodyState->torsoPos, gMarioState->pos);
}