mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 12:05:11 +00:00
allow mods to hide and move shadows for small objects (#257)
This commit is contained in:
parent
76038a20e4
commit
053d4902ed
5 changed files with 33 additions and 13 deletions
|
@ -555,6 +555,7 @@
|
|||
--- @field public animInfo AnimInfo
|
||||
--- @field public areaIndex integer
|
||||
--- @field public cameraToObject Vec3f
|
||||
--- @field public disableAutomaticShadowPos boolean
|
||||
--- @field public node GraphNode
|
||||
--- @field public pos Vec3f
|
||||
--- @field public prevAngle Vec3s
|
||||
|
@ -567,6 +568,8 @@
|
|||
--- @field public prevThrowMatrixTimestamp integer
|
||||
--- @field public prevTimestamp integer
|
||||
--- @field public scale Vec3f
|
||||
--- @field public shadowInvisible boolean
|
||||
--- @field public shadowPos Vec3f
|
||||
--- @field public sharedChild GraphNode
|
||||
--- @field public skipInViewCheck boolean
|
||||
--- @field public skipInterpolationTimestamp integer
|
||||
|
@ -756,6 +759,7 @@
|
|||
--- @field public unkC4 number
|
||||
--- @field public usedObj Object
|
||||
--- @field public vel Vec3f
|
||||
--- @field public visibleToEnemies integer
|
||||
--- @field public wall Surface
|
||||
--- @field public wallKickTimer integer
|
||||
--- @field public wallNormal Vec3f
|
||||
|
|
|
@ -818,6 +818,7 @@
|
|||
| animInfo | [AnimInfo](structs.md#AnimInfo) | read-only |
|
||||
| areaIndex | `integer` | |
|
||||
| cameraToObject | [Vec3f](structs.md#Vec3f) | read-only |
|
||||
| disableAutomaticShadowPos | `boolean` | |
|
||||
| node | [GraphNode](structs.md#GraphNode) | read-only |
|
||||
| pos | [Vec3f](structs.md#Vec3f) | read-only |
|
||||
| prevAngle | [Vec3s](structs.md#Vec3s) | read-only |
|
||||
|
@ -830,6 +831,8 @@
|
|||
| prevThrowMatrixTimestamp | `integer` | |
|
||||
| prevTimestamp | `integer` | |
|
||||
| scale | [Vec3f](structs.md#Vec3f) | read-only |
|
||||
| shadowInvisible | `boolean` | |
|
||||
| shadowPos | [Vec3f](structs.md#Vec3f) | read-only |
|
||||
| sharedChild | [GraphNode](structs.md#GraphNode) | |
|
||||
| skipInViewCheck | `boolean` | |
|
||||
| skipInterpolationTimestamp | `integer` | |
|
||||
|
@ -1082,6 +1085,7 @@
|
|||
| unkC4 | `number` | |
|
||||
| usedObj | [Object](structs.md#Object) | |
|
||||
| vel | [Vec3f](structs.md#Vec3f) | read-only |
|
||||
| visibleToEnemies | `integer` | |
|
||||
| wall | [Surface](structs.md#Surface) | |
|
||||
| wallKickTimer | `integer` | |
|
||||
| wallNormal | [Vec3f](structs.md#Vec3f) | read-only |
|
||||
|
|
|
@ -145,8 +145,11 @@ struct GraphNodeObject
|
|||
Vec3s prevAngle;
|
||||
Vec3f prevPos;
|
||||
u32 prevTimestamp;
|
||||
Vec3f shadowPos;
|
||||
Vec3f prevShadowPos;
|
||||
u32 prevShadowPosTimestamp;
|
||||
bool shadowInvisible;
|
||||
bool disableAutomaticShadowPos;
|
||||
/*0x2C*/ Vec3f scale;
|
||||
Vec3f prevScale;
|
||||
u32 prevScaleTimestamp;
|
||||
|
|
|
@ -973,7 +973,6 @@ void geo_set_animation_globals(struct AnimInfo *node, s32 hasAnimation) {
|
|||
*/
|
||||
static void geo_process_shadow(struct GraphNodeShadow *node) {
|
||||
Mat4 mtxf;
|
||||
Vec3f shadowPos;
|
||||
Vec3f shadowPosPrev;
|
||||
Vec3f animOffset;
|
||||
f32 shadowScale;
|
||||
|
@ -983,11 +982,13 @@ static void geo_process_shadow(struct GraphNodeShadow *node) {
|
|||
|
||||
if (gCurGraphNodeCamera != NULL && gCurGraphNodeObject != NULL) {
|
||||
if (gCurGraphNodeHeldObject != NULL) {
|
||||
get_pos_from_transform_mtx(shadowPos, gMatStack[gMatStackIndex],
|
||||
get_pos_from_transform_mtx(gCurGraphNodeObject->shadowPos, gMatStack[gMatStackIndex],
|
||||
*gCurGraphNodeCamera->matrixPtr);
|
||||
shadowScale = node->shadowScale;
|
||||
} else {
|
||||
vec3f_copy(shadowPos, gCurGraphNodeObject->pos);
|
||||
if (!gCurGraphNodeObject->disableAutomaticShadowPos) {
|
||||
vec3f_copy(gCurGraphNodeObject->shadowPos, gCurGraphNodeObject->pos);
|
||||
}
|
||||
shadowScale = node->shadowScale * gCurGraphNodeObject->scale[0];
|
||||
}
|
||||
|
||||
|
@ -1013,8 +1014,8 @@ static void geo_process_shadow(struct GraphNodeShadow *node) {
|
|||
f32 sinAng = sins(gCurGraphNodeObject->angle[1]);
|
||||
f32 cosAng = coss(gCurGraphNodeObject->angle[1]);
|
||||
|
||||
shadowPos[0] += animOffset[0] * cosAng + animOffset[2] * sinAng;
|
||||
shadowPos[2] += -animOffset[0] * sinAng + animOffset[2] * cosAng;
|
||||
gCurGraphNodeObject->shadowPos[0] += animOffset[0] * cosAng + animOffset[2] * sinAng;
|
||||
gCurGraphNodeObject->shadowPos[2] += -animOffset[0] * sinAng + animOffset[2] * cosAng;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1023,10 +1024,10 @@ static void geo_process_shadow(struct GraphNodeShadow *node) {
|
|||
if (gGlobalTimer == gCurGraphNodeHeldObject->prevShadowPosTimestamp + 1) {
|
||||
vec3f_copy(shadowPosPrev, gCurGraphNodeHeldObject->prevShadowPos);
|
||||
} else {
|
||||
vec3f_copy(shadowPosPrev, shadowPos);
|
||||
vec3f_copy(shadowPosPrev, gCurGraphNodeObject->shadowPos);
|
||||
}
|
||||
|
||||
vec3f_copy(gCurGraphNodeHeldObject->prevShadowPos, shadowPos);
|
||||
vec3f_copy(gCurGraphNodeHeldObject->prevShadowPos, gCurGraphNodeObject->shadowPos);
|
||||
gCurGraphNodeHeldObject->prevShadowPosTimestamp = gGlobalTimer;
|
||||
} else {
|
||||
if (gGlobalTimer == gCurGraphNodeObject->prevShadowPosTimestamp + 1 &&
|
||||
|
@ -1034,9 +1035,9 @@ static void geo_process_shadow(struct GraphNodeShadow *node) {
|
|||
gGlobalTimer != gLakituState.skipCameraInterpolationTimestamp) {
|
||||
vec3f_copy(shadowPosPrev, gCurGraphNodeObject->prevShadowPos);
|
||||
} else {
|
||||
vec3f_copy(shadowPosPrev, shadowPos);
|
||||
vec3f_copy(shadowPosPrev, gCurGraphNodeObject->shadowPos);
|
||||
}
|
||||
vec3f_copy(gCurGraphNodeObject->prevShadowPos, shadowPos);
|
||||
vec3f_copy(gCurGraphNodeObject->prevShadowPos, gCurGraphNodeObject->shadowPos);
|
||||
gCurGraphNodeObject->prevShadowPosTimestamp = gGlobalTimer;
|
||||
}
|
||||
|
||||
|
@ -1047,7 +1048,7 @@ static void geo_process_shadow(struct GraphNodeShadow *node) {
|
|||
interp->node = node;
|
||||
interp->shadowScale = shadowScale;
|
||||
interp->obj = gCurGraphNodeObject;
|
||||
vec3f_copy(interp->shadowPos, shadowPos);
|
||||
vec3f_copy(interp->shadowPos, gCurGraphNodeObject->shadowPos);
|
||||
vec3f_copy(interp->shadowPosPrev, shadowPosPrev);
|
||||
} else {
|
||||
gShadowInterpCurrent = NULL;
|
||||
|
@ -1061,8 +1062,12 @@ static void geo_process_shadow(struct GraphNodeShadow *node) {
|
|||
gShadowInterpCurrent->gfx = shadowListPrev;
|
||||
}
|
||||
|
||||
if (gCurGraphNodeObject->shadowInvisible) {
|
||||
shadowListPrev = NULL;
|
||||
}
|
||||
|
||||
if (shadowListPrev != NULL) {
|
||||
mtxf_translate(mtxf, shadowPos);
|
||||
mtxf_translate(mtxf, gCurGraphNodeObject->shadowPos);
|
||||
mtxf_mul(gMatStack[gMatStackIndex + 1], mtxf, *gCurGraphNodeCamera->matrixPtr);
|
||||
mtxf_translate(mtxf, shadowPosPrev);
|
||||
mtxf_mul(gMatStackPrev[gMatStackIndex + 1], mtxf, *gCurGraphNodeCamera->matrixPtrPrev);
|
||||
|
|
|
@ -636,13 +636,14 @@ static struct LuaObjectField sGraphNodeFields[LUA_GRAPH_NODE_FIELD_COUNT] = {
|
|||
{ "type", LVT_S16, offsetof(struct GraphNode, type), false, LOT_NONE },
|
||||
};
|
||||
|
||||
#define LUA_GRAPH_NODE_OBJECT_FIELD_COUNT 23
|
||||
#define LUA_GRAPH_NODE_OBJECT_FIELD_COUNT 26
|
||||
static struct LuaObjectField sGraphNodeObjectFields[LUA_GRAPH_NODE_OBJECT_FIELD_COUNT] = {
|
||||
{ "activeAreaIndex", LVT_S8, offsetof(struct GraphNodeObject, activeAreaIndex), false, LOT_NONE },
|
||||
{ "angle", LVT_COBJECT, offsetof(struct GraphNodeObject, angle), true, LOT_VEC3S },
|
||||
{ "animInfo", LVT_COBJECT, offsetof(struct GraphNodeObject, animInfo), true, LOT_ANIMINFO },
|
||||
{ "areaIndex", LVT_S8, offsetof(struct GraphNodeObject, areaIndex), false, LOT_NONE },
|
||||
{ "cameraToObject", LVT_COBJECT, offsetof(struct GraphNodeObject, cameraToObject), true, LOT_VEC3F },
|
||||
{ "disableAutomaticShadowPos", LVT_BOOL, offsetof(struct GraphNodeObject, disableAutomaticShadowPos), false, LOT_NONE },
|
||||
{ "node", LVT_COBJECT, offsetof(struct GraphNodeObject, node), true, LOT_GRAPHNODE },
|
||||
{ "pos", LVT_COBJECT, offsetof(struct GraphNodeObject, pos), true, LOT_VEC3F },
|
||||
{ "prevAngle", LVT_COBJECT, offsetof(struct GraphNodeObject, prevAngle), true, LOT_VEC3S },
|
||||
|
@ -655,6 +656,8 @@ static struct LuaObjectField sGraphNodeObjectFields[LUA_GRAPH_NODE_OBJECT_FIELD_
|
|||
{ "prevThrowMatrixTimestamp", LVT_U32, offsetof(struct GraphNodeObject, prevThrowMatrixTimestamp), false, LOT_NONE },
|
||||
{ "prevTimestamp", LVT_U32, offsetof(struct GraphNodeObject, prevTimestamp), false, LOT_NONE },
|
||||
{ "scale", LVT_COBJECT, offsetof(struct GraphNodeObject, scale), true, LOT_VEC3F },
|
||||
{ "shadowInvisible", LVT_BOOL, offsetof(struct GraphNodeObject, shadowInvisible), false, LOT_NONE },
|
||||
{ "shadowPos", LVT_COBJECT, offsetof(struct GraphNodeObject, shadowPos), true, LOT_VEC3F },
|
||||
{ "sharedChild", LVT_COBJECT_P, offsetof(struct GraphNodeObject, sharedChild), false, LOT_GRAPHNODE },
|
||||
{ "skipInViewCheck", LVT_BOOL, offsetof(struct GraphNodeObject, skipInViewCheck), false, LOT_NONE },
|
||||
{ "skipInterpolationTimestamp", LVT_U32, offsetof(struct GraphNodeObject, skipInterpolationTimestamp), false, LOT_NONE },
|
||||
|
@ -796,7 +799,7 @@ static struct LuaObjectField sMarioBodyStateFields[LUA_MARIO_BODY_STATE_FIELD_CO
|
|||
{ "wingFlutter", LVT_S8, offsetof(struct MarioBodyState, wingFlutter), false, LOT_NONE },
|
||||
};
|
||||
|
||||
#define LUA_MARIO_STATE_FIELD_COUNT 76
|
||||
#define LUA_MARIO_STATE_FIELD_COUNT 77
|
||||
static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = {
|
||||
{ "action", LVT_U32, offsetof(struct MarioState, action), false, LOT_NONE },
|
||||
{ "actionArg", LVT_U32, offsetof(struct MarioState, actionArg), false, LOT_NONE },
|
||||
|
@ -869,6 +872,7 @@ static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = {
|
|||
{ "unkC4", LVT_F32, offsetof(struct MarioState, unkC4), false, LOT_NONE },
|
||||
{ "usedObj", LVT_COBJECT_P, offsetof(struct MarioState, usedObj), false, LOT_OBJECT },
|
||||
{ "vel", LVT_COBJECT, offsetof(struct MarioState, vel), true, LOT_VEC3F },
|
||||
{ "visibleToEnemies", LVT_U8, offsetof(struct MarioState, visibleToEnemies), false, LOT_NONE },
|
||||
{ "wall", LVT_COBJECT_P, offsetof(struct MarioState, wall), false, LOT_SURFACE },
|
||||
{ "wallKickTimer", LVT_U8, offsetof(struct MarioState, wallKickTimer), false, LOT_NONE },
|
||||
{ "wallNormal", LVT_COBJECT, offsetof(struct MarioState, wallNormal), true, LOT_VEC3F },
|
||||
|
|
Loading…
Reference in a new issue