diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 9626d3b75..601038e72 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -2999,6 +2999,9 @@ GRAPH_RENDER_PLAYER = (1 << 7) --- @type integer GRAPH_EXTRA_FORCE_3D = (1 << 0) +--- @type integer +GRAPH_EXTRA_ROTATE_HELD = (1 << 1) + --- @type integer GRAPH_NODE_TYPE_FUNCTIONAL = 0x100 diff --git a/docs/lua/constants.md b/docs/lua/constants.md index 744db5da8..6f7403334 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -1335,6 +1335,7 @@ - GRAPH_RENDER_CYLBOARD - GRAPH_RENDER_PLAYER - GRAPH_EXTRA_FORCE_3D +- GRAPH_EXTRA_ROTATE_HELD - GRAPH_NODE_TYPE_FUNCTIONAL - GRAPH_NODE_TYPE_400 - GRAPH_NODE_TYPE_ROOT diff --git a/src/engine/graph_node.h b/src/engine/graph_node.h index c044fa548..7e61e9f4c 100644 --- a/src/engine/graph_node.h +++ b/src/engine/graph_node.h @@ -20,6 +20,7 @@ // Extra, custom, flags #define GRAPH_EXTRA_FORCE_3D (1 << 0) +#define GRAPH_EXTRA_ROTATE_HELD (1 << 1) // Whether the node type has a function pointer of type GraphNodeFunc #define GRAPH_NODE_TYPE_FUNCTIONAL 0x100 diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index cfebccc00..c2a44de59 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -1628,6 +1628,7 @@ void geo_process_held_object(struct GraphNodeHeldObject *node) { Mat4 mat; Vec3f translation; Vec3f scalePrev; + Vec3s anglePrev; // Sanity check our stack index, If we above or equal to our stack size. Return to prevent OOB\. if ((gMatStackIndex + 1) >= MATRIX_STACK_SIZE) { LOG_ERROR("Preventing attempt to exceed the maximum size %i for our matrix stack with size of %i.", MATRIX_STACK_SIZE - 1, gMatStackIndex); return; } @@ -1648,19 +1649,29 @@ void geo_process_held_object(struct GraphNodeHeldObject *node) { if (gGlobalTimer == node->objNode->header.gfx.prevScaleTimestamp + 1) { vec3f_copy(scalePrev, node->objNode->header.gfx.prevScale); + vec3s_copy(anglePrev, node->objNode->header.gfx.prevAngle); } else { vec3f_copy(scalePrev, node->objNode->header.gfx.scale); + vec3s_copy(anglePrev, node->objNode->header.gfx.angle); } vec3f_copy(node->objNode->header.gfx.prevScale, node->objNode->header.gfx.scale); node->objNode->header.gfx.prevScaleTimestamp = gGlobalTimer; - mtxf_translate(mat, translation); + if (node->objNode->header.gfx.sharedChild->extraFlags & GRAPH_EXTRA_ROTATE_HELD) { + vec3s_copy(node->objNode->header.gfx.prevAngle, node->objNode->header.gfx.angle); + mtxf_rotate_zxy_and_translate(mat, translation, node->objNode->header.gfx.angle); + } else { + mtxf_translate(mat, translation); + } mtxf_copy(gMatStack[gMatStackIndex + 1], *gCurGraphNodeObject->throwMatrix); gMatStack[gMatStackIndex + 1][3][0] = gMatStack[gMatStackIndex][3][0]; gMatStack[gMatStackIndex + 1][3][1] = gMatStack[gMatStackIndex][3][1]; gMatStack[gMatStackIndex + 1][3][2] = gMatStack[gMatStackIndex][3][2]; mtxf_mul(gMatStack[gMatStackIndex + 1], mat, gMatStack[gMatStackIndex + 1]); mtxf_scale_vec3f(gMatStack[gMatStackIndex + 1], gMatStack[gMatStackIndex + 1], node->objNode->header.gfx.scale); + if (node->objNode->header.gfx.sharedChild->extraFlags & GRAPH_EXTRA_ROTATE_HELD) { + mtxf_rotate_zxy_and_translate(mat, translation, anglePrev); + } mtxf_copy(gMatStackPrev[gMatStackIndex + 1], (void *) gCurGraphNodeObject->throwMatrixPrev); gMatStackPrev[gMatStackIndex + 1][3][0] = gMatStackPrev[gMatStackIndex][3][0]; gMatStackPrev[gMatStackIndex + 1][3][1] = gMatStackPrev[gMatStackIndex][3][1]; @@ -2003,4 +2014,4 @@ void geo_process_root(struct GraphNodeRoot *node, Vp *b, Vp *c, s32 clearColor) gCurGraphNodeRoot = NULL; } -} \ No newline at end of file +} diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index f4ebbea66..6966f02fe 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -1544,6 +1544,7 @@ char gSmluaConstants[] = "" "GRAPH_RENDER_CYLBOARD=(1 << 6)\n" "GRAPH_RENDER_PLAYER=(1 << 7)\n" "GRAPH_EXTRA_FORCE_3D=(1 << 0)\n" +"GRAPH_EXTRA_ROTATE_HELD=(1 << 1)\n" "GRAPH_NODE_TYPE_FUNCTIONAL=0x100\n" "GRAPH_NODE_TYPE_400=0x400\n" "GRAPH_NODE_TYPE_ROOT=0x001\n"