Skip to main content

ScaleStateComponent.ixx File

Component for managing the dimensions of an entity. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

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

namespacemodules

Domain-specific components and systems. More...

namespacespatial
namespacetransform

Transform components and systems for spatial state management. More...

namespacecomponents

Transform state components for spatial management. More...

Classes Index

classScaleStateComponent

Component that defines the physical dimensions (scale) of an entity. More...

Description

Component for managing the dimensions of an entity.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file ScaleStateComponent.ixx
3 * @brief Component for managing the dimensions of an entity.
4 */
5module;
6
7export module helios.engine.modules.spatial.transform.components.ScaleStateComponent;
8
9import helios.engine.ecs.GameObject;
10import helios.math.types;
11
12import helios.core.spatial.Transform;
13import helios.core.units.Unit;
14
15
17
18 /**
19 * @brief Component that defines the physical dimensions (scale) of an entity.
20 *
21 * @details
22 * This component stores the width, height, and depth of an entity, along with the
23 * unit of measurement. It tracks changes via a dirty flag, allowing other systems
24 * to react to scale updates.
25 */
27 /**
28 * @brief Width of the entity.
29 */
30 float width_;
31
32 /**
33 * @brief Height of the entity.
34 */
35 float height_;
36
37 /**
38 * @brief Depth of the entity.
39 */
40 float depth_;
41
42 /**
43 * @brief Unit of measurement for the dimensions.
44 */
46
47 /**
48 * @brief Flag indicating if the scale has changed.
49 */
50 bool isDirty_ = true;
51
52 /**
53 * @brief Whether this component is enabled.
54 */
55 bool isEnabled_ = true;
56
57 public:
58
59 /**
60 * @brief Checks whether this component is enabled.
61 *
62 * @return True if enabled, false otherwise.
63 */
64 [[nodiscard]] bool isEnabled() const noexcept {
65 return isEnabled_;
66 }
67
68 /**
69 * @brief Enables this component.
70 */
71 void enable() noexcept {
72 isEnabled_ = true;
73 }
74
75 /**
76 * @brief Disables this component.
77 */
78 void disable() noexcept {
79 isEnabled_ = false;
80 }
81
82 /**
83 * @brief Constructs a ScaleStateComponent with specified dimensions and unit.
84 *
85 * @param width Width of the entity.
86 * @param height Height of the entity.
87 * @param depth Depth of the entity.
88 * @param unit Unit of measurement (default: Meter).
89 */
90 explicit ScaleStateComponent(const float width, const float height, const float depth, const helios::core::units::Unit unit) :
91 width_(width), height_(height), depth_(depth), unit_(unit) {}
92
94 width_(scale[0]), height_(scale[1]), depth_(scale[2]), unit_(unit) {}
95
96 /**
97 * @brief Copy constructor.
98 *
99 * @param other The component to copy from.
100 */
102 width_(other.width_),
103 height_(other.height_),
104 depth_(other.depth_),
105 unit_(other.unit_),
106 isDirty_(true) {}
107
110 ScaleStateComponent& operator=(ScaleStateComponent&&) noexcept = default;
111
112
113
114
115 /**
116 * @brief Resets the dirty flag to true when acquired.
117 *
118 * Makes sure scaling is considered once the component was acquired.
119 */
120 void onAcquire() noexcept {
121 isDirty_ = true;
122 }
123
124 /**
125 * @brief Resets the dirty flag to true when released.
126 *
127 * Makes sure the entities dirty-state is reset to the default state.
128 */
129 void onRelease() noexcept {
130 isDirty_ = true;
131 }
132
133 /**
134 * @brief Clears the dirty flag.
135 */
136 void clearDirty() noexcept {
137 isDirty_ = false;
138 }
139
140 /**
141 * @brief Checks if the scale has changed.
142 *
143 * @return True if dirty, false otherwise.
144 */
145 [[nodiscard]] bool isDirty() const noexcept {
146 return isDirty_;
147 }
148
149
150 /**
151 * @brief Retrieves the unit of measurement.
152 *
153 * @return The unit enum value.
154 */
155 [[nodiscard]] helios::core::units::Unit unit() const noexcept {
156 return unit_;
157 }
158
159 /**
160 * @brief Retrieves the scaling vector (width, height, depth).
161 *
162 * @return A vec3f containing the dimensions.
163 */
164 [[nodiscard]] helios::math::vec3f scaling() const noexcept {
165 return {width_, height_, depth_};
166 }
167
168 /**
169 * @brief Sets the dimensions and unit of the entity.
170 *
171 * @param width New width.
172 * @param height New height.
173 * @param depth New depth.
174 * @param unit New unit of measurement (default: Meter).
175 */
176 void setScale(const float width, const float height, const float depth,
178 ) noexcept {
179
180 width_ = width;
181 height_ = height;
182 depth_ = depth;
183 unit_ = unit;
184 isDirty_ = true;
185
186 };
187
188
189 };
190
191}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.