Reflect transform component
This commit is contained in:
parent
247930ea68
commit
2c16eb4393
|
@ -30,10 +30,11 @@ project "SHADE_Application"
|
|||
|
||||
externalincludedirs
|
||||
{
|
||||
"%{IncludeDir.spdlog}/include",
|
||||
"%{IncludeDir.VULKAN}/include",
|
||||
"%{IncludeDir.VMA}/include",
|
||||
"%{IncludeDir.VULKAN}/Source/SPIRV-Reflect"
|
||||
"%{IncludeDir.spdlog}/include",
|
||||
"%{IncludeDir.VULKAN}/include",
|
||||
"%{IncludeDir.VMA}/include",
|
||||
"%{IncludeDir.VULKAN}/Source/SPIRV-Reflect",
|
||||
"%{IncludeDir.RTTR}/include"
|
||||
}
|
||||
|
||||
externalwarnings "Off"
|
||||
|
|
|
@ -181,4 +181,15 @@ namespace SHADE
|
|||
updateQueue.push({ UpdateCommandType::WORLD_SCALE, newWorldScale });
|
||||
}
|
||||
|
||||
} // namespace SHADE
|
||||
} // namespace SHADE
|
||||
|
||||
RTTR_REGISTRATION
|
||||
{
|
||||
using namespace SHADE;
|
||||
using namespace rttr;
|
||||
|
||||
registration::class_<SHTransformComponent>("Transform Component")
|
||||
.property("Translate", &SHTransformComponent::GetLocalPosition, &SHTransformComponent::SetLocalPosition)
|
||||
.property("Rotate", &SHTransformComponent::GetLocalRotation, select_overload<void(SHVec3 const&)>(&SHTransformComponent::SetLocalRotation))
|
||||
.property("Scale", &SHTransformComponent::GetLocalScale, &SHTransformComponent::SetLocalScale);
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <queue>
|
||||
|
||||
#include <rttr/registration>
|
||||
// Project Headers
|
||||
#include "SH_API.h"
|
||||
#include "ECS_Base/Components/SHComponent.h"
|
||||
|
@ -116,6 +117,8 @@ namespace SHADE
|
|||
SHTransform world;
|
||||
|
||||
UpdateQueue updateQueue;
|
||||
|
||||
RTTR_ENABLE()
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -66,27 +66,23 @@ namespace SHADE
|
|||
|
||||
for (const auto* child : node->GetChildren())
|
||||
{
|
||||
|
||||
|
||||
|
||||
const bool HAS_TRANSFORM = SHComponentManager::HasComponent<SHTransformComponent>(child->GetEntityID());
|
||||
if (!HAS_TRANSFORM)
|
||||
continue;
|
||||
|
||||
auto* childTransform = SHComponentManager::GetComponent<SHTransformComponent>(child->GetEntityID());
|
||||
|
||||
// Only update if node in hierarchy and component are both active
|
||||
const bool IS_NODE_ACTIVE = child->IsActive();
|
||||
if (IS_NODE_ACTIVE && childTransform->isActive)
|
||||
auto* childTransform = SHComponentManager::GetComponent_s<SHTransformComponent>(child->GetEntityID());
|
||||
if (childTransform)
|
||||
{
|
||||
if (childTransform->dirty || HAS_PARENT_CHANGED)
|
||||
UpdateTransform(*childTransform, NODE_TRANSFORM);
|
||||
// Only update if node in hierarchy and component are both active
|
||||
const bool IS_NODE_ACTIVE = child->IsActive();
|
||||
if (IS_NODE_ACTIVE && childTransform->isActive)
|
||||
{
|
||||
if (childTransform->dirty || HAS_PARENT_CHANGED)
|
||||
UpdateTransform(*childTransform, NODE_TRANSFORM);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateEntity(child);
|
||||
|
||||
// Clear dirty flag after all children are updated
|
||||
childTransform->dirty = false;
|
||||
if (childTransform)
|
||||
childTransform->dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,8 +140,8 @@ namespace SHADE
|
|||
tf.world.ComputeTRS();
|
||||
|
||||
// Transpose TRS to column major
|
||||
tf.local.trs.Transpose();
|
||||
tf.world.trs.Transpose();
|
||||
//tf.local.trs.Transpose();
|
||||
//tf.world.trs.Transpose();
|
||||
}
|
||||
|
||||
} // namespace SHADE
|
Loading…
Reference in New Issue