From f354acac3dd10d40d056dabbe8273ee949e283f5 Mon Sep 17 00:00:00 2001 From: KiritoDev Date: Sat, 22 May 2021 11:56:16 -0500 Subject: [PATCH] Reimplemented LOD --- src/game/rendering_graph_node.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index d5bf5778..1479c5c3 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -267,8 +267,10 @@ 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; + // The fixed point Mtx type is defined as 16 longs, but it's actually 16 + // shorts for the integer parts followed by 16 shorts for the fraction parts + Mtx *mtx = gMatStackFixed[gMatStackIndex]; + s16 distanceFromCam = (s32) -mtx->m[3][2]; // z-component of the translation column if (node->minDistance <= distanceFromCam && distanceFromCam < node->maxDistance) { if (node->node.children != 0) {