Skip to content

Commit

Permalink
fix(transform): make global getters const
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoMendonc-a committed Feb 27, 2024
1 parent f11d19c commit bc3df3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ 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

- Crash in multiple samples due to missing plugin dependencies (**@RiscadoA**).
- 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

Expand Down
6 changes: 3 additions & 3 deletions engine/include/cubos/engine/transform/local_to_world.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions engine/src/transform/local_to_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

0 comments on commit bc3df3b

Please sign in to comment.