Add check for unstable spring parameters

This commit is contained in:
Aaron Smith 2023-09-20 11:39:44 +01:00
parent a543a24865
commit 835f4d429b
2 changed files with 8 additions and 3 deletions

View file

@ -161,6 +161,11 @@ local function spring<T>(source: () -> T, period: number?, damping_ratio: number
local c_c = 2*w_n
local c = z * c_c
-- todo: is there a solution to this other than upping step frequency?
if c > UPDATE_RATE*2 then -- solver will explode if this is true
throw("spring damping too high, consider reducing damping or increasing period")
end
local data: SpringData<T> = {
k = k,
c = c,