SteeringComponent Class
Component that manages the heading (orientation) of an entity. More...
Declaration
Public Constructors Index
| SteeringComponent ()=default | |
|
Default constructor. More... | |
| SteeringComponent (bool useInstantRotation, bool directionFromSteering=false) | |
|
Constructs a SteeringComponent with specified settings. More... | |
| SteeringComponent (const SteeringComponent &other) | |
|
Copy constructor. More... | |
| SteeringComponent (SteeringComponent &&) noexcept=default | |
Public Operators Index
| SteeringComponent & | operator= (const SteeringComponent &)=default |
| SteeringComponent & | operator= (SteeringComponent &&) noexcept=default |
Public Member Functions Index
| bool | isEnabled () const noexcept |
|
Checks whether this component is enabled. More... | |
| void | enable () noexcept |
|
Enables this component. More... | |
| void | disable () noexcept |
|
Disables this component. More... | |
| void | setHeading (helios::math::vec3f direction, float turnIntensity) |
| void | setDirectionFromSteering (const bool directionFromSteering) noexcept |
|
Sets whether the direction component should be updated from steering. More... | |
| bool | directionFromSteering () const noexcept |
|
Checks if direction synchronization is enabled. More... | |
| bool | useInstantRotation () const noexcept |
|
Returns whether instant rotation mode is enabled. More... | |
| void | setUseInstantRotation (const bool useInstantRotation) noexcept |
|
Sets the instant rotation mode. More... | |
| void | setSteeringIntent (helios::math::vec3f direction, float turnIntensity) |
|
Sets the heading direction and turn intensity from input. More... | |
| helios::math::vec3f | rotationAxis () const noexcept |
|
Returns the axis around which rotation occurs. More... | |
| void | setCurrentRotationSpeed (float speed) noexcept |
|
Sets the current rotation speed. More... | |
| float | currentRotationSpeed () const noexcept |
|
Returns the current rotation speed. More... | |
| float | rotationAngleDelta () const noexcept |
|
Returns the angular distance to the target rotation. More... | |
| float | currentRotationAngle () const noexcept |
|
Returns the current rotation angle. More... | |
| float | targetRotationAngle () const noexcept |
|
Returns the target rotation angle. More... | |
| void | setTargetRotationAngle (float angle) noexcept |
|
Sets the target rotation angle. More... | |
| void | setCurrentRotationAngle (float angle) noexcept |
|
Sets the current rotation angle. More... | |
| void | setRotationAngleDelta (float delta) noexcept |
|
Sets the angular distance to the target rotation. More... | |
| bool | stateChanged () const noexcept |
|
Checks if input is currently active. More... | |
| const helios::math::vec3f & | steeringInput () const noexcept |
|
Returns the current steering input direction. More... | |
| const helios::math::vec3f & | steeringIntent () const noexcept |
|
Returns the current steering intent (alias for steeringInput). More... | |
| float | rotationSpeed () const noexcept |
|
Returns the maximum rotation speed in degrees per second. More... | |
| float | rotationSpeedThreshold () const noexcept |
|
Returns the minimum rotation speed threshold. More... | |
| float | rotationDampening () const noexcept |
|
Returns the rotation dampening factor. More... | |
| void | setRotationSpeed (float value) noexcept |
|
Sets the maximum rotation speed in degrees per second. More... | |
| void | setRotationSpeedThreshold (float value) noexcept |
|
Sets the minimum rotation speed threshold. More... | |
| void | setRotationDampening (float value) noexcept |
|
Sets the rotation dampening factor. More... | |
| float | turnIntensity () const noexcept |
|
Returns the current turn intensity. More... | |
| void | resetToDefaults () noexcept |
|
Resets all physics parameters to their default values. More... | |
Protected Member Attributes Index
| float | rotationSpeed_ = DEFAULT_ROTATION_SPEED |
|
Maximum rotation speed in degrees per second. More... | |
| float | rotationSpeedThreshold_ = DEFAULT_ROTATION_SPEED_THRESHOLD |
|
Minimum rotation speed before rotation stops completely. More... | |
| float | rotationDampening_ = DEFAULT_ROTATION_DAMPENING |
|
Exponential decay factor for rotation when input stops. More... | |
| float | currentRotationAngle_ = 0 |
|
Current rotation angle in degrees. More... | |
| float | targetRotationAngle_ = 0 |
|
Target rotation angle derived from input direction. More... | |
| float | rotationAngleDelta_ = 0 |
|
Shortest angular distance to target rotation. More... | |
| float | currentRotationSpeed_ = 0.0f |
|
Current rotation speed after applying input and dampening. More... | |
| bool | stateChanged_ = true |
|
Indicates whether input is currently being received. More... | |
| float | turnIntensity_ = 0.0f |
|
Intensity of the turn input, typically from 0.0 to 1.0. More... | |
| helios::math::vec3f | steeringInput_ |
|
Current steering input as 2D direction vector. More... | |
| helios::math::vec3f | rotationAxis_ = helios::math::Z_AXISf |
|
The axis around which rotation occurs. More... | |
| bool | useInstantRotation_ = false |
|
Flag for instant rotation mode. More... | |
| bool | directionFromSteering_ = false |
|
Flag indicating if the direction component should be updated from steering. More... | |
| bool | isEnabled_ = true |
|
Whether this component is enabled. More... | |
Protected Static Attributes Index
| static constexpr float | DEFAULT_ROTATION_SPEED = 560.0f |
|
Default maximum rotation speed in degrees per second. More... | |
| static constexpr float | DEFAULT_ROTATION_SPEED_THRESHOLD = 0.1f |
|
Default minimum rotation speed before rotation stops completely. More... | |
| static constexpr float | DEFAULT_ROTATION_DAMPENING = 0.0001f |
|
Default exponential decay factor for rotation when input stops. More... | |
Description
Component that manages the heading (orientation) of an entity.
This component handles the rotational physics of an entity, including turning towards a target direction, rotation speed limits, and dampening. It maintains the current and target rotation angles and is used by the SteeringSystem to update the entity's orientation.
Definition at line 35 of file SteeringComponent.ixx.
Public Constructors
SteeringComponent()
| default |
Default constructor.
Definition at line 163 of file SteeringComponent.ixx.
Referenced by operator=, operator=, SteeringComponent and SteeringComponent.
SteeringComponent()
| inline explicit |
Constructs a SteeringComponent with specified settings.
- Parameters
-
useInstantRotation If true, rotation snaps instantly to target.
directionFromSteering If true, synchronizes DirectionComponent with steering.
Definition at line 171 of file SteeringComponent.ixx.
References directionFromSteering, directionFromSteering_, useInstantRotation and useInstantRotation_.
SteeringComponent()
| inline |
Copy constructor.
- Parameters
-
other The component to copy from.
Definition at line 179 of file SteeringComponent.ixx.
References directionFromSteering_, rotationAxis_, rotationDampening_, rotationSpeed_, rotationSpeedThreshold_, SteeringComponent and useInstantRotation_.
SteeringComponent()
| noexcept default |
Definition at line 188 of file SteeringComponent.ixx.
Reference SteeringComponent.
Public Operators
operator=()
| default |
Definition at line 187 of file SteeringComponent.ixx.
Reference SteeringComponent.
operator=()
| noexcept default |
Definition at line 189 of file SteeringComponent.ixx.
Reference SteeringComponent.
Public Member Functions
currentRotationAngle()
| inline nodiscard noexcept |
Returns the current rotation angle.
- Returns
The current rotation angle in degrees.
Definition at line 306 of file SteeringComponent.ixx.
Reference currentRotationAngle_.
currentRotationSpeed()
| inline nodiscard noexcept |
Returns the current rotation speed.
- Returns
The current rotation speed.
Definition at line 288 of file SteeringComponent.ixx.
Reference currentRotationSpeed_.
directionFromSteering()
| inline noexcept |
Checks if direction synchronization is enabled.
- Returns
True if DirectionComponent is updated from steering, false otherwise.
Definition at line 212 of file SteeringComponent.ixx.
Reference directionFromSteering_.
Referenced by setDirectionFromSteering and SteeringComponent.
disable()
| inline noexcept |
Disables this component.
Definition at line 156 of file SteeringComponent.ixx.
Reference isEnabled_.
enable()
| inline noexcept |
isEnabled()
| inline nodiscard noexcept |
Checks whether this component is enabled.
- Returns
True if enabled, false otherwise.
Definition at line 142 of file SteeringComponent.ixx.
Reference isEnabled_.
resetToDefaults()
| inline noexcept |
Resets all physics parameters to their default values.
Definition at line 437 of file SteeringComponent.ixx.
References DEFAULT_ROTATION_DAMPENING, DEFAULT_ROTATION_SPEED, DEFAULT_ROTATION_SPEED_THRESHOLD, rotationDampening_, rotationSpeed_ and rotationSpeedThreshold_.
rotationAngleDelta()
| inline nodiscard noexcept |
Returns the angular distance to the target rotation.
- Returns
The angle delta in degrees.
Definition at line 297 of file SteeringComponent.ixx.
Reference rotationAngleDelta_.
rotationAxis()
| inline nodiscard noexcept |
Returns the axis around which rotation occurs.
For 2D gameplay on the XY plane, this is typically the Z-axis.
- Returns
The rotation axis as a unit vector.
Definition at line 270 of file SteeringComponent.ixx.
Reference rotationAxis_.
rotationDampening()
| inline nodiscard noexcept |
Returns the rotation dampening factor.
- Returns
Exponential decay factor for rotation.
Definition at line 392 of file SteeringComponent.ixx.
Reference rotationDampening_.
rotationSpeed()
| inline nodiscard noexcept |
Returns the maximum rotation speed in degrees per second.
- Returns
Maximum rotation speed value.
Definition at line 378 of file SteeringComponent.ixx.
Reference rotationSpeed_.
rotationSpeedThreshold()
| inline nodiscard noexcept |
Returns the minimum rotation speed threshold.
- Returns
Rotation speed threshold below which rotation stops.
Definition at line 385 of file SteeringComponent.ixx.
Reference rotationSpeedThreshold_.
setCurrentRotationAngle()
| inline noexcept |
Sets the current rotation angle.
- Parameters
-
angle The new rotation angle in degrees.
Definition at line 333 of file SteeringComponent.ixx.
Reference currentRotationAngle_.
setCurrentRotationSpeed()
| inline noexcept |
Sets the current rotation speed.
- Parameters
-
speed The new rotation speed.
Definition at line 279 of file SteeringComponent.ixx.
Reference currentRotationSpeed_.
setDirectionFromSteering()
| inline noexcept |
Sets whether the direction component should be updated from steering.
- Parameters
-
directionFromSteering True to enable synchronization, false to disable.
Definition at line 203 of file SteeringComponent.ixx.
References directionFromSteering and directionFromSteering_.
setHeading()
| inline |
- Deprecated
-
Use setSteeringIntent instead.
Definition at line 194 of file SteeringComponent.ixx.
References setHeading, setSteeringIntent and turnIntensity.
Referenced by setHeading.
setRotationAngleDelta()
| inline noexcept |
Sets the angular distance to the target rotation.
- Parameters
-
delta The new angle delta in degrees.
Definition at line 342 of file SteeringComponent.ixx.
Reference rotationAngleDelta_.
setRotationDampening()
| inline noexcept |
Sets the rotation dampening factor.
- Parameters
-
value New dampening factor (exponential decay).
Definition at line 417 of file SteeringComponent.ixx.
Reference rotationDampening_.
setRotationSpeed()
| inline noexcept |
Sets the maximum rotation speed in degrees per second.
- Parameters
-
value New rotation speed value.
Definition at line 399 of file SteeringComponent.ixx.
Reference rotationSpeed_.
setRotationSpeedThreshold()
| inline noexcept |
Sets the minimum rotation speed threshold.
- Parameters
-
value New threshold value.
Definition at line 408 of file SteeringComponent.ixx.
Reference rotationSpeedThreshold_.
setSteeringIntent()
| inline |
Sets the heading direction and turn intensity from input.
Updates the heading input vector and turn intensity. If the turn intensity is below the epsilon threshold, input is deactivated and the heading is reset to zero.
- Parameters
-
direction Normalized direction vector representing the desired heading.
turnIntensity Magnitude of the input (0.0 to 1.0).
- Precondition
direction must be a normalized vector (length ~= 1.0).
Definition at line 247 of file SteeringComponent.ixx.
References helios::math::EPSILON_LENGTH, helios::math::vec3< T >::isNormalized, stateChanged_, steeringInput_, turnIntensity and turnIntensity_.
Referenced by setHeading.
setTargetRotationAngle()
| inline noexcept |
Sets the target rotation angle.
- Parameters
-
angle The new target rotation angle in degrees.
Definition at line 324 of file SteeringComponent.ixx.
Reference targetRotationAngle_.
setUseInstantRotation()
| inline noexcept |
Sets the instant rotation mode.
- Parameters
-
useInstantRotation True to snap instantly to target rotation, false for interpolation.
Definition at line 230 of file SteeringComponent.ixx.
References useInstantRotation and useInstantRotation_.
stateChanged()
| inline nodiscard noexcept |
Checks if input is currently active.
- Returns
True if input is active, false otherwise.
Definition at line 351 of file SteeringComponent.ixx.
Reference stateChanged_.
steeringInput()
| inline nodiscard noexcept |
Returns the current steering input direction.
- Returns
Const reference to the 2D steering input vector.
Definition at line 360 of file SteeringComponent.ixx.
Reference steeringInput_.
steeringIntent()
| inline nodiscard noexcept |
Returns the current steering intent (alias for steeringInput).
- Returns
Const reference to the steering input vector.
Definition at line 369 of file SteeringComponent.ixx.
Reference steeringInput_.
targetRotationAngle()
| inline nodiscard noexcept |
Returns the target rotation angle.
- Returns
The target rotation angle in degrees.
Definition at line 315 of file SteeringComponent.ixx.
Reference targetRotationAngle_.
turnIntensity()
| inline nodiscard noexcept |
Returns the current turn intensity.
- Returns
Turn intensity value, typically from 0.0 to 1.0.
Definition at line 426 of file SteeringComponent.ixx.
Reference turnIntensity_.
Referenced by setHeading and setSteeringIntent.
useInstantRotation()
| inline nodiscard noexcept |
Returns whether instant rotation mode is enabled.
- Returns
True if rotation snaps instantly, false for smooth interpolation.
Definition at line 221 of file SteeringComponent.ixx.
Reference useInstantRotation_.
Referenced by setUseInstantRotation and SteeringComponent.
Protected Member Attributes
currentRotationAngle_
| protected |
Current rotation angle in degrees.
Definition at line 72 of file SteeringComponent.ixx.
Referenced by currentRotationAngle and setCurrentRotationAngle.
currentRotationSpeed_
| protected |
Current rotation speed after applying input and dampening.
Definition at line 87 of file SteeringComponent.ixx.
Referenced by currentRotationSpeed and setCurrentRotationSpeed.
directionFromSteering_
| protected |
Flag indicating if the direction component should be updated from steering.
If true, the DirectionComponent of the entity will be synchronized with the steering input direction.
Definition at line 128 of file SteeringComponent.ixx.
Referenced by directionFromSteering, setDirectionFromSteering, SteeringComponent and SteeringComponent.
isEnabled_
| protected |
Whether this component is enabled.
Definition at line 133 of file SteeringComponent.ixx.
rotationAngleDelta_
| protected |
Shortest angular distance to target rotation.
Definition at line 82 of file SteeringComponent.ixx.
Referenced by rotationAngleDelta and setRotationAngleDelta.
rotationAxis_
| protected |
The axis around which rotation occurs.
Defaults to Z-axis for 2D top-down rotation.
Definition at line 112 of file SteeringComponent.ixx.
Referenced by rotationAxis and SteeringComponent.
rotationDampening_
| protected |
Exponential decay factor for rotation when input stops.
Definition at line 67 of file SteeringComponent.ixx.
Referenced by resetToDefaults, rotationDampening, setRotationDampening and SteeringComponent.
rotationSpeed_
| protected |
Maximum rotation speed in degrees per second.
Definition at line 57 of file SteeringComponent.ixx.
Referenced by resetToDefaults, rotationSpeed, setRotationSpeed and SteeringComponent.
rotationSpeedThreshold_
| protected |
Minimum rotation speed before rotation stops completely.
Definition at line 62 of file SteeringComponent.ixx.
Referenced by resetToDefaults, rotationSpeedThreshold, setRotationSpeedThreshold and SteeringComponent.
stateChanged_
| protected |
Indicates whether input is currently being received.
Definition at line 92 of file SteeringComponent.ixx.
Referenced by setSteeringIntent and stateChanged.
steeringInput_
| protected |
Current steering input as 2D direction vector.
Definition at line 105 of file SteeringComponent.ixx.
Referenced by setSteeringIntent, steeringInput and steeringIntent.
targetRotationAngle_
| protected |
Target rotation angle derived from input direction.
Definition at line 77 of file SteeringComponent.ixx.
Referenced by setTargetRotationAngle and targetRotationAngle.
turnIntensity_
| protected |
Intensity of the turn input, typically from 0.0 to 1.0.
Derived from the magnitude of the input direction vector. Used to modulate rotation speed based on stick deflection.
Definition at line 100 of file SteeringComponent.ixx.
Referenced by setSteeringIntent and turnIntensity.
useInstantRotation_
| protected |
Flag for instant rotation mode.
When true, the entity snaps to the target rotation instantly rather than smoothly interpolating.
Definition at line 120 of file SteeringComponent.ixx.
Referenced by setUseInstantRotation, SteeringComponent, SteeringComponent and useInstantRotation.
Protected Static Attributes
DEFAULT_ROTATION_DAMPENING
| constexpr protected static |
Default exponential decay factor for rotation when input stops.
Definition at line 52 of file SteeringComponent.ixx.
Referenced by resetToDefaults.
DEFAULT_ROTATION_SPEED
| constexpr protected static |
Default maximum rotation speed in degrees per second.
Definition at line 42 of file SteeringComponent.ixx.
Referenced by resetToDefaults.
DEFAULT_ROTATION_SPEED_THRESHOLD
| constexpr protected static |
Default minimum rotation speed before rotation stops completely.
Definition at line 47 of file SteeringComponent.ixx.
Referenced by resetToDefaults.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.