Skip to main content

HeadingComponent Class

Component that manages the heading (orientation) of an entity. More...

Declaration

class helios::engine::game::components::physics::HeadingComponent { ... }

Base class

classComponent

Abstract base class for components attached to GameObjects. More...

Public Member Functions Index

voidsetHeading (helios::math::vec3f direction, float turnIntensity)

Sets the heading direction and turn intensity from input. More...

helios::math::vec3frotationAxis () const noexcept

Returns the axis around which rotation occurs. More...

voidsetCurrentRotationSpeed (float speed) noexcept

Sets the current rotation speed. More...

floatcurrentRotationSpeed () const noexcept

Returns the current rotation speed. More...

floatrotationAngleDelta () const noexcept

Returns the angular distance to the target rotation. More...

floatcurrentRotationAngle () const noexcept

Returns the current rotation angle. More...

floattargetRotationAngle () const noexcept

Returns the target rotation angle. More...

voidsetTargetRotationAngle (float angle) noexcept

Sets the target rotation angle. More...

voidsetCurrentRotationAngle (float angle) noexcept

Sets the current rotation angle. More...

voidsetRotationAngleDelta (float delta) noexcept

Sets the angular distance to the target rotation. More...

boolisInputActive () const noexcept

Checks if input is currently active. More...

const helios::math::vec3f &headingInput () const noexcept

Returns the current steering input direction. More...

floatrotationSpeed () const noexcept

Returns the maximum rotation speed in degrees per second. More...

floatrotationSpeedThreshold () const noexcept

Returns the minimum rotation speed threshold. More...

floatrotationDampening () const noexcept

Returns the rotation dampening factor. More...

voidsetRotationSpeed (float value) noexcept

Sets the maximum rotation speed in degrees per second. More...

voidsetRotationSpeedThreshold (float value) noexcept

Sets the minimum rotation speed threshold. More...

voidsetRotationDampening (float value) noexcept

Sets the rotation dampening factor. More...

floatturnIntensity () const noexcept

Returns the current turn intensity. More...

voidresetToDefaults () noexcept

Resets all physics parameters to their default values. More...

Protected Member Attributes Index

floatrotationSpeed_ = DEFAULT_ROTATION_SPEED

Maximum rotation speed in degrees per second. More...

floatrotationSpeedThreshold_ = DEFAULT_ROTATION_SPEED_THRESHOLD

Minimum rotation speed before rotation stops completely. More...

floatrotationDampening_ = DEFAULT_ROTATION_DAMPENING

Exponential decay factor for rotation when input stops. More...

floatcurrentRotationAngle_ = 0

Current rotation angle in degrees. More...

floattargetRotationAngle_ = 0

Target rotation angle derived from input direction. More...

floatrotationAngleDelta_ = 0

Shortest angular distance to target rotation. More...

floatcurrentRotationSpeed_ = 0.0f

Current rotation speed after applying input and dampening. More...

boolisInputActive_ = true

Indicates whether input is currently being received. More...

floatturnIntensity_ = 0.0f

Intensity of the turn input, typically from 0.0 to 1.0. More...

helios::math::vec3fheadingInput_

Current steering input as 2D direction vector. More...

Protected Static Attributes Index

static constexpr floatDEFAULT_ROTATION_SPEED = 560.0f

Default maximum rotation speed in degrees per second. More...

static constexpr floatDEFAULT_ROTATION_SPEED_THRESHOLD = 0.1f

Default minimum rotation speed before rotation stops completely. More...

static constexpr floatDEFAULT_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()

float helios::engine::game::components::physics::HeadingComponent::currentRotationAngle ()
inline nodiscard noexcept

Returns the current rotation angle.

Returns

The current rotation angle in degrees.

Definition at line 181 of file HeadingComponent.ixx.

181 [[nodiscard]] float currentRotationAngle() const noexcept {
183 }

Reference currentRotationAngle_.

currentRotationSpeed()

float helios::engine::game::components::physics::HeadingComponent::currentRotationSpeed ()
inline nodiscard noexcept

Returns the current rotation speed.

Returns

The current rotation speed.

Definition at line 163 of file HeadingComponent.ixx.

163 [[nodiscard]] float currentRotationSpeed() const noexcept {
165 }

Reference currentRotationSpeed_.

headingInput()

const helios::math::vec3f & helios::engine::game::components::physics::HeadingComponent::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.

235 [[nodiscard]] const helios::math::vec3f& headingInput() const noexcept {
236 return headingInput_;
237 }

Reference headingInput_.

isInputActive()

bool helios::engine::game::components::physics::HeadingComponent::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.

226 [[nodiscard]] bool isInputActive() const noexcept {
227 return isInputActive_;
228 }

Reference isInputActive_.

resetToDefaults()

