diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index ac4bd1fb..0e06bdaa 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -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 diff --git a/docs/lua/structs.md b/docs/lua/structs.md index df710091..91ac4aed 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -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` | | diff --git a/include/types.h b/include/types.h index 26a55cbe..cbdfb9bf 100644 --- a/include/types.h +++ b/include/types.h @@ -281,6 +281,7 @@ struct MarioBodyState /*????*/ Vec3f torsoPos; /*????*/ Vec3f handFootPos[4]; /*????*/ u32 updateTorsoTime; + /*????*/ Vec3f headPos; //u8 padding[4]; }; diff --git a/src/game/mario_misc.c b/src/game/mario_misc.c index 48a1b700..87c018d7 100644 --- a/src/game/mario_misc.c +++ b/src/game/mario_misc.c @@ -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; } diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 02732637..8db814e6 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -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 },