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 = {
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")

View File

@ -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 )

View File

@ -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 )

View File

@ -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

View File

@ -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