Struct MapFollowSmoother
Critically damped smoothing state for a map center (X/Y in whatever linear unit the caller feeds it, normally mercator) and, optionally, its rotation.
public struct MapFollowSmoother
- Inherited Members
Remarks
A mutable struct: the owning component holds one as a plain field and calls Step(double, double, double, double, double, bool) once per frame, no allocation. Reset(double, double, double) jumps straight to a value with zero velocity, for the frame a follow target changes and the view should snap rather than swoop from wherever it was.
Properties
RotationDeg
Current smoothed rotation in degrees, normalized to [0, 360).
public double RotationDeg { get; }
Property Value
X
Current smoothed X.
public double X { get; }
Property Value
Y
Current smoothed Y.
public double Y { get; }
Property Value
Methods
Reset(double, double, double)
Jumps straight to a value with zero velocity.
public void Reset(double x, double y, double rotationDeg)
Parameters
ResetPosition(double, double)
Jumps the X/Y channels to a value with zero velocity, leaving rotation untouched.
public void ResetPosition(double x, double y)
Parameters
ResetRotation(double)
Jumps the rotation channel to a value with zero velocity, leaving X/Y untouched.
public void ResetRotation(double rotationDeg)
Parameters
rotationDegdoubleRotation in degrees to snap to.
Step(double, double, double, double, double, bool)
Advances one tick toward the given target.
public void Step(double targetX, double targetY, double targetRotationDeg, double smoothSeconds, double deltaSeconds, bool smoothRotation)
Parameters
targetXdoubleTarget X.
targetYdoubleTarget Y.
targetRotationDegdoubleTarget rotation in degrees.
smoothSecondsdoubleSeconds to settle. Zero, negative, or NaN snaps immediately.
deltaSecondsdoubleElapsed time this tick, in seconds. Non-positive is a no-op: nothing elapsed, nothing moves.
smoothRotationboolWhether rotation moves this tick. False leaves RotationDeg and its velocity untouched, other than the snap a non-positive
smoothSecondsstill applies to X/Y.