12 void Transform::UpdateTransform() {
15 for (
const auto entity : view1) {
16 UpdateTransformRecursive(entity, glm::mat3(1.0f), 1,
false,
false);
21 void Transform::UpdateTransformRecursive(entt::entity entity,
const glm::mat3& parentTransform,
const uint8_t parentDepth,
const bool parentTransformDirty,
const bool parentDepthDirty) {
23 const bool transformDirty = transform.m_DirtyTransform || parentTransformDirty;
24 const bool layerDirty = transform.m_DirtyDepth || parentDepthDirty;
27 if (!transform.GetDetachedState()) {
28 transform.m_WorldTransform = parentTransform * transform.GetLocalTransform();
29 transform.m_LastParentTransform = parentTransform;
31 transform.m_WorldTransform = transform.m_LastParentTransform * transform.GetLocalTransform();
33 transform.m_DirtyTransform =
false;
36 int16_t unclamped = parentDepth + transform.GetLocalDepthOffset();
37 if (unclamped < 0 || unclamped > 255) {
38 uint8_t clamped =
static_cast<uint8_t
>(std::clamp(unclamped,
static_cast<int16_t
>(0),
static_cast<int16_t
>(255)));
40 transform.m_WorldDepth = clamped;
41 transform.m_DirtyDepth =
false;
43 transform.m_WorldDepth =
static_cast<uint8_t
>(unclamped);
44 transform.m_DirtyDepth =
false;
47 const auto& hierarchy =
m_Owner.GetRegistry().get<Components::Entity::Hierarchy>(entity);
48 entt::entity currentChild = hierarchy.m_FirstChild;
49 while (
m_Owner.GetRegistry().valid(currentChild)) {
50 UpdateTransformRecursive(currentChild, transform.m_WorldTransform, transform.m_WorldDepth, transformDirty, layerDirty);
51 currentChild =
m_Owner.GetRegistry().get<Components::Entity::Hierarchy>(currentChild).m_NextSibling;
61 void Transform::OnTransformCreate(entt::registry& registry, entt::entity entity) {
62 Entity e = entt::handle{ registry, entity };
#define CORI_CORE_WARN_TAGGED(...)
#define CORI_PROFILE_FUNCTION()
A GameTimer is responsible for managing everything that is connected with time, ticks,...
Entities are the essential part of WorldSystem.
decltype(auto) GetComponents()
Retries the references to the requested components of the entity.
entt::registry & GetRegistry()
Retrieves the EnTT registry.
Anything connected to WorldSystem (ECS) is in this namespace.