Skip to main content

TranslationStateComponent.ixx File

Component for storing the current translation (position) state of an entity. More...

Included Headers

#include <cmath> #include <helios.math>

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

classTranslationStateComponent

Component that holds the current translation (position) state. More...

Description

Component for storing the current translation (position) state of an entity.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file TranslationStateComponent.ixx
3 * @brief Component for storing the current translation (position) state of an entity.
4 */
5module;
6
7#include <cmath>
8
9export module helios.engine.modules.spatial.transform.components.TranslationStateComponent;
10
11
12
13import helios.math;
14
16
17 /**
18 * @brief Component that holds the current translation (position) state.
19 *
20 * @details
21 * This component stores the accumulated translation vector. It acts as a data
22 * container for the ComposeTransformSystem to build the final translation matrix.
23 * It separates the raw position data from the computed ComposeTransformComponent.
24 */
26
27 /**
28 * @brief The current translation vector.
29 */
30 helios::math::vec3f translation_{};
31
32 /**
33 * @brief Whether this component is enabled.
34 */
35 bool isEnabled_ = true;
36
37 public:
38
39 /**
40 * @brief Checks whether this component is enabled.
41 *
42 * @return True if enabled, false otherwise.
43 */
44 [[nodiscard]] bool isEnabled() const noexcept {
45 return isEnabled_;
46 }
47
48 /**
49 * @brief Enables this component.
50 */
51 void enable() noexcept {
52 isEnabled_ = true;
53 }
54
55 /**
56 * @brief Disables this component.
57 */
58 void disable() noexcept {
59 isEnabled_ = false;
60 }
61
62 /**
63 * @brief Default constructor.
64 */
66
67 /**
68 * @brief Copy constructor.
69 *
70 * @param other The component to copy from.
71 */
73 translation_(other.translation_){
74 }
75
76 /**
77 * @brief Copy assignment operator.
78 */
80
81 /**
82 * @brief Move constructor.
83 */
85
86 /**
87 * @brief Move assignment operator.
88 */
89 TranslationStateComponent& operator=(TranslationStateComponent&&) noexcept = default;
90
91 /**
92 * @brief Creates a new TranslationStateComponent with the specified translation vector.
93 *
94 * @param translation The translation vector this component should be initialized with.
95 */
97 translation_(translation) {}
98
99 /**
100 * @brief Resets the translation vector to 0-vector when acquired.
101 */
102 void onAcquire() noexcept{
103 translation_ = helios::math::vec3f{};
104 }
105
106
107 /**
108 * @brief Resets the translation vector to 0-vector when released.
109 */
110 void onRelease() noexcept {
111 translation_ = helios::math::vec3f{};
112 }
113
114 /**
115 * @brief Sets the absolute translation.
116 *
117 * @param translation The new position vector.
118 */
120 translation_ = translation;
121 }
122
123 /**
124 * @brief Translates the current position by a delta vector.
125 *
126 * @param translation The vector to add to the current position.
127 */
129 translation_ = translation_ + translation;
130 }
131
132 /**
133 * @brief Returns the current translation vector.
134 *
135 * @return The current position.
136 */
137 [[nodiscard]] helios::math::vec3f translation() const noexcept {
138 return translation_;
139 }
140 };
141
142};

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.