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

This commit is contained in:
ecker 2026-05-13 22:34:30 -05:00
parent b3df72bfab
commit dc192064b1
5 changed files with 54 additions and 36 deletions

View File

@ -109,13 +109,15 @@ end )
local fpsCounter = { local fpsCounter = {
frames = 0, frames = 0,
time = 0, time = 0,
freq = 0.1 freq = 0.1,
enabled = false,
} }
--[[
text:callHook( "gui:UpdateText.%UID%", { if fpsCounter["enabled"] then
string = "" text:callHook( "gui:UpdateText.%UID%", {
} ) string = ""
]] } )
end
ent:bind( "tick", function(self) ent:bind( "tick", function(self)
--[[ --[[
@ -128,20 +130,20 @@ ent:bind( "tick", function(self)
end end
]] ]]
--[[ if fpsCounter["enabled"] then
if fpsCounter["time"] > fpsCounter["freq"] then if fpsCounter["time"] > fpsCounter["freq"] then
-- update text -- update text
text:callHook( "gui:UpdateText.%UID%", { text:callHook( "gui:UpdateText.%UID%", {
string = tostring(math.floor(fpsCounter["frames"] / fpsCounter["time"])) string = tostring(math.floor(fpsCounter["frames"] / fpsCounter["time"]))
} ) } )
fpsCounter["time"] = 0 fpsCounter["time"] = 0
fpsCounter["frames"] = 0 fpsCounter["frames"] = 0
else else
fpsCounter["frames"] = fpsCounter["frames"] + 1 fpsCounter["frames"] = fpsCounter["frames"] + 1
fpsCounter["time"] = fpsCounter["time"] + time.delta() fpsCounter["time"] = fpsCounter["time"] + time.delta()
end
end end
]]
local controllerTransform = controller:getComponent("Transform") local controllerTransform = controller:getComponent("Transform")

View File

@ -137,9 +137,7 @@ local function handleSelectionIndex()
end end
end end
ent:bind( "tick", function(self) local function updateVisuals(self, dt)
handleSelectionIndex()
local static = Static.get(self) local static = Static.get(self)
if not static.alpha then if not static.alpha then
static.alpha = 0 static.alpha = 0
@ -148,10 +146,13 @@ ent:bind( "tick", function(self)
if static.alpha >= 1.0 then if static.alpha >= 1.0 then
static.alpha = 1.0 static.alpha = 1.0
else 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 end
metadata.initialized = true
-- make background glow -- make background glow
local glow = 1 + math.sin(1.25 * time.current()) * 0.125 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 if static.delta >= 1 then
static.delta = 1 static.delta = 1
else 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 ) transform.position = Vector3f.lerp( static.from, static.to, static.delta )
end end
@ -222,7 +223,7 @@ ent:bind( "tick", function(self)
local transform = child:getComponent("Transform") local transform = child:getComponent("Transform")
local metadata = child:getComponent("GuiBehavior::Metadata") local metadata = child:getComponent("GuiBehavior::Metadata")
local speed = metadata.hovered and 0.25 or 0.0125 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 ) transform.orientation = Quaternion.axisAngle( Vector3f(0, 0, 1), static.time )
end end
-- circle out -- circle out
@ -233,7 +234,14 @@ ent:bind( "tick", function(self)
local transform = child:getComponent("Transform") local transform = child:getComponent("Transform")
local metadata = child:getComponent("GuiBehavior::Metadata") local metadata = child:getComponent("GuiBehavior::Metadata")
local speed = metadata.hovered and 0.25 or 0.0125 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 ) transform.orientation = Quaternion.axisAngle( Vector3f(0, 0, 1), static.time )
end end
end
updateVisuals(ent, 0)
ent:bind( "tick", function(self)
handleSelectionIndex()
updateVisuals(self, time.delta())
end ) end )

View File

@ -128,9 +128,8 @@ local function handleSelectionIndex()
end end
end end
ent:bind( "tick", function(self)
handleSelectionIndex()
local function updateVisuals(self, dt)
local static = Static.get(self) local static = Static.get(self)
if not static.alpha then if not static.alpha then
static.alpha = 0 static.alpha = 0
@ -148,7 +147,7 @@ ent:bind( "tick", function(self)
closing = false closing = false
closed = true closed = true
else else
static.alpha = static.alpha - time.delta() static.alpha = static.alpha - dt
end end
elseif closed then elseif closed then
timer:stop() timer:stop()
@ -175,11 +174,13 @@ ent:bind( "tick", function(self)
if not metadata.initialized then if not metadata.initialized then
static.alpha = 0 static.alpha = 0
end end
metadata.initialized = true; if dt > 0 then
metadata.initialized = true;
end
if static.alpha >= 1.0 then if static.alpha >= 1.0 then
static.alpha = 1.0 static.alpha = 1.0
else else
static.alpha = static.alpha + time.delta() * 1.5 static.alpha = static.alpha + dt * 1.5
end end
end end
@ -230,7 +231,7 @@ ent:bind( "tick", function(self)
if static.delta >= 1 then if static.delta >= 1 then
static.delta = 1 static.delta = 1
else 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 ) transform.position = Vector3f.lerp( static.from, static.to, static.delta )
end end
@ -245,7 +246,7 @@ ent:bind( "tick", function(self)
local transform = child:getComponent("Transform") local transform = child:getComponent("Transform")
local metadata = child:getComponent("GuiBehavior::Metadata") local metadata = child:getComponent("GuiBehavior::Metadata")
local speed = metadata.hovered and 0.25 or 0.0125 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 ) transform.orientation = Quaternion.axisAngle( Vector3f(0, 0, 1), static.time )
end end
-- circle out -- circle out
@ -256,7 +257,14 @@ ent:bind( "tick", function(self)
local transform = child:getComponent("Transform") local transform = child:getComponent("Transform")
local metadata = child:getComponent("GuiBehavior::Metadata") local metadata = child:getComponent("GuiBehavior::Metadata")
local speed = metadata.hovered and 0.25 or 0.0125 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 ) transform.orientation = Quaternion.axisAngle( Vector3f(0, 0, 1), static.time )
end end
end
updateVisuals(ent, 0)
ent:bind( "tick", function(self)
handleSelectionIndex()
updateVisuals(self, time.delta())
end ) end )

View File

@ -76,7 +76,7 @@
#endif #endif
#if BARYCENTRIC #if BARYCENTRIC
#ifndef BARYCENTRIC_CALCULATE #ifndef BARYCENTRIC_CALCULATE
#define BARYCENTRIC_CALCULATE 1 #define BARYCENTRIC_CALCULATE 0
#endif #endif
#ifndef BUFFER_REFERENCE #ifndef BUFFER_REFERENCE
#define BUFFER_REFERENCE 1 #define BUFFER_REFERENCE 1

View File

@ -21,7 +21,7 @@
#if BARYCENTRIC #if BARYCENTRIC
// 0 keeps a buffer for barycentric coordinates, 1 will reconstruct in the deferred pass // 0 keeps a buffer for barycentric coordinates, 1 will reconstruct in the deferred pass
#ifndef BARYCENTRIC_CALCULATE #ifndef BARYCENTRIC_CALCULATE
#define BARYCENTRIC_CALCULATE 1 #define BARYCENTRIC_CALCULATE 0
#endif #endif
#endif #endif