Skip to main content

SpinComponent.ixx File

Component for applying continuous spin rotation to an entity. More...

Included Headers

#include <helios.math>

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespacemodules

Domain-specific components and systems. More...

namespaceeffects

Visual effects module for game entities. More...

namespacegfx

Visual effects components and systems. More...

namespacecomponents

Visual effects components. More...

Classes Index

classSpinComponent

Component that defines spin properties for an entity. More...

Description

Component for applying continuous spin rotation to an entity.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file SpinComponent.ixx
3 * @brief Component for applying continuous spin rotation to an entity.
4 */
5module;
6
7
8export module helios.engine.modules.effects.gfx.components.SpinComponent;
9
10
11
12import helios.math;
13
14/**
15 * @todo move to spatial or effects
16 */
18
19 /**
20 * @brief Component that defines spin properties for an entity.
21 *
22 * @details
23 * This component is used by the SpinSystem to apply continuous rotation
24 * around a specific axis. It stores the rotation speed, axis, and current
25 * rotation state.
26 */
28
29 /**
30 * @brief Rotation speed in degrees per second.
31 */
32 float rotationSpeed_ = 720.0f;
33
34 /**
35 * @brief The axis around which the entity spins.
36 */
38
39 /**
40 * @brief Current accumulated rotation angle in degrees.
41 */
42 float currentRotation_ = 0.0f;
43
44 /**
45 * @brief Whether this component is enabled.
46 */
47 bool isEnabled_ = true;
48
49 public:
50
51 /**
52 * @brief Checks whether this component is enabled.
53 *
54 * @return True if enabled, false otherwise.
55 */
56 [[nodiscard]] bool isEnabled() const noexcept {
57 return isEnabled_;
58 }
59
60 /**
61 * @brief Enables this component.
62 */
63 void enable() noexcept {
64 isEnabled_ = true;
65 }
66
67 /**
68 * @brief Disables this component.
69 */
70 void disable() noexcept {
71 isEnabled_ = false;
72 }
73
74 /**
75 * @brief Constructs a SpinComponent.
76 *
77 * @param rotationSpeed Speed of rotation in degrees per second.
78 * @param rotationAxis The axis to rotate around.
79 */
80 explicit SpinComponent(
81 const float rotationSpeed, const helios::math::vec3f rotationAxis
82 ) : rotationSpeed_(rotationSpeed),
83 rotationAxis_(rotationAxis) {}
84
85 /**
86 * @brief Copy constructor.
87 *
88 * @param other The component to copy from.
89 */
91 : rotationSpeed_(other.rotationSpeed_),
92 rotationAxis_(other.rotationAxis_) {}
93
95 SpinComponent(SpinComponent&&) noexcept = default;
96 SpinComponent& operator=(SpinComponent&&) noexcept = default;
97
98 /**
99 * @brief Returns the rotation axis.
100 *
101 * @return The normalized rotation axis vector.
102 */
103 [[nodiscard]] helios::math::vec3f axis() {
104 return rotationAxis_;
105 }
106
107 /**
108 * @brief Returns the rotation speed.
109 *
110 * @return Speed in degrees per second.
111 */
112 [[nodiscard]] float speed() const {
113 return rotationSpeed_;
114 }
115
116 /**
117 * @brief Returns the current accumulated rotation.
118 *
119 * @return Current rotation angle in degrees.
120 */
121 [[nodiscard]] float rotation() const {
122 return currentRotation_;
123 }
124
125 /**
126 * @brief Sets the current accumulated rotation.
127 *
128 * @param currentRotation The new rotation angle in degrees.
129 */
130 void setRotation(float currentRotation) {
131 currentRotation_ = currentRotation;
132 }
133 };
134
135}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.