From 9422c348360f2c44c5910d8fc9e9834e58ef4217 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Sat, 13 Dec 2025 23:20:08 -0500 Subject: [PATCH] Add behavior value for enabling GEO_RENDER_RANGE --- autogen/lua_definitions/structs.lua | 1 + docs/lua/structs.md | 1 + src/game/hardcoded.c | 1 + src/game/hardcoded.h | 1 + src/game/rendering_graph_node.c | 9 +++++---- src/pc/lua/smlua_cobject_autogen.c | 3 ++- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index cae4894d4..c145789d7 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -195,6 +195,7 @@ --- @field public RespawnShellBoxes integer --- @field public MultipleCapCollection integer --- @field public InfiniteRenderDistance integer +--- @field public ProcessLODs integer --- @field public CourtyardBoosRequirement integer --- @field public starsNeededForDialog StarsNeededForDialog --- @field public dialogs BehaviorDialogs diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 77a0e5f89..ee844a0df 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -336,6 +336,7 @@ | RespawnShellBoxes | `integer` | | | MultipleCapCollection | `integer` | | | InfiniteRenderDistance | `integer` | | +| ProcessLODs | `integer` | | | CourtyardBoosRequirement | `integer` | | | starsNeededForDialog | [StarsNeededForDialog](structs.md#StarsNeededForDialog) | read-only | | dialogs | [BehaviorDialogs](structs.md#BehaviorDialogs) | read-only | diff --git a/src/game/hardcoded.c b/src/game/hardcoded.c index 6ce8364d8..344a370ad 100644 --- a/src/game/hardcoded.c +++ b/src/game/hardcoded.c @@ -168,6 +168,7 @@ struct BehaviorValues gDefaultBehaviorValues = { .RespawnShellBoxes = TRUE, .MultipleCapCollection = FALSE, .InfiniteRenderDistance = TRUE, + .ProcessLODs = FALSE, .CourtyardBoosRequirement = 12, .starsNeededForDialog = { 1, 3, 8, 30, 50, 70 }, .dialogs = { diff --git a/src/game/hardcoded.h b/src/game/hardcoded.h index d0c6ebb23..bb597d2a0 100644 --- a/src/game/hardcoded.h +++ b/src/game/hardcoded.h @@ -265,6 +265,7 @@ struct BehaviorValues { u8 RespawnShellBoxes; u8 MultipleCapCollection; u8 InfiniteRenderDistance; + u8 ProcessLODs; s16 CourtyardBoosRequirement; struct StarsNeededForDialog starsNeededForDialog; struct BehaviorDialogs dialogs; diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index c6631b5db..fc3f44c5f 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -16,11 +16,12 @@ #include "pc/lua/smlua_hooks.h" #include "pc/utils/misc.h" #include "pc/debuglog.h" -#include "game/skybox.h" -#include "game/first_person_cam.h" +#include "skybox.h" +#include "first_person_cam.h" #include "course_table.h" #include "skybox.h" #include "mario.h" +#include "hardcoded.h" /** * This file contains the code that processes the scene graph for rendering. @@ -633,8 +634,8 @@ static void geo_process_perspective(struct GraphNodePerspective *node) { * range of this node. */ static void geo_process_level_of_detail(struct GraphNodeLevelOfDetail *node) { - // We assume modern hardware is powerful enough to draw the most detailed variant - s16 distanceFromCam = 0; + Mtx *mtx = gMatStackFixed[gMatStackIndex]; + s16 distanceFromCam = gBehaviorValues.ProcessLODs ? (s32) -mtx->m[3][2] : 0; // z-component of the translation column if (node->minDistance <= distanceFromCam && distanceFromCam < node->maxDistance) { if (node->node.children != 0) { diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index bf2dbc90c..5150d1d39 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -340,7 +340,7 @@ static struct LuaObjectField sBehaviorTrajectoriesFields[LUA_BEHAVIOR_TRAJECTORI { "UnagiTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, UnagiTrajectory), false, LOT_POINTER, 1, sizeof(Trajectory*) }, }; -#define LUA_BEHAVIOR_VALUES_FIELD_COUNT 32 +#define LUA_BEHAVIOR_VALUES_FIELD_COUNT 33 static struct LuaObjectField sBehaviorValuesFields[LUA_BEHAVIOR_VALUES_FIELD_COUNT] = { { "BowlingBallBob2Speed", LVT_F32, offsetof(struct BehaviorValues, BowlingBallBob2Speed), false, LOT_NONE, 1, sizeof(f32) }, { "BowlingBallBobSpeed", LVT_F32, offsetof(struct BehaviorValues, BowlingBallBobSpeed), false, LOT_NONE, 1, sizeof(f32) }, @@ -361,6 +361,7 @@ static struct LuaObjectField sBehaviorValuesFields[LUA_BEHAVIOR_VALUES_FIELD_COU { "MipsStar1Requirement", LVT_S16, offsetof(struct BehaviorValues, MipsStar1Requirement), false, LOT_NONE, 1, sizeof(s16) }, { "MipsStar2Requirement", LVT_S16, offsetof(struct BehaviorValues, MipsStar2Requirement), false, LOT_NONE, 1, sizeof(s16) }, { "MultipleCapCollection", LVT_U8, offsetof(struct BehaviorValues, MultipleCapCollection), false, LOT_NONE, 1, sizeof(u8) }, + { "ProcessLODs", LVT_U8, offsetof(struct BehaviorValues, ProcessLODs), false, LOT_NONE, 1, sizeof(u8) }, { "RacingPenguinBigHeight", LVT_F32, offsetof(struct BehaviorValues, RacingPenguinBigHeight), false, LOT_NONE, 1, sizeof(f32) }, { "RacingPenguinBigRadius", LVT_F32, offsetof(struct BehaviorValues, RacingPenguinBigRadius), false, LOT_NONE, 1, sizeof(f32) }, { "RacingPenguinHeight", LVT_F32, offsetof(struct BehaviorValues, RacingPenguinHeight), false, LOT_NONE, 1, sizeof(f32) },