#include <SpringMath.h>
|
| static constexpr float | SmoothingTimeToHalfLife (float SmoothingTime) |
| |
| static constexpr float | HalfLifeToSmoothingTime (float HalfLife) |
| |
| static constexpr float | SmoothingTimeToStrength (float SmoothingTime) |
| |
| static constexpr float | StrengthToSmoothingTime (float Strength) |
| |
| template<typename T > |
| static void | CriticalSpringDamper (T &InOutX, T &InOutV, T TargetX, float SmoothingTime, float DeltaTime) |
| |
| static void | CriticalSpringDamperAngle (float &InOutAngleRadians, float &InOutAngularVelocityRadians, float TargetAngleRadians, float SmoothingTime, float DeltaTime) |
| |
| static void | CriticalSpringDamperQuat (FQuat &InOutRotation, FVector &InOutAngularVelocityRadians, const FQuat &TargetRotation, float SmoothingTime, float DeltaTime) |
| |
| template<typename TFloat > |
| static void | VelocitySpringDamperF (TFloat &InOutX, TFloat &InOutV, TFloat &InOutXi, TFloat TargetX, TFloat MaxSpeed, float SmoothingTime, float DeltaTime) |
| |
| template<typename TVector > |
| static void | VelocitySpringDamper (TVector &InOutX, TVector &InOutV, TVector &InOutXi, TVector TargetX, float MaxSpeed, float SmoothingTime, float DeltaTime) |
| |
| template<typename TVector > |
| static void | SpringCharacterUpdate (TVector &InOutPosition, TVector &InOutVelocity, TVector &InOutAcceleration, const TVector &TargetVelocity, float SmoothingTime, float DeltaTime, float VDeadzone=1e-2f, float ADeadzone=1e-4f) |
| |
| template<typename TVector > |
| static void | SpringCharacterPredict (TArrayView< TVector > OutPredictedPositions, TArrayView< TVector > OutPredictedVelocities, TArrayView< TVector > OutPredictedAccelerations, const TVector &CurrentPosition, const TVector &CurrentVelocity, const TVector &CurrentAcceleration, const TVector &TargetVelocity, float SmoothingTime, float SecondsPerPredictionStep, float VDeadzone=1e-2f, float ADeadzone=1e-4f) |
| |
| template<typename TVector > |
| static void | VelocitySpringCharacterUpdate (TVector &InOutPosition, TVector &InOutVelocity, TVector &InOutVelocityIntermediate, TVector &InOutAcceleration, TVector TargetVelocity, float SmoothingTime, float MaxAcceleration, float DeltaTime, float VDeadzone=1e-2f, float ADeadzone=1e-4f) |
| |
| template<typename TVector > |
| static void | VelocitySpringCharacterPredict (TArrayView< TVector > OutPredictedPositions, TArrayView< TVector > OutPredictedVelocities, TArrayView< TVector > OutPredictedIntermediateVelocities, TArrayView< TVector > OutPredictedAccelerations, const TVector &CurrentPosition, const TVector &CurrentVelocity, const TVector &CurrentIntermediateVelocity, const TVector &CurrentAcceleration, const TVector &TargetVelocity, float SmoothingTime, float MaxAcceleration, float SecondsPerPredictionStep, float VDeadzone=1e-2f, float ADeadzone=1e-4f) |
| |
| static void | CriticalSpringDamperQuatPredict (TArrayView< FQuat > OutPredictedRotations, TArrayView< FVector > OutPredictedAngularVelocities, int32 PredictCount, const FQuat &CurrentRotation, const FVector &CurrentAngularVelocity, const FQuat &TargetRotation, float SmoothingTime, float SecondsPerPredictionStep) |
| |
| static constexpr void | ExponentialSmoothingApproxQuat (FQuat &InOutRotation, const FQuat &InTargetRotation, const float InDeltaTime, const float InSmoothingTime) |
| |
| static constexpr void | ExponentialSmoothingApproxAngle (float &InOutAngleRadians, const float &InTargetAngleRadians, const float InDeltaTime, const float InSmoothingTime) |
| |
◆ CriticalSpringDamper()
| static void SpringMath::CriticalSpringDamper |
( |
T & |
InOutX, |
|
|
T & |
InOutV, |
|
|
T |
TargetX, |
|
|
float |
SmoothingTime, |
|
|
float |
DeltaTime |
|
) |
| |
|
inlinestatic |
Simplified version of FMath::CriticallyDampedSmoothing where v_goal is assumed to be 0. This interpolates the value InOutX towards TargetX with the motion of a critically damped spring. The velocity of InOutX is stored in InOutV.
- Template Parameters
-
- Parameters
-
| InOutX | The value to be damped |
| InOutV | The speed of the value to be damped |
| TargetX | The goal to damp towards |
| SmoothingTime | The smoothing time to use for the spring. Longer times lead to more damped behaviour. A time of 0 will snap InOutX to TargetX |
| DeltaTime | Timestep in seconds |
◆ CriticalSpringDamperAngle()
| static void SpringMath::CriticalSpringDamperAngle |
( |
float & |
InOutAngleRadians, |
|
|
float & |
InOutAngularVelocityRadians, |
|
|
float |
TargetAngleRadians, |
|
|
float |
SmoothingTime, |
|
|
float |
DeltaTime |
|
) |
| |
|
inlinestatic |
Specialized angle version of CriticalSpringDamper that handles angle wrapping.
- Parameters
-
| InOutAngleRadians | The value to be damped |
| InOutAngularVelocityRadians | The speed of the value to be damped |
| TargetAngleRadians | The goal to damp towards |
| SmoothingTime | The smoothing time to use for the spring. Longer times lead to more damped behaviour. A time of 0 will snap InOutAngleRadians to TargetAngleRadians |
| DeltaTime | Timestep in seconds |
◆ CriticalSpringDamperQuat()
Specialized quaternion version of CriticalSpringDamper, uses FVector for angular velocity
- Parameters
-
| InOutRotation | The value to be damped |
| InOutAngularVelocityRadians | The angular velocity of the rotation in radians |
| TargetRotation | The target rotation to damp towards |
| SmoothingTime | he smoothing time to use for the spring. Longer times lead to more damped behaviour. A time of 0 will snap InOutRotation to TargetRotation |
| DeltaTime | |
◆ CriticalSpringDamperQuatPredict()
Prediction of CriticalSpringDamperQuat
- Parameters
-
| OutPredictedRotations | ArrayView of output buffer to put the predicted rotations. ArrayView should be the same size as PredictCount |
| OutPredictedAngularVelocities | ArrayView of output buffer to put the predicted angular velocities. ArrayView should be the same size as PredictCount |
| PredictCount | How many points to predict. Must be greater than 0 |
| CurrentRotation | Initial rotation at t = 0 |
| CurrentAngularVelocity | Initial angular velocity at t = 0 |
| TargetRotation | The target rotation |
| SmoothingTime | The smoothing time |
| SecondsPerPredictionStep | How many seconds per prediction step |
◆ ExponentialSmoothingApproxAngle()
Specialized angle damper, similar to FMath::ExponentialSmoothingApprox but deals correctly with angle wrap-around. Smooths an angle using exponential damping towards a target.
- Parameters
-
| InOutAngleRadians | The angle to be smoothed |
| InTargetAngleRadians | The target to smooth towards |
| InDeltaTime | Time interval |
| InSmoothingTime | Timescale over which to smooth. Larger values result in more smoothed behaviour. Can be zero. |
◆ ExponentialSmoothingApproxQuat()
Specialized quaternion damper, similar to FMath::ExponentialSmoothingApprox but for quaternions. Smooths a value using exponential damping towards a target.
- Parameters
-
| InOutRotation | The value to be smoothed |
| InTargetRotation | The target to smooth towards |
| InDeltaTime | Time interval |
| InSmoothingTime | Timescale over which to smooth. Larger values result in more smoothed behaviour. Can be zero. |
◆ HalfLifeToSmoothingTime()
Convert a halflife to a smoothing time
- Parameters
-
| HalfLife | The half life of the spring. How long it takes the value to get halfway towards the target. |
- Returns
- The smoothing time of the spring in seconds. It is the time by which the output lags the input when critically damped, when the input is changing at a constant rate.
◆ SmoothingTimeToHalfLife()
Convert a smoothing time to a half life
- Parameters
-
| SmoothingTime | The smoothing time of the spring in seconds. It is the time by which the output lags the input when critically damped, when the input is changing at a constant rate. |
- Returns
- The half life of the spring. How long it takes the value to get halfway towards the target.
◆ SmoothingTimeToStrength()
Convert from smoothing time to spring strength.
- Parameters
-
| SmoothingTime | The smoothing time of the spring in seconds. It is the time by which the output lags the input when critically damped, when the input is changing at a constant rate. |
- Returns
- The spring strength. This corresponds to the undamped frequency of the spring in hz.
◆ SpringCharacterPredict()
| static void SpringMath::SpringCharacterPredict |
( |
TArrayView< TVector > |
OutPredictedPositions, |
|
|
TArrayView< TVector > |
OutPredictedVelocities, |
|
|
TArrayView< TVector > |
OutPredictedAccelerations, |
|
|
const TVector & |
CurrentPosition, |
|
|
const TVector & |
CurrentVelocity, |
|
|
const TVector & |
CurrentAcceleration, |
|
|
const TVector & |
TargetVelocity, |
|
|
float |
SmoothingTime, |
|
|
float |
SecondsPerPredictionStep, |
|
|
float |
VDeadzone = 1e-2f, |
|
|
float |
ADeadzone = 1e-4f |
|
) |
| |
|
inlinestatic |
Gives predicted positions, velocities and accelerations for SpringCharacterUpdate. Useful for generating a predicted trajectory given known initial start conditions.
- Template Parameters
-
| TVector | The type of vector to use (e.g. FVector2D, FVector4, FVector etc) |
- Parameters
-
| OutPredictedPositions | ArrayView of output buffer to put the predicted positions. ArrayView should be the same size as PredictCount |
| OutPredictedVelocities | ArrayView of output buffer to put the predicted velocities. ArrayView should be the same size as PredictCount |
| OutPredictedAccelerations | ArrayView of output buffer to put the predicted accelerations. ArrayView should be the same size as PredictCount |
| PredictCount | How many points to predict. Must be greater than 0 |
| CurrentPosition | The initial position of the character |
| CurrentVelocity | The initial velocity of the character |
| CurrentAcceleration | The initial acceleration of the character |
| TargetVelocity | The target velocity of the character |
| SmoothingTime | The smoothing time of the character. It takes roughly the smoothing time in order for the character to reach the target velocity. |
| SecondsPerPredictionStep | How much time in between each prediction step. |
| VDeadzone | Deadzone for velocity. Current velocity will snap to target velocity when within the deadzone |
| ADeadzone | Deadzone for acceleration. Acceleration will snap to zero when within the deadzone |
◆ SpringCharacterUpdate()
| static void SpringMath::SpringCharacterUpdate |
( |
TVector & |
InOutPosition, |
|
|
TVector & |
InOutVelocity, |
|
|
TVector & |
InOutAcceleration, |
|
|
const TVector & |
TargetVelocity, |
|
|
float |
SmoothingTime, |
|
|
float |
DeltaTime, |
|
|
float |
VDeadzone = 1e-2f, |
|
|
float |
ADeadzone = 1e-4f |
|
) |
| |
|
inlinestatic |
Update the position of a character given a target velocity using a simple damped spring
- Template Parameters
-
| TVector | The type of vector to use (e.g. FVector2D, FVector4, FVector etc) |
- Parameters
-
| InOutPosition | The position of the character |
| InOutVelocity | The velocity of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller. |
| InOutAcceleration | The acceleration of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller. |
| TargetVelocity | The target velocity of the character. |
| SmoothingTime | The time over which to smooth velocity. It takes roughly the smoothing time in order for the character to reach the target velocity. |
| DeltaTime | The delta time to tick the character |
| VDeadzone | Deadzone for velocity. Current velocity will snap to target velocity when within the deadzone |
| ADeadzone | Deadzone for acceleration. Acceleration will snap to zero when within the deadzone |
◆ StrengthToSmoothingTime()
Convert from spring strength to smoothing time.
- Parameters
-
| Strength | The spring strength. This corresponds to the undamped frequency of the spring in hz. |
- Returns
- The smoothing time of the spring in seconds. It is the time by which the output lags the input when critically damped, when the input is changing at a constant rate.
◆ VelocitySpringCharacterPredict()
| static void SpringMath::VelocitySpringCharacterPredict |
( |
TArrayView< TVector > |
OutPredictedPositions, |
|
|
TArrayView< TVector > |
OutPredictedVelocities, |
|
|
TArrayView< TVector > |
OutPredictedIntermediateVelocities, |
|
|
TArrayView< TVector > |
OutPredictedAccelerations, |
|
|
const TVector & |
CurrentPosition, |
|
|
const TVector & |
CurrentVelocity, |
|
|
const TVector & |
CurrentIntermediateVelocity, |
|
|
const TVector & |
CurrentAcceleration, |
|
|
const TVector & |
TargetVelocity, |
|
|
float |
SmoothingTime, |
|
|
float |
MaxAcceleration, |
|
|
float |
SecondsPerPredictionStep, |
|
|
float |
VDeadzone = 1e-2f, |
|
|
float |
ADeadzone = 1e-4f |
|
) |
| |
|
inlinestatic |
Gives predicted positions, velocities and accelerations for SpringCharacterUpdate. Useful for generating a predicted trajectory given known initial start conditions.
- Template Parameters
-
| TVector | The type of vector to use (e.g. FVector2D, FVector4, FVector etc) |
- Parameters
-
| OutPredictedPositions | ArrayView of output buffer to put the predicted positions. ArrayView should be the same size as PredictCount |
| OutPredictedVelocities | ArrayView of output buffer to put the predicted velocities. ArrayView should be the same size as PredictCount |
| OutPredictedIntermediateVelocities | ArrayView of output buffer to put the predicted intermediate velocities. ArrayView should be the same size as PredictCount |
| OutPredictedAccelerations | ArrayView of output buffer to put the predicted accelerations. ArrayView should be the same size as PredictCount |
| PredictCount | How many points to predict. Must be greater than 0 |
| CurrentPosition | The initial position of the character |
| CurrentVelocity | The initial velocity of the character |
| CurrentIntermediateVelocity | The initial intermediate velocity of the character |
| CurrentAcceleration | The initial acceleration of the character |
| TargetVelocity | The target velocity of the character |
| SmoothingTime | The smoothing time of the character. It takes roughly the smoothing time in order for the character to reach the target velocity. |
| MaxAcceleration | Puts a limit on the maximum acceleration that the intermediate velocity can do each frame. If MaxAccel is very large, the behaviour wil lbe the same as SpringCharacterUpdate |
| SecondsPerPredictionStep | How much time in between each prediction step. |
| VDeadzone | Deadzone for velocity. Current velocity will snap to target velocity when within the deadzone |
| ADeadzone | Deadzone for acceleration. Acceleration will snap to zero when within the deadzone |
◆ VelocitySpringCharacterUpdate()
| static void SpringMath::VelocitySpringCharacterUpdate |
( |
TVector & |
InOutPosition, |
|
|
TVector & |
InOutVelocity, |
|
|
TVector & |
InOutVelocityIntermediate, |
|
|
TVector & |
InOutAcceleration, |
|
|
TVector |
TargetVelocity, |
|
|
float |
SmoothingTime, |
|
|
float |
MaxAcceleration, |
|
|
float |
DeltaTime, |
|
|
float |
VDeadzone = 1e-2f, |
|
|
float |
ADeadzone = 1e-4f |
|
) |
| |
|
inlinestatic |
Update a position representing a character given a target velocity using a velocity spring. A velocity spring tracks an intermediate velocity which moves at a maximum acceleration linearly towards a target. This means unlike the "SpringCharacterUpdate", it will take longer to reach a target velocity that is further away from the current velocity.
- Template Parameters
-
| TVector | The type of vector to use (e.g. FVector2D, FVector4, FVector etc) |
- Parameters
-
| InOutPosition | The position of the character |
| InOutVelocity | The velocity of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller. |
| InOutVelocityIntermediate | The intermediate velocity of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller. |
| InOutAcceleration | The acceleration of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller. |
| TargetVelocity | The target velocity of the character. |
| SmoothingTime | The time over which to smooth velocity. It takes roughly the smoothing time in order for the character to reach the target velocity. |
| MaxAcceleration | Puts a limit on the maximum acceleration that the intermediate velocity can do each frame. If MaxAccel is very large, the behaviour wil lbe the same as SpringCharacterUpdate |
| DeltaTime | The delta time to tick the character |
| VDeadzone | Deadzone for velocity. Current velocity will snap to target velocity when within the deadzone |
| ADeadzone | Deadzone for acceleration. Acceleration will snap to zero when within the deadzone |
◆ VelocitySpringDamper()
| static void SpringMath::VelocitySpringDamper |
( |
TVector & |
InOutX, |
|
|
TVector & |
InOutV, |
|
|
TVector & |
InOutXi, |
|
|
TVector |
TargetX, |
|
|
float |
MaxSpeed, |
|
|
float |
SmoothingTime, |
|
|
float |
DeltaTime |
|
) |
| |
|
inlinestatic |
A velocity spring will damp towards a target that follows a fixed linear target velocity, allowing control of the interpolation speed while still giving a smoothed behaviour. A SmoothingTime of 0 will give a linear interpolation between X and TargetX
- Template Parameters
-
| TVector | The type of vector to use (e.g. FVector2D, FVector4, FVector etc) |
- Parameters
-
| InOutX | The value to be damped |
| InOutV | The velocity of the value to be damped |
| InOutXi | The intermediate target of the value to be damped |
| TargetX | The target value of X to damp towards |
| MaxSpeed | The max velocity to use for the intermediate target interpolation |
| SmoothingTime | The smoothing time to use while damping towards X. Higher values will give more smoothed behaviour. A value of 0 will give a linear interpolation of X to Target |
| DeltaTime | The timestep in seconds |
◆ VelocitySpringDamperF()
A velocity spring will damp towards a target that follows a fixed linear target velocity, allowing control of the interpolation speed while still giving a smoothed behavior. A SmoothingTime of 0 will give a linear interpolation between X and TargetX
- Parameters
-
| InOutX | The value to be damped |
| InOutV | The velocity of the value to be damped |
| InOutXi | The intermediate target of the value to be damped |
| TargetX | The target value of X to damp towards |
| MaxSpeed | The desired speed to achieve while damping towards X |
| SmoothingTime | The smoothing time to use while damping towards X. Higher values will give more smoothed behaviour. A value of 0 will give a linear interpolation of X to Target |
| DeltaTime | The timestep in seconds |
The documentation for this struct was generated from the following file: