Add control over spring solver step

This commit is contained in:
aaron 2023-08-26 14:59:19 +01:00
parent 5ab76a434e
commit 38f8e8d9c5
2 changed files with 39 additions and 29 deletions

View file

@ -20,6 +20,31 @@ local flags = require(script.flags)
export type Source<T> = source.Source<T>
local function step(dt: number)
if game then
debug.profilebegin("VIDE STEP")
debug.profilebegin("VIDE SPRING")
end
update_springs(dt)
if game then
debug.profileend()
debug.profilebegin("VIDE GARBAGE CLEANUP")
end
clean_garbage()
if game then
debug.profileend()
debug.profileend()
end
end
local stepped = game and game:GetService("RunService").Heartbeat:Connect(function(dt: number)
task.defer(step, dt)
end)
local vide = {
-- core
create = create,
@ -52,24 +77,11 @@ local vide = {
-- runtime
step = function(dt: number)
if game then
debug.profilebegin("VIDE STEP")
debug.profilebegin("VIDE SPRING")
end
update_springs(dt)
if game then
debug.profileend()
debug.profilebegin("VIDE GARBAGE CLEANUP")
end
clean_garbage()
if game then
debug.profileend()
debug.profileend()
if stepped then
stepped:Disconnect()
stepped = nil
end
step(dt)
end
}
@ -97,10 +109,4 @@ do
})
end
if game then
game:GetService("RunService").Heartbeat:Connect(function(dt: number)
task.defer(vide.step, dt)
end)
end
return vide