diff --git a/CHANGELOG.md b/CHANGELOG.md index 42ec31e18..583a956f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed Time Step plugin (#989, **@joaomanita**). - New feature guide focused on queries (#995, **@RiscadoA**). - ECS Statistics tesseratos plugin (#1024, **@RiscadoA**). +- Global position, rotation and scale getters (#1002, **@DiogoMendonc-a**) ### Fixed @@ -24,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Cursor offset in tesseratos when on retina displays (#998, **@diogomsmiranda**). - Random failures in the ECS stress test (#948, **@RiscadoA**). - System condition being ignored by Cubos (#1032, **@RiscadoA**). +- Wrong tranform gizmo position for entities with parents (#1003, **@DiogoMendonc-a**) ## [v0.1.0] - 2024-02-17 diff --git a/engine/include/cubos/engine/transform/local_to_world.hpp b/engine/include/cubos/engine/transform/local_to_world.hpp index 6c2bac7e9..4932a983b 100644 --- a/engine/include/cubos/engine/transform/local_to_world.hpp +++ b/engine/include/cubos/engine/transform/local_to_world.hpp @@ -28,15 +28,15 @@ namespace cubos::engine /// @brief Gets global position of the entity. /// @return Position vector in world space. - glm::vec3 worldPosition(); + glm::vec3 worldPosition() const; /// @brief Gets global rotation of the entity. /// @return Rotation quaternion in world space. - glm::quat worldRotation(); + glm::quat worldRotation() const; /// @brief Gets global scale of the entity. /// @return Scale value in world space. - float worldScale(); + float worldScale() const; }; } // namespace cubos::engine diff --git a/engine/src/transform/local_to_world.cpp b/engine/src/transform/local_to_world.cpp index 07ad51ec1..4697a072c 100644 --- a/engine/src/transform/local_to_world.cpp +++ b/engine/src/transform/local_to_world.cpp @@ -13,17 +13,17 @@ CUBOS_REFLECT_IMPL(cubos::engine::LocalToWorld) .build(); } -glm::vec3 cubos::engine::LocalToWorld::worldPosition() +glm::vec3 cubos::engine::LocalToWorld::worldPosition() const { return mat[3]; } -glm::quat cubos::engine::LocalToWorld::worldRotation() +glm::quat cubos::engine::LocalToWorld::worldRotation() const { return glm::toQuat(glm::mat3(mat) / worldScale()); } -float cubos::engine::LocalToWorld::worldScale() +float cubos::engine::LocalToWorld::worldScale() const { return glm::length(mat[0]); } \ No newline at end of file