signApply
Definition
-- @/lua/common/mathlib.lua:1141
-- returns sign(s) * abs(v)
function signApply(s, v)
local absv = abs(v)
return max(min((s * 1e200) * 1e200, absv), -absv)
end
Callers
@/lua/vehicle/hydros.lua
virtualWheelVel = virtualWheelVel + dt * (virtualWheelExtTorque - torque) / virtualWheelI
virtualWheelVel = signApply(virtualWheelVel, max(0, abs(virtualWheelVel) - virtualFriction))
virtualWheelAngle = clamp(virtualWheelAngle + dt * virtualWheelVel, -1, 1)
local normResult = prev[1] + (normForce - prev2) * (nxt[1] - (prev and prev[1] or 0)) / (nxt[2] - prev2)
return signApply(force, normResult * FFmax)
end
if f.offsetDiff ~= 0 and not(k == "steering_input" and FFBID >= 0 and playerInfo.anyPlayerSeated) then
offset = offset + signApply(f.offsetDiff, min(abs(f.offsetDiff), f.maxRate * dt))
offset = min(max(offset + eval, f.inLimit), f.outLimit) - eval
else
offset = signApply(offset, max(0, abs(offset) - f.minRate * dt))
end
if absStress > h.forceLimit then
inputFlex[h.inputSource].offsetDiff = inputFlex[h.inputSource].offsetDiff + signApply(stress, absStress - h.forceLimit) / (v.data.beams[h.bcid].beamSpring * min(h.multOut, h.multIn))
end
@/lua/vehicle/sounds.lua
else
snd.noiseTrail = signApply(snd.noiseTrail, snd.noiseFactor)
end