public static class CameraDampingHow a camera catches up with where it should be: exponentially, and at a rate that does not depend on the frame rate.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
A damping time is the time in which 99 % of the error is removed, and that number is the whole definition. A residual of 0.01 after dampTime gives a decay constant of ln(0.01) / dampTime, so the fraction of the remaining error taken in a step of dt is 1 − exp(ln(0.01) · dt / dampTime).
Why not a fixed lerp factor. Lerp(current, target, 0.1f) is what this is usually written as, and it means a different camera on a 30 Hz machine than on a 144 Hz one — the same "smoothing" that reads as heavy at 30 fps is nearly a snap at 144. The exponential form composes exactly: the residual after a second is 0.01 ^ (1 / dampTime) whether that second arrived as one step or as a hundred, because exp(a·dt) multiplied n times is exp(a·n·dt). That is not an approximation and DampingIsIndependentOfTheFrameRate holds it to a ten-thousandth.
The rotational form is exact too, which is less obvious. Slerp travels the geodesic at constant angular speed, so taking a fraction k of the way leaves exactly (1 − k) of the angle — the same multiplicative residual the linear case has. A Nlerp would not have that property, which is the reason this is the one place in the engine that pays for a slerp per frame rather than taking the cheaper path.
Methods (5)
public static float Fraction(float dampTime, float deltaTime)The fraction of the remaining error a step of takes.
public static float Approach(float current, float target, float dampTime, float deltaTime)Moves a scalar towards a target.
public static Vector3 Approach(Vector3 current, Vector3 target, Vector3 dampTime, float deltaTime)Moves a vector towards a target, one damping time per axis.
public static Quaternion Approach(Quaternion current, Quaternion target, float dampTime, float deltaTime)Turns a rotation towards a target.
public static Vector3 Decay(Vector3 error, Vector3 dampTime, float deltaTime)Shrinks an error towards zero — the same curve, written the way a correction wants it.
Used by (3)
- CameraDampingTestsVixen.Engine.Tests
- CameraFramingVixen.Engine
- VirtualCameraSystemVixen.Engine