mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Add Ability to Rotate Held Objects (#953)
* Add files via upload * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Update rendering_graph_node.c --------- Co-authored-by: PeachyPeach <72323920+PeachyPeachSM64@users.noreply.github.com>
This commit is contained in:
parent
fc7a2f5557
commit
77a43c60a3
5 changed files with 19 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue