Skip to main content

RotationStateComponent Class

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

Declaration

class helios::engine::modules::spatial::transform::components::RotationStateComponent { ... }

Public Constructors Index

RotationStateComponent ()=default

Default constructor. More...

RotationStateComponent (const RotationStateComponent &other)

Copy constructor. More...

RotationStateComponent (RotationStateComponent &&) noexcept=default

Public Operators Index

RotationStateComponent &operator= (const RotationStateComponent &)=default
RotationStateComponent &operator= (RotationStateComponent &&) noexcept=default

Public Member Functions Index

boolisEnabled () const noexcept

Checks whether this component is enabled. More...

voidenable () noexcept

Enables this component. More...

voiddisable () noexcept

Disables this component. More...

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...

boolisEnabled_ = true

Whether this component is enabled. 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 31 of file RotationStateComponent.ixx.

Public Constructors

RotationStateComponent()

helios::engine::modules::spatial::transform::components::RotationStateComponent::RotationStateComponent ()
default

Default constructor.

Definition at line 139 of file RotationStateComponent.ixx.

Referenced by operator=, operator=, RotationStateComponent and RotationStateComponent.

RotationStateComponent()

helios::engine::modules::spatial::transform::components::RotationStateComponent::RotationStateComponent (const RotationStateComponent & other)
inline

Copy constructor.

Parameters
other

The component to copy from.

Copies rotation axes but resets angles and matrices.

Definition at line 148 of file RotationStateComponent.ixx.

149 headingRotationAxis_(other.headingRotationAxis_),
150 spinRotationAxis_(other.spinRotationAxis_)
151 {}

Reference RotationStateComponent.

RotationStateComponent()

helios::engine::modules::spatial::transform::components::RotationStateComponent::RotationStateComponent (RotationStateComponent &&)
noexcept default

Definition at line 154 of file RotationStateComponent.ixx.

Reference RotationStateComponent.

Public Operators

operator=()

RotationStateComponent & helios::engine::modules::spatial::transform::components::RotationStateComponent::operator= (const RotationStateComponent &)
default

Definition at line 153 of file RotationStateComponent.ixx.

Reference RotationStateComponent.

operator=()

RotationStateComponent & helios::engine::modules::spatial::transform::components::RotationStateComponent::operator= (RotationStateComponent &&)
noexcept default

Definition at line 155 of file RotationStateComponent.ixx.

Reference RotationStateComponent.

Public Member Functions

disable()

void helios::engine::modules::spatial::transform::components::RotationStateComponent::disable ()
inline noexcept

Disables this component.

Definition at line 99 of file RotationStateComponent.ixx.

99 void disable() noexcept {
100 isEnabled_ = false;
101 }

enable()

void helios::engine::modules::spatial::transform::components::RotationStateComponent::enable ()
inline noexcept

Enables this component.

Definition at line 92 of file RotationStateComponent.ixx.

92 void enable() noexcept {
93 isEnabled_ = true;
94 }

headingRotation()

const helios::math::mat4f & helios::engine::modules::spatial::transform::components::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 252 of file RotationStateComponent.ixx.

253 update();
254 return headingRotationMatrix_;
255 }

headingRotationAngle()

float helios::engine::modules::spatial::transform::components::RotationStateComponent::headingRotationAngle ()
inline nodiscard noexcept

Returns the current heading rotation angle.

Returns

The heading rotation angle in degrees.

Definition at line 172 of file RotationStateComponent.ixx.

172 [[nodiscard]] float headingRotationAngle() const noexcept {
173 return headingRotationAngle_;
174 }

headingRotationAxis()

helios::math::vec3f helios::engine::modules::spatial::transform::components::RotationStateComponent::headingRotationAxis ()
inline nodiscard noexcept

Returns the heading rotation axis.

Returns

The current heading rotation axis.

Definition at line 191 of file RotationStateComponent.ixx.

191 [[nodiscard]] helios::math::vec3f headingRotationAxis() const noexcept {
192 return headingRotationAxis_;
193 }

isEnabled()

bool helios::engine::modules::spatial::transform::components::RotationStateComponent::isEnabled ()
inline nodiscard noexcept

Checks whether this component is enabled.

Returns

True if enabled, false otherwise.

Definition at line 85 of file RotationStateComponent.ixx.

85 [[nodiscard]] bool isEnabled() const noexcept {
86 return isEnabled_;
87 }

rotation()

const helios::math::mat4f & helios::engine::modules::spatial::transform::components::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 264 of file RotationStateComponent.ixx.

264 const helios::math::mat4f& rotation() noexcept {
265 update();
266 return composedRotationMatrix_;
267 }

setHeadingRotationAngle()

void helios::engine::modules::spatial::transform::components::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 162 of file RotationStateComponent.ixx.

162 void setHeadingRotationAngle(float angle) {
163 headingRotationAngle_ = std::fmod(angle, 360.0f);
164 needsUpdate_ = true;
165 }

Reference setHeadingRotationAngle.

Referenced by helios::engine::builder::gameObject::builders::configs::TransformConfig::rotate and setHeadingRotationAngle.

setHeadingRotationAxis()

void helios::engine::modules::spatial::transform::components::RotationStateComponent::setHeadingRotationAxis (helios::math::vec3f axis)
inline

Sets the heading rotation axis.

Parameters
axis

The new rotation axis (should be normalized).

Definition at line 181 of file RotationStateComponent.ixx.

182 headingRotationAxis_ = axis;
183 needsUpdate_ = true;
184 }

setSpinRotationAngle()

void helios::engine::modules::spatial::transform::components::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 200 of file RotationStateComponent.ixx.

200 void setSpinRotationAngle(float angle) {
201 spinRotationAngle_ = std::fmod(angle, 360.0f);
202 needsUpdate_ = true;
203 }

setSpinRotationAxis()

void helios::engine::modules::spatial::transform::components::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 219 of file RotationStateComponent.ixx.

220 spinRotationAxis_ = axis;
221 needsUpdate_ = true;
222 }

spinRotation()

const helios::math::mat4f & helios::engine::modules::spatial::transform::components::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 240 of file RotationStateComponent.ixx.

241 update();
242 return spinRotationMatrix_;
243 }

spinRotationAngle()

float helios::engine::modules::spatial::transform::components::RotationStateComponent::spinRotationAngle ()
inline nodiscard noexcept

Returns the current spin rotation angle.

Returns

The spin rotation angle in degrees.

Definition at line 210 of file RotationStateComponent.ixx.

210 [[nodiscard]] float spinRotationAngle() const noexcept {
211 return spinRotationAngle_;
212 }

spinRotationAxis()

helios::math::vec3f helios::engine::modules::spatial::transform::components::RotationStateComponent::spinRotationAxis ()
inline nodiscard noexcept

Returns the spin rotation axis.

Returns

The current spin rotation axis.

Definition at line 229 of file RotationStateComponent.ixx.

229 [[nodiscard]] helios::math::vec3f spinRotationAxis() const noexcept {
230 return spinRotationAxis_;
231 }

Private Member Functions

update()

void helios::engine::modules::spatial::transform::components::RotationStateComponent::update ()
inline

Recalculates rotation matrices if dirty.

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

Definition at line 111 of file RotationStateComponent.ixx.

111 void update() {
112
113 if (!needsUpdate_) {
114 return;
115 }
116 needsUpdate_ = false;
117
118 spinRotationMatrix_ = helios::math::rotate(
120 helios::math::radians(spinRotationAngle_),
121 spinRotationAxis_
122 );
123
124 headingRotationMatrix_ = helios::math::rotate(
126 helios::math::radians(headingRotationAngle_),
127 headingRotationAxis_
128
129 );
130
131 composedRotationMatrix_ = headingRotationMatrix_ * spinRotationMatrix_;
132 }

Private Member Attributes

composedRotationMatrix_

helios::math::mat4f helios::engine::modules::spatial::transform::components::RotationStateComponent::composedRotationMatrix_

Cached composed rotation matrix (heading * spin).

Definition at line 71 of file RotationStateComponent.ixx.

71 helios::math::mat4f composedRotationMatrix_;

headingRotationAngle_

float helios::engine::modules::spatial::transform::components::RotationStateComponent::headingRotationAngle_ = 0.0f

Current heading rotation angle in degrees.

Definition at line 36 of file RotationStateComponent.ixx.

36 float headingRotationAngle_ = 0.0f;

headingRotationAxis_

helios::math::vec3f helios::engine::modules::spatial::transform::components::RotationStateComponent::headingRotationAxis_ {}

Axis around which heading rotation occurs.

Definition at line 41 of file RotationStateComponent.ixx.

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

headingRotationMatrix_

helios::math::mat4f helios::engine::modules::spatial::transform::components::RotationStateComponent::headingRotationMatrix_

Cached heading rotation matrix.

Definition at line 66 of file RotationStateComponent.ixx.

66 helios::math::mat4f headingRotationMatrix_;

isEnabled_

bool helios::engine::modules::spatial::transform::components::RotationStateComponent::isEnabled_ = true

Whether this component is enabled.

Definition at line 76 of file RotationStateComponent.ixx.

76 bool isEnabled_ = true;

needsUpdate_

bool helios::engine::modules::spatial::transform::components::RotationStateComponent::needsUpdate_ = true

Dirty flag indicating matrices need recalculation.

Definition at line 56 of file RotationStateComponent.ixx.

56 bool needsUpdate_ = true;

spinRotationAngle_

float helios::engine::modules::spatial::transform::components::RotationStateComponent::spinRotationAngle_ = 0.0f

Current spin rotation angle in degrees.

Definition at line 46 of file RotationStateComponent.ixx.

46 float spinRotationAngle_ = 0.0f;

spinRotationAxis_

helios::math::vec3f helios::engine::modules::spatial::transform::components::RotationStateComponent::spinRotationAxis_ {}

Axis around which spin rotation occurs.

Definition at line 51 of file RotationStateComponent.ixx.

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

spinRotationMatrix_

helios::math::mat4f helios::engine::modules::spatial::transform::components::RotationStateComponent::spinRotationMatrix_

Cached spin rotation matrix.

Definition at line 61 of file RotationStateComponent.ixx.

61 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.