HeadingComponent Class
Component that manages the heading (orientation) of an entity. More...
Declaration
Base class
| class | Component |
|
Abstract base class for components attached to GameObjects. More... | |
Public Member Functions Index
| void | setHeading (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 | isInputActive () const noexcept |
|
Checks if input is currently active. More... | |
| const helios::math::vec3f & | headingInput () const noexcept |
|
Returns the current steering input direction. 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 | isInputActive_ = 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 | headingInput_ |
|
Current steering input as 2D direction vector. 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 HeadingSystem to update the entity's orientation.
Definition at line 35 of file HeadingComponent.ixx.
Public Member Functions
currentRotationAngle()
| inline nodiscard noexcept |
Returns the current rotation angle.
- Returns
The current rotation angle in degrees.
Definition at line 181 of file HeadingComponent.ixx.
Reference currentRotationAngle_.
currentRotationSpeed()
| inline nodiscard noexcept |
Returns the current rotation speed.
- Returns
The current rotation speed.
Definition at line 163 of file HeadingComponent.ixx.
Reference currentRotationSpeed_.
headingInput()
| inline nodiscard noexcept |
Returns the current steering input direction.
- Returns
Const reference to the 2D steering input vector.
Definition at line 235 of file HeadingComponent.ixx.
Reference headingInput_.
isInputActive()
| inline nodiscard noexcept |
Checks if input is currently active.
- Returns
True if input is active, false otherwise.
Definition at line 226 of file HeadingComponent.ixx.
Reference isInputActive_.
resetToDefaults()
| inline noexcept |
Resets all physics parameters to their default values.
Definition at line 305 of file HeadingComponent.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 172 of file HeadingComponent.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 145 of file HeadingComponent.ixx.
Reference helios::math::Z_AXISf.
rotationDampening()
| inline nodiscard noexcept |
Returns the rotation dampening factor.
- Returns
Exponential decay factor for rotation.
Definition at line 258 of file HeadingComponent.ixx.
Reference rotationDampening_.
rotationSpeed()
| inline nodiscard noexcept |
Returns the maximum rotation speed in degrees per second.
- Returns
Maximum rotation speed value.
Definition at line 244 of file HeadingComponent.ixx.
Reference rotationSpeed_.
rotationSpeedThreshold()
| inline nodiscard noexcept |
Returns the minimum rotation speed threshold.
- Returns
Rotation speed threshold below which rotation stops.
Definition at line 251 of file HeadingComponent.ixx.
Reference rotationSpeedThreshold_.
setCurrentRotationAngle()
| inline noexcept |
Sets the current rotation angle.
- Parameters
-
angle The new rotation angle in degrees.
Definition at line 208 of file HeadingComponent.ixx.
Reference currentRotationAngle_.
setCurrentRotationSpeed()
| inline noexcept |
Sets the current rotation speed.
- Parameters
-
speed The new rotation speed.
Definition at line 154 of file HeadingComponent.ixx.
Reference currentRotationSpeed_.
setHeading()
| 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 122 of file HeadingComponent.ixx.
References helios::math::EPSILON_LENGTH, headingInput_, isInputActive_, helios::math::vec3< T >::length, turnIntensity and turnIntensity_.
setRotationAngleDelta()
| inline noexcept |
Sets the angular distance to the target rotation.
- Parameters
-
delta The new angle delta in degrees.
Definition at line 217 of file HeadingComponent.ixx.
Reference rotationAngleDelta_.
setRotationDampening()
| inline noexcept |
Sets the rotation dampening factor.
- Parameters
-
value New dampening factor (exponential decay).
Definition at line 285 of file HeadingComponent.ixx.
Reference rotationDampening_.
setRotationSpeed()
| inline noexcept |
Sets the maximum rotation speed in degrees per second.
- Parameters
-
value New rotation speed value.
Definition at line 265 of file HeadingComponent.ixx.
Reference rotationSpeed_.
setRotationSpeedThreshold()
| inline noexcept |
Sets the minimum rotation speed threshold.
- Parameters
-
value New threshold value.
Definition at line 274 of file HeadingComponent.ixx.
Reference rotationSpeedThreshold_.
setTargetRotationAngle()
| inline noexcept |
Sets the target rotation angle.
- Parameters
-
angle The new target rotation angle in degrees.
Definition at line 199 of file HeadingComponent.ixx.
Reference targetRotationAngle_.
targetRotationAngle()
| inline nodiscard noexcept |
Returns the target rotation angle.
- Returns
The target rotation angle in degrees.
Definition at line 190 of file HeadingComponent.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 294 of file HeadingComponent.ixx.
Reference turnIntensity_.
Referenced by setHeading.
Protected Member Attributes
currentRotationAngle_
| protected |
Current rotation angle in degrees.
Definition at line 72 of file HeadingComponent.ixx.
Referenced by currentRotationAngle and setCurrentRotationAngle.
currentRotationSpeed_
| protected |
Current rotation speed after applying input and dampening.
Definition at line 87 of file HeadingComponent.ixx.
Referenced by currentRotationSpeed and setCurrentRotationSpeed.
headingInput_
| protected |
Current steering input as 2D direction vector.
Definition at line 105 of file HeadingComponent.ixx.
Referenced by headingInput and setHeading.
isInputActive_
| protected |
Indicates whether input is currently being received.
Definition at line 92 of file HeadingComponent.ixx.
Referenced by isInputActive and setHeading.
rotationAngleDelta_
| protected |
Shortest angular distance to target rotation.
Definition at line 82 of file HeadingComponent.ixx.
Referenced by rotationAngleDelta and setRotationAngleDelta.
rotationDampening_
| protected |
Exponential decay factor for rotation when input stops.
Definition at line 67 of file HeadingComponent.ixx.
Referenced by resetToDefaults, rotationDampening and setRotationDampening.
rotationSpeed_
| protected |
Maximum rotation speed in degrees per second.
Definition at line 57 of file HeadingComponent.ixx.
Referenced by resetToDefaults, rotationSpeed and setRotationSpeed.
rotationSpeedThreshold_
| protected |
Minimum rotation speed before rotation stops completely.
Definition at line 62 of file HeadingComponent.ixx.
Referenced by resetToDefaults, rotationSpeedThreshold and setRotationSpeedThreshold.
targetRotationAngle_
| protected |
Target rotation angle derived from input direction.
Definition at line 77 of file HeadingComponent.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 HeadingComponent.ixx.
Referenced by setHeading and turnIntensity.
Protected Static Attributes
DEFAULT_ROTATION_DAMPENING
| constexpr protected static |
Default exponential decay factor for rotation when input stops.
Definition at line 52 of file HeadingComponent.ixx.
Referenced by resetToDefaults.
DEFAULT_ROTATION_SPEED
| constexpr protected static |
Default maximum rotation speed in degrees per second.
Definition at line 42 of file HeadingComponent.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 HeadingComponent.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.