Skip to main content

Transform.ixx File

Represents a 3D transformation consisting of translation, rotation and scale. More...

Included Headers

#include <helios.math.transform> #include <helios.math.types>

Namespaces Index

namespacehelios
namespaceengine
namespacecore
namespacespatial

Classes Index

classTransform

Represents a 3D transformation consisting of translation, rotation and scale. More...

Description

Represents a 3D transformation consisting of translation, rotation and scale.

File Listing

The file content with the documentation metadata removed is:

1
6module;
7
8
9export module helios.engine.core.spatial.Transform;
10
11import helios.math.types;
12import helios.math.transform;
13
14
16
29 class Transform {
30
31 private:
36 mutable bool needsUpdate_ = true;
37
41 helios::math::mat4f rotation_ = helios::math::mat4f::identity();
42
46 helios::math::vec3f scale_ = helios::math::vec3f(1);
47
51 helios::math::vec3f translation_ = helios::math::vec3f(0);
52
57 mutable helios::math::mat4f cached_ = helios::math::mat4f::identity();
58
65 helios::math::mat4f updateCache() const {
66 needsUpdate_ = false;
67 return math::translate(
68 helios::math::mat4f::identity(),
69 translation_) *
70 (rotation_ * helios::math::mat4f(scale_)
71 );
72 }
73
74 public:
75 ~Transform() = default;
76
81 Transform() = default;
82
90 Transform(const helios::math::mat4f& rotation,
91 helios::math::vec3f scale,
92 helios::math::vec3f translation
93 ) noexcept :
94 rotation_(rotation),
95 scale_(scale),
96 translation_(translation),
97 needsUpdate_(true)
98 {}
99
106 void setRotation(const math::mat4f& rotation) noexcept {
107 rotation_ = rotation;
108 needsUpdate_ = true;
109 }
110
117 void setTranslation(const math::vec3f& translation) noexcept {
118 translation_ = translation;
119 needsUpdate_ = true;
120 }
121
128 void setScale(const math::vec3f& scale) noexcept {
129 scale_ = scale;
130 needsUpdate_ = true;
131 }
132
138 [[nodiscard]] helios::math::mat4f rotation() const noexcept {
139 return rotation_;
140 }
141
147 [[nodiscard]] helios::math::vec3f translation() const noexcept {
148 return translation_;
149 }
150
156 [[nodiscard]] helios::math::vec3f scaling() const noexcept {
157 return scale_;
158 }
159
165 [[nodiscard]] helios::math::mat4f transform() const noexcept {
166 if (needsUpdate_) {
167 cached_ = updateCache();
168 }
169 return cached_;
170 }
171
180 return needsUpdate_;
181 }
182
183 };
184
185};

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.