From dc192064b1ff78bbae9f45f7d472449fc6d92387 Mon Sep 17 00:00:00 2001 From: ecker Date: Wed, 13 May 2026 22:34:30 -0500 Subject: [PATCH] fixed the nagging problem of GUI elements being in their final position for one frame as i'm not setting them to their initial states pre-first tick, disabled BARYCENTRIC_CALCULATE until I can be assed to fix the 'reconstructed geometry data lags behind' issue --- bin/data/entities/gui/hud/scripts/hud.lua | 38 ++++++++++--------- .../entities/gui/mainmenu/scripts/menu.lua | 24 ++++++++---- bin/data/entities/gui/pause/scripts/menu.lua | 24 ++++++++---- bin/data/shaders/common/macros.h | 2 +- .../src/ext/vulkan/rendermodes/deferred.cpp | 2 +- 5 files changed, 54 insertions(+), 36 deletions(-) diff --git a/bin/data/entities/gui/hud/scripts/hud.lua b/bin/data/entities/gui/hud/scripts/hud.lua index c283d31b..1e0d578d 100644 --- a/bin/data/entities/gui/hud/scripts/hud.lua +++ b/bin/data/entities/gui/hud/scripts/hud.lua @@ -109,13 +109,15 @@ end ) local fpsCounter = { frames = 0, time = 0, - freq = 0.1 + freq = 0.1, + enabled = false, } ---[[ -text:callHook( "gui:UpdateText.%UID%", { - string = "" -} ) -]] + +if fpsCounter["enabled"] then + text:callHook( "gui:UpdateText.%UID%", { + string = "" + } ) +end ent:bind( "tick", function(self) --[[ @@ -128,20 +130,20 @@ ent:bind( "tick", function(self) end ]] ---[[ - if fpsCounter["time"] > fpsCounter["freq"] then - -- update text - text:callHook( "gui:UpdateText.%UID%", { - string = tostring(math.floor(fpsCounter["frames"] / fpsCounter["time"])) - } ) + if fpsCounter["enabled"] then + if fpsCounter["time"] > fpsCounter["freq"] then + -- update text + text:callHook( "gui:UpdateText.%UID%", { + string = tostring(math.floor(fpsCounter["frames"] / fpsCounter["time"])) + } ) - fpsCounter["time"] = 0 - fpsCounter["frames"] = 0 - else - fpsCounter["frames"] = fpsCounter["frames"] + 1 - fpsCounter["time"] = fpsCounter["time"] + time.delta() + fpsCounter["time"] = 0 + fpsCounter["frames"] = 0 + else + fpsCounter["frames"] = fpsCounter["frames"] + 1 + fpsCounter["time"] = fpsCounter["time"] + time.delta() + end end -]] local controllerTransform = controller:getComponent("Transform") diff --git a/bin/data/entities/gui/mainmenu/scripts/menu.lua b/bin/data/entities/gui/mainmenu/scripts/menu.lua index fe2914fa..159371b5 100644 --- a/bin/data/entities/gui/mainmenu/scripts/menu.lua +++ b/bin/data/entities/gui/mainmenu/scripts/menu.lua @@ -137,9 +137,7 @@ local function handleSelectionIndex() end end -ent:bind( "tick", function(self) - handleSelectionIndex() - +local function updateVisuals(self, dt) local static = Static.get(self) if not static.alpha then static.alpha = 0 @@ -148,10 +146,13 @@ ent:bind( "tick", function(self) if static.alpha >= 1.0 then static.alpha = 1.0 else - static.alpha = static.alpha + time.delta() * 1.5 + static.alpha = static.alpha + dt * 1.5 + end + + if dt > 0 then + metadata.initialized = true end - metadata.initialized = true -- make background glow local glow = 1 + math.sin(1.25 * time.current()) * 0.125 @@ -207,7 +208,7 @@ ent:bind( "tick", function(self) if static.delta >= 1 then static.delta = 1 else - static.delta = static.delta + time.delta() * 1.5 + static.delta = static.delta + dt * 1.5 transform.position = Vector3f.lerp( static.from, static.to, static.delta ) end @@ -222,7 +223,7 @@ ent:bind( "tick", function(self) local transform = child:getComponent("Transform") local metadata = child:getComponent("GuiBehavior::Metadata") local speed = metadata.hovered and 0.25 or 0.0125 - static.time = (static.time or 0) + time.delta() * -speed + static.time = (static.time or 0) + dt * -speed transform.orientation = Quaternion.axisAngle( Vector3f(0, 0, 1), static.time ) end -- circle out @@ -233,7 +234,14 @@ ent:bind( "tick", function(self) local transform = child:getComponent("Transform") local metadata = child:getComponent("GuiBehavior::Metadata") local speed = metadata.hovered and 0.25 or 0.0125 - static.time = (static.time or 0) + time.delta() * speed + static.time = (static.time or 0) + dt * speed transform.orientation = Quaternion.axisAngle( Vector3f(0, 0, 1), static.time ) end +end + +updateVisuals(ent, 0) + +ent:bind( "tick", function(self) + handleSelectionIndex() + updateVisuals(self, time.delta()) end ) \ No newline at end of file diff --git a/bin/data/entities/gui/pause/scripts/menu.lua b/bin/data/entities/gui/pause/scripts/menu.lua index 1569e7eb..0ab65b3a 100644 --- a/bin/data/entities/gui/pause/scripts/menu.lua +++ b/bin/data/entities/gui/pause/scripts/menu.lua @@ -128,9 +128,8 @@ local function handleSelectionIndex() end end -ent:bind( "tick", function(self) - handleSelectionIndex() +local function updateVisuals(self, dt) local static = Static.get(self) if not static.alpha then static.alpha = 0 @@ -148,7 +147,7 @@ ent:bind( "tick", function(self) closing = false closed = true else - static.alpha = static.alpha - time.delta() + static.alpha = static.alpha - dt end elseif closed then timer:stop() @@ -175,11 +174,13 @@ ent:bind( "tick", function(self) if not metadata.initialized then static.alpha = 0 end - metadata.initialized = true; + if dt > 0 then + metadata.initialized = true; + end if static.alpha >= 1.0 then static.alpha = 1.0 else - static.alpha = static.alpha + time.delta() * 1.5 + static.alpha = static.alpha + dt * 1.5 end end @@ -230,7 +231,7 @@ ent:bind( "tick", function(self) if static.delta >= 1 then static.delta = 1 else - static.delta = static.delta + time.delta() * 1.5 + static.delta = static.delta + dt * 1.5 transform.position = Vector3f.lerp( static.from, static.to, static.delta ) end @@ -245,7 +246,7 @@ ent:bind( "tick", function(self) local transform = child:getComponent("Transform") local metadata = child:getComponent("GuiBehavior::Metadata") local speed = metadata.hovered and 0.25 or 0.0125 - static.time = (static.time or 0) + time.delta() * -speed + static.time = (static.time or 0) + dt * -speed transform.orientation = Quaternion.axisAngle( Vector3f(0, 0, 1), static.time ) end -- circle out @@ -256,7 +257,14 @@ ent:bind( "tick", function(self) local transform = child:getComponent("Transform") local metadata = child:getComponent("GuiBehavior::Metadata") local speed = metadata.hovered and 0.25 or 0.0125 - static.time = (static.time or 0) + time.delta() * speed + static.time = (static.time or 0) + dt * speed transform.orientation = Quaternion.axisAngle( Vector3f(0, 0, 1), static.time ) end +end + +updateVisuals(ent, 0) + +ent:bind( "tick", function(self) + handleSelectionIndex() + updateVisuals(self, time.delta()) end ) \ No newline at end of file diff --git a/bin/data/shaders/common/macros.h b/bin/data/shaders/common/macros.h index 72d3be51..7437dd37 100644 --- a/bin/data/shaders/common/macros.h +++ b/bin/data/shaders/common/macros.h @@ -76,7 +76,7 @@ #endif #if BARYCENTRIC #ifndef BARYCENTRIC_CALCULATE - #define BARYCENTRIC_CALCULATE 1 + #define BARYCENTRIC_CALCULATE 0 #endif #ifndef BUFFER_REFERENCE #define BUFFER_REFERENCE 1 diff --git a/engine/src/ext/vulkan/rendermodes/deferred.cpp b/engine/src/ext/vulkan/rendermodes/deferred.cpp index b37d40e6..b1aa1220 100644 --- a/engine/src/ext/vulkan/rendermodes/deferred.cpp +++ b/engine/src/ext/vulkan/rendermodes/deferred.cpp @@ -21,7 +21,7 @@ #if BARYCENTRIC // 0 keeps a buffer for barycentric coordinates, 1 will reconstruct in the deferred pass #ifndef BARYCENTRIC_CALCULATE - #define BARYCENTRIC_CALCULATE 1 + #define BARYCENTRIC_CALCULATE 0 #endif #endif