perf: batch springs

This commit is contained in:
ernisto 2025-04-11 17:31:51 -03:00
parent e115372e6b
commit 6ce4d25081

View file

@ -1,3 +1,4 @@
local batch = require "./batch"
local graph = require "./graph"
type Node<T> = graph.Node<T>
type SourceNode<T> = graph.SourceNode<T>
@ -263,6 +264,8 @@ local function step_springs(dt: number)
end
local function update_spring_sources()
graph.bump_update_id()
batch(function()
for data, output in springs do
local x0_123, x1_123, v_123,
x0_456, x1_456, v_456 =
@ -285,9 +288,9 @@ local function update_spring_sources()
output.cache = vec6_to_type[typeof(data.source_value)](x0_123, x0_456)
end
graph.bump_update_id()
update_descendants(output)
end
end)
end
return function()