Skip to main content

RotationStateComponent Class

Component that manages composite rotation from heading and spin rotations. More...

Declaration

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

Base class

classComponent

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

Public Member Functions Index

voidsetHeadingRotationAngle (float angle)

Sets the heading rotation angle. More...

floatheadingRotationAngle () const noexcept

Returns the current heading rotation angle. More...

voidsetHeadingRotationAxis (helios::math::vec3f axis)

Sets the heading rotation axis. More...

helios::math::vec3fheadingRotationAxis () const noexcept

Returns the heading rotation axis. More...

voidsetSpinRotationAngle (float angle)

Sets the spin rotation angle. More...

floatspinRotationAngle () const noexcept

Returns the current spin rotation angle. More...

voidsetSpinRotationAxis (helios::math::vec3f axis)

Sets the spin rotation axis. More...

helios::math::vec3fspinRotationAxis () const noexcept

Returns the spin rotation axis. More...

const helios::math::mat4f &spinRotation () noexcept

Returns the spin rotation matrix. More...

const helios::math::mat4f &headingRotation () noexcept

Returns the heading rotation matrix. More...

const helios::math::mat4f &rotation () noexcept

Returns the composed rotation matrix (heading * spin). More...

Private Member Functions Index

voidupdate ()

Recalculates rotation matrices if dirty. More...

Private Member Attributes Index

floatheadingRotationAngle_ = 0.0f

Current heading rotation angle in degrees. More...

helios::math::vec3fheadingRotationAxis_ {}

Axis around which heading rotation occurs. More...

floatspinRotationAngle_ = 0.0f

Current spin rotation angle in degrees. More...

helios::math::vec3fspinRotationAxis_ {}

Axis around which spin rotation occurs. More...

boolneedsUpdate_ = true

Dirty flag indicating matrices need recalculation. More...

helios::math::mat4fspinRotationMatrix_

Cached spin rotation matrix. More...

helios::math::mat4fheadingRotationMatrix_

Cached heading rotation matrix. More...

helios::math::mat4fcomposedRotationMatrix_

Cached composed rotation matrix (heading * spin). More...

Description

Component that manages composite rotation from heading and spin rotations.

This component combines two independent rotation sources:

  • **Heading Rotation:** The direction the entity is facing (controlled by input).
  • **Spin Rotation:** Additional rotation for visual effects (e.g., rolling, tumbling).

The component caches the computed rotation matrices and only recalculates them when the underlying angles or axes change (dirty flag pattern).

Definition at line 28 of file RotationStateComponent.ixx.

Public Member Functions

headingRotation()

const helios::math::mat4f & helios::engine::game::components::physics::RotationStateComponent::headingRotation ()
inline noexcept

Returns the heading rotation matrix.

Triggers matrix update if dirty.

Returns

Const reference to the heading rotation matrix.

Definition at line 198 of file RotationStateComponent.ixx.

199 update();
200 return headingRotationMatrix_;
201 }

headingRotationAngle()

float helios::engine::game::components::physics::RotationStateComponent::headingRotationAngle ()
inline nodiscard noexcept

Returns the current heading rotation angle.

Returns

The heading rotation angle in degrees.

Definition at line 118 of file RotationStateComponent.ixx.

118 [[nodiscard]] float headingRotationAngle() const noexcept {
119 return headingRotationAngle_;
120 }

headingRotationAxis()

helios::math::vec3f helios::engine::game::components::physics::RotationStateComponent::headingRotationAxis ()
inline nodiscard noexcept

Returns the heading rotation axis.

Returns

The current heading rotation axis.

Definition at line 137 of file RotationStateComponent.ixx.

137 [[nodiscard]] helios::math::vec3f headingRotationAxis() const noexcept {
138 return headingRotationAxis_;
139 }

rotation()

const helios::math::mat4f & helios::engine::game::components::physics::RotationStateComponent::rotation ()
inline noexcept

Returns the composed rotation matrix (heading * spin).

Triggers matrix update if dirty.

Returns

Const reference to the composed rotation matrix.

Definition at line 210 of file RotationStateComponent.ixx.

210 const helios::math::mat4f& rotation() noexcept {
211 update();
212 return composedRotationMatrix_;
213 }

setHeadingRotationAngle()

void helios::engine::game::components::physics::RotationStateComponent::setHeadingRotationAngle (float angle)
inline

Sets the heading rotation angle.

Parameters
angle

The new heading rotation angle in degrees (wrapped to 0-360).

Definition at line 108 of file RotationStateComponent.ixx.

108 void setHeadingRotationAngle(float angle) {
109 headingRotationAngle_ = std::fmod(angle, 360.0f);
110 needsUpdate_ = true;
111 }

setHeadingRotationAxis()

void helios::engine::game::components::physics::RotationStateComponent::setHeadingRotationAxis (helios::math::vec3f axis)
inline

Sets the heading rotation axis.

Parameters
axis

The new rotation axis (should be normalized).

Definition at line 127 of file RotationStateComponent.ixx.

128 headingRotationAxis_ = axis;
129 needsUpdate_ = true;
130 }

setSpinRotationAngle()

void helios::engine::game::components::physics::RotationStateComponent::setSpinRotationAngle (float angle)
inline

Sets the spin rotation angle.

Parameters
angle

The new spin rotation angle in degrees (wrapped to 0-360).

Definition at line 146 of file RotationStateComponent.ixx.

146 void setSpinRotationAngle(float angle) {
147 spinRotationAngle_ = std::fmod(angle, 360.0f);
148 needsUpdate_ = true;
149 }

setSpinRotationAxis()

void helios::engine::game::components::physics::RotationStateComponent::setSpinRotationAxis (helios::math::vec3f axis)
inline

Sets the spin rotation axis.

Parameters
axis

The new spin rotation axis (should be normalized).

Definition at line 165 of file RotationStateComponent.ixx.

166 spinRotationAxis_ = axis;
167 needsUpdate_ = true;
168 }

spinRotation()

const helios::math::mat4f & helios::engine::game::components::physics::RotationStateComponent::spinRotation ()
inline noexcept

Returns the spin rotation matrix.

Triggers matrix update if dirty.

Returns

Const reference to the spin rotation matrix.

Definition at line 186 of file RotationStateComponent.ixx.

187 update();
188 return spinRotationMatrix_;
189 }

spinRotationAngle()

float helios::engine::game::components::physics::RotationStateComponent::spinRotationAngle ()
inline nodiscard noexcept

Returns the current spin rotation angle.

Returns

The spin rotation angle in degrees.

Definition at line 156 of file RotationStateComponent.ixx.

156 [[nodiscard]] float spinRotationAngle() const noexcept {
157 return spinRotationAngle_;
158 }

spinRotationAxis()

helios::math::vec3f helios::engine::game::components::physics::RotationStateComponent::spinRotationAxis ()
inline nodiscard noexcept

Returns the spin rotation axis.

Returns

The current spin rotation axis.

Definition at line 175 of file RotationStateComponent.ixx.

175 [[nodiscard]] helios::math::vec3f spinRotationAxis() const noexcept {
176 return spinRotationAxis_;
177 }

Private Member Functions

update()

void helios::engine::game::components::physics::RotationStateComponent::update ()
inline

Recalculates rotation matrices if dirty.

Updates spinRotationMatrix_, headingRotationMatrix_, and composedRotationMatrix_ based on current angles and axes.

Definition at line 78 of file RotationStateComponent.ixx.

78 void update() {
79
80 if (!needsUpdate_) {
81 return;
82 }
83 needsUpdate_ = false;
84
85 spinRotationMatrix_ = helios::math::rotate(
87 helios::math::radians(spinRotationAngle_),
88 spinRotationAxis_
89 );
90
91 headingRotationMatrix_ = helios::math::rotate(
93 helios::math::radians(headingRotationAngle_),
94 headingRotationAxis_
95
96 );
97
98 composedRotationMatrix_ = headingRotationMatrix_ * spinRotationMatrix_;
99 }

Private Member Attributes

composedRotationMatrix_

helios::math::mat4f helios::engine::game::components::physics::RotationStateComponent::composedRotationMatrix_

Cached composed rotation matrix (heading * spin).

Definition at line 68 of file RotationStateComponent.ixx.

68 helios::math::mat4f composedRotationMatrix_;

headingRotationAngle_

float helios::engine::game::components::physics::RotationStateComponent::headingRotationAngle_ = 0.0f

Current heading rotation angle in degrees.

Definition at line 33 of file RotationStateComponent.ixx.

33 float headingRotationAngle_ = 0.0f;

headingRotationAxis_

helios::math::vec3f helios::engine::game::components::physics::RotationStateComponent::headingRotationAxis_ {}

Axis around which heading rotation occurs.

Definition at line 38 of file RotationStateComponent.ixx.

38 helios::math::vec3f headingRotationAxis_{};

headingRotationMatrix_

helios::math::mat4f helios::engine::game::components::physics::RotationStateComponent::headingRotationMatrix_

Cached heading rotation matrix.

Definition at line 63 of file RotationStateComponent.ixx.

63 helios::math::mat4f headingRotationMatrix_;

needsUpdate_

bool helios::engine::game::components::physics::RotationStateComponent::needsUpdate_ = true

Dirty flag indicating matrices need recalculation.

Definition at line 53 of file RotationStateComponent.ixx.

53 bool needsUpdate_ = true;

spinRotationAngle_

float helios::engine::game::components::physics::RotationStateComponent::spinRotationAngle_ = 0.0f

Current spin rotation angle in degrees.

Definition at line 43 of file RotationStateComponent.ixx.

43 float spinRotationAngle_ = 0.0f;

spinRotationAxis_

helios::math::vec3f helios::engine::game::components::physics::RotationStateComponent::spinRotationAxis_ {}

Axis around which spin rotation occurs.

Definition at line 48 of file RotationStateComponent.ixx.

48 helios::math::vec3f spinRotationAxis_{};

spinRotationMatrix_

helios::math::mat4f helios::engine::game::components::physics::RotationStateComponent::spinRotationMatrix_

Cached spin rotation matrix.

Definition at line 58 of file RotationStateComponent.ixx.

58 helios::math::mat4f spinRotationMatrix_;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.