Add headPos to marioBodyState

This commit is contained in:
MysterD 2022-04-20 18:21:36 -07:00
parent 2347ab61c1
commit 18d7140954
5 changed files with 11 additions and 2 deletions

View File

@ -596,6 +596,7 @@
--- @field public grabPos integer
--- @field public handState integer
--- @field public headAngle Vec3s
--- @field public headPos Vec3f
--- @field public heldObjLastPosition Vec3f
--- @field public modelState integer
--- @field public punchState integer

View File

@ -879,6 +879,7 @@
| grabPos | `integer` | |
| handState | `integer` | |
| headAngle | [Vec3s](structs.md#Vec3s) | read-only |
| headPos | [Vec3f](structs.md#Vec3f) | read-only |
| heldObjLastPosition | [Vec3f](structs.md#Vec3f) | read-only |
| modelState | `integer` | |
| punchState | `integer` | |

View File

@ -281,6 +281,7 @@ struct MarioBodyState
/*????*/ Vec3f torsoPos;
/*????*/ Vec3f handFootPos[4];
/*????*/ u32 updateTorsoTime;
/*????*/ Vec3f headPos;
//u8 padding[4];
};

View File

@ -522,7 +522,7 @@ Gfx* geo_mario_tilt_torso(s32 callContext, struct GraphNode* node, Mat4* mtx) {
/**
* Makes Mario's head rotate with the camera angle when in C-up mode
*/
Gfx* geo_mario_head_rotation(s32 callContext, struct GraphNode* node, UNUSED Mat4* c) {
Gfx* geo_mario_head_rotation(s32 callContext, struct GraphNode* node, Mat4* c) {
u8 plrIdx = geo_get_processing_object_index();
struct MarioBodyState* bodyState = &gBodyStates[plrIdx];
s32 action = bodyState->action;
@ -553,6 +553,11 @@ Gfx* geo_mario_head_rotation(s32 callContext, struct GraphNode* node, UNUSED Mat
vec3s_copy(rotNode->prevRotation, rotNode->rotation);
rotNode->prevTimestamp = gGlobalTimer;
}
// update head position in bodyState
get_pos_from_transform_mtx(bodyState->headPos,
*c,
*gCurGraphNodeCamera->matrixPtr);
}
return NULL;
}

View File

@ -693,7 +693,7 @@ static struct LuaObjectField sMarioAnimationFields[LUA_MARIO_ANIMATION_FIELD_COU
{ "targetAnim", LVT_COBJECT_P, offsetof(struct MarioAnimation, targetAnim), false, LOT_ANIMATION },
};
#define LUA_MARIO_BODY_STATE_FIELD_COUNT 13
#define LUA_MARIO_BODY_STATE_FIELD_COUNT 14
static struct LuaObjectField sMarioBodyStateFields[LUA_MARIO_BODY_STATE_FIELD_COUNT] = {
{ "action", LVT_U32, offsetof(struct MarioBodyState, action), false, LOT_NONE },
{ "capState", LVT_S8, offsetof(struct MarioBodyState, capState), false, LOT_NONE },
@ -702,6 +702,7 @@ static struct LuaObjectField sMarioBodyStateFields[LUA_MARIO_BODY_STATE_FIELD_CO
// { "handFootPos", LOT_???, offsetof(struct MarioBodyState, handFootPos), false, LOT_??? }, <--- UNIMPLEMENTED
{ "handState", LVT_S8, offsetof(struct MarioBodyState, handState), false, LOT_NONE },
{ "headAngle", LVT_COBJECT, offsetof(struct MarioBodyState, headAngle), true, LOT_VEC3S },
{ "headPos", LVT_COBJECT, offsetof(struct MarioBodyState, headPos), true, LOT_VEC3F },
{ "heldObjLastPosition", LVT_COBJECT, offsetof(struct MarioBodyState, heldObjLastPosition), true, LOT_VEC3F },
{ "modelState", LVT_S16, offsetof(struct MarioBodyState, modelState), false, LOT_NONE },
{ "punchState", LVT_U8, offsetof(struct MarioBodyState, punchState), false, LOT_NONE },