void helios::engine::game::components::physics::HeadingComponent::resetToDefaults ()
inline noexcept

rotationAngleDelta()

float helios::engine::game::components::physics::HeadingComponent::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.

172 [[nodiscard]] float rotationAngleDelta() const noexcept {
174 }

Reference rotationAngleDelta_.

rotationAxis()

helios::math::vec3f helios::engine::game::components::physics::HeadingComponent::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.

145 [[nodiscard]] helios::math::vec3f rotationAxis() const noexcept {
147 }

Reference helios::math::Z_AXISf.

rotationDampening()

float helios::engine::game::components::physics::HeadingComponent::rotationDampening ()
inline nodiscard noexcept

Returns the rotation dampening factor.

Returns

Exponential decay factor for rotation.

Definition at line 258 of file HeadingComponent.ixx.

258 [[nodiscard]] float rotationDampening() const noexcept { return rotationDampening_; }

Reference rotationDampening_.

rotationSpeed()

float helios::engine::game::components::physics::HeadingComponent::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.

244 [[nodiscard]] float rotationSpeed() const noexcept { return rotationSpeed_; }

Reference rotationSpeed_.

rotationSpeedThreshold()

float helios::engine::game::components::physics::HeadingComponent::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.

251 [[nodiscard]] float rotationSpeedThreshold() const noexcept { return rotationSpeedThreshold_; }

Reference rotationSpeedThreshold_.

setCurrentRotationAngle()

void helios::engine::game::components::physics::HeadingComponent::setCurrentRotationAngle (float angle)
inline noexcept

Sets the current rotation angle.

Parameters
angle

The new rotation angle in degrees.

Definition at line 208 of file HeadingComponent.ixx.

208 void setCurrentRotationAngle(float angle) noexcept {
210 }

Reference currentRotationAngle_.

setCurrentRotationSpeed()

void helios::engine::game::components::physics::HeadingComponent::setCurrentRotationSpeed (float speed)
inline noexcept

Sets the current rotation speed.

Parameters
speed

The new rotation speed.

Definition at line 154 of file HeadingComponent.ixx.

154 void setCurrentRotationSpeed(float speed) noexcept {
156 }

Reference currentRotationSpeed_.

setHeading()

void helios::engine::game::components::physics::HeadingComponent::setHeading (helios::math::vec3f direction, float turnIntensity)
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.

123
124 headingInput_ = direction;
126 isInputActive_ = true;
127
129 headingInput_ = {0.0f, 0.0f, 0.0f};
130 isInputActive_ = false;
131 turnIntensity_ = 0.0f;
132 return;
133 }
134
135 assert(std::abs(direction.length() - 1.0f) <= 0.001f && "Unexpected direction vector - not normalized");
136 }

References helios::math::EPSILON_LENGTH, headingInput_, isInputActive_, helios::math::vec3< T >::length, turnIntensity and turnIntensity_.

setRotationAngleDelta()

void helios::engine::game::components::physics::HeadingComponent::setRotationAngleDelta (float delta)
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.

217 void setRotationAngleDelta(float delta) noexcept {
218 rotationAngleDelta_ = delta;
219 }

Reference rotationAngleDelta_.

setRotationDampening()

void helios::engine::game::components::physics::HeadingComponent::setRotationDampening (float value)
inline noexcept

Sets the rotation dampening factor.

Parameters
value

New dampening factor (exponential decay).

Definition at line 285 of file HeadingComponent.ixx.

285 void setRotationDampening(float value) noexcept {
286 rotationDampening_ = value;
287 }

Reference rotationDampening_.

setRotationSpeed()

void helios::engine::game::components::physics::HeadingComponent::setRotationSpeed (float value)
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.

265 void setRotationSpeed(float value) noexcept { rotationSpeed_ = value; }

Reference rotationSpeed_.

setRotationSpeedThreshold()

void helios::engine::game::components::physics::HeadingComponent::setRotationSpeedThreshold (float value)
inline noexcept

Sets the minimum rotation speed threshold.

Parameters
value

New threshold value.

Definition at line 274 of file HeadingComponent.ixx.

274 void setRotationSpeedThreshold(float value) noexcept {
276 }

Reference rotationSpeedThreshold_.

setTargetRotationAngle()

void helios::engine::game::components::physics::HeadingComponent::setTargetRotationAngle (float angle)
inline noexcept

Sets the target rotation angle.

Parameters
angle

The new target rotation angle in degrees.

Definition at line 199 of file HeadingComponent.ixx.

199 void setTargetRotationAngle(float angle) noexcept {
201 }

Reference targetRotationAngle_.

targetRotationAngle()

float helios::engine::game::components::physics::HeadingComponent::targetRotationAngle ()
inline nodiscard noexcept

Returns the target rotation angle.

Returns

The target rotation angle in degrees.

Definition at line 190 of file HeadingComponent.ixx.

190 [[nodiscard]] float targetRotationAngle() const noexcept {
192 }

Reference targetRotationAngle_.

turnIntensity()

float helios::engine::game::components::physics::HeadingComponent::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.

294 [[nodiscard]] float turnIntensity() const noexcept {
295 return turnIntensity_;
296 }

Reference turnIntensity_.

Referenced by setHeading.

Protected Member Attributes

currentRotationAngle_

float helios::engine::game::components::physics::HeadingComponent::currentRotationAngle_ = 0
protected

Current rotation angle in degrees.

Definition at line 72 of file HeadingComponent.ixx.

Referenced by currentRotationAngle and setCurrentRotationAngle.

currentRotationSpeed_

float helios::engine::game::components::physics::HeadingComponent::currentRotationSpeed_ = 0.0f
protected

Current rotation speed after applying input and dampening.

Definition at line 87 of file HeadingComponent.ixx.

Referenced by currentRotationSpeed and setCurrentRotationSpeed.

headingInput_

helios::math::vec3f helios::engine::game::components::physics::HeadingComponent::headingInput_
protected

Current steering input as 2D direction vector.

Definition at line 105 of file HeadingComponent.ixx.

Referenced by headingInput and setHeading.

isInputActive_

bool helios::engine::game::components::physics::HeadingComponent::isInputActive_ = true
protected

Indicates whether input is currently being received.

Definition at line 92 of file HeadingComponent.ixx.

92 bool isInputActive_ = true;

Referenced by isInputActive and setHeading.

rotationAngleDelta_

float helios::engine::game::components::physics::HeadingComponent::rotationAngleDelta_ = 0
protected

Shortest angular distance to target rotation.

Definition at line 82 of file HeadingComponent.ixx.

Referenced by rotationAngleDelta and setRotationAngleDelta.

rotationDampening_

float helios::engine::game::components::physics::HeadingComponent::rotationDampening_ = DEFAULT_ROTATION_DAMPENING
protected

Exponential decay factor for rotation when input stops.

Definition at line 67 of file HeadingComponent.ixx.

Referenced by resetToDefaults, rotationDampening and setRotationDampening.

rotationSpeed_

float helios::engine::game::components::physics::HeadingComponent::rotationSpeed_ = DEFAULT_ROTATION_SPEED
protected

Maximum rotation speed in degrees per second.

Definition at line 57 of file HeadingComponent.ixx.

Referenced by resetToDefaults, rotationSpeed and setRotationSpeed.

rotationSpeedThreshold_

float helios::engine::game::components::physics::HeadingComponent::rotationSpeedThreshold_ = DEFAULT_ROTATION_SPEED_THRESHOLD
protected

Minimum rotation speed before rotation stops completely.

Definition at line 62 of file HeadingComponent.ixx.

Referenced by resetToDefaults, rotationSpeedThreshold and setRotationSpeedThreshold.

targetRotationAngle_

float helios::engine::game::components::physics::HeadingComponent::targetRotationAngle_ = 0
protected

Target rotation angle derived from input direction.

Definition at line 77 of file HeadingComponent.ixx.

Referenced by setTargetRotationAngle and targetRotationAngle.

turnIntensity_

float helios::engine::game::components::physics::HeadingComponent::turnIntensity_ = 0.0f
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.

100 float turnIntensity_ = 0.0f;

Referenced by setHeading and turnIntensity.

Protected Static Attributes

DEFAULT_ROTATION_DAMPENING

float helios::engine::game::components::physics::HeadingComponent::DEFAULT_ROTATION_DAMPENING = 0.0001f
constexpr protected static

Default exponential decay factor for rotation when input stops.

Definition at line 52 of file HeadingComponent.ixx.

52 static constexpr float DEFAULT_ROTATION_DAMPENING = 0.0001f;

Referenced by resetToDefaults.

DEFAULT_ROTATION_SPEED

float helios::engine::game::components::physics::HeadingComponent::DEFAULT_ROTATION_SPEED = 560.0f
constexpr protected static

Default maximum rotation speed in degrees per second.

Definition at line 42 of file HeadingComponent.ixx.

42 static constexpr float DEFAULT_ROTATION_SPEED = 560.0f;

Referenced by resetToDefaults.

DEFAULT_ROTATION_SPEED_THRESHOLD

float helios::engine::game::components::physics::HeadingComponent::DEFAULT_ROTATION_SPEED_THRESHOLD = 0.1f
constexpr protected static

Default minimum rotation speed before rotation stops completely.

Definition at line 47 of file HeadingComponent.ixx.

47 static constexpr float DEFAULT_ROTATION_SPEED_THRESHOLD = 0.1f;

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.