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 9ab1021f33
commit 5b45e44b81
3 changed files with 4 additions and 3 deletions

View file

@ -293,6 +293,7 @@ struct MarioBodyState
/*0x18*/ Vec3f heldObjLastPosition; /// also known as HOLP /*0x18*/ Vec3f heldObjLastPosition; /// also known as HOLP
/*????*/ Vec3f torsoPos; /*????*/ Vec3f torsoPos;
/*????*/ Vec3f handFootPos[4]; /*????*/ Vec3f handFootPos[4];
/*????*/ u32 updateTorsoTime;
//u8 padding[4]; //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 // update torso position in bodyState
get_pos_from_transform_mtx(bodyState->torsoPos, *curTransform, *gCurGraphNodeCamera->matrixPtr); get_pos_from_transform_mtx(bodyState->torsoPos, *curTransform, *gCurGraphNodeCamera->matrixPtr);
bodyState->updateTorsoTime = gGlobalTimer;
} }
return NULL; return NULL;
} }

View file

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