Added missing active check in transform system
This commit is contained in:
parent
415e47780c
commit
14eed4c726
|
@ -16,6 +16,8 @@
|
|||
// Project Headers
|
||||
#include "Scene/SHSceneManager.h"
|
||||
#include "ECS_Base/Managers/SHComponentManager.h"
|
||||
#include "ECS_Base/Managers/SHEntityManager.h"
|
||||
#include "Tools/SHException.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -35,8 +37,8 @@ namespace SHADE
|
|||
void SHTransformSystem::Execute(double dt) noexcept
|
||||
{
|
||||
// Get the current scene graph to traverse and update
|
||||
auto& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
|
||||
UpdateEntity(sceneGraph.GetRoot());
|
||||
const auto& SCENE_GRAPH = SHSceneManager::GetCurrentSceneGraph();
|
||||
UpdateEntity(SCENE_GRAPH.GetRoot());
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
@ -50,6 +52,20 @@ namespace SHADE
|
|||
|
||||
for (const auto* child : node->GetChildren())
|
||||
{
|
||||
// Active states of entities should sync with scene nodes
|
||||
const bool IS_NODE_ACTIVE = child->isActive;
|
||||
|
||||
#ifdef _DEBUG
|
||||
const bool IS_ENTITY_ACTIVE = SHEntityManager::GetEntityByID(child->GetEntityID())->GetActive();
|
||||
SHASSERT(IS_NODE_ACTIVE == IS_ENTITY_ACTIVE, "Entity and Node active states are not synced!")
|
||||
#endif
|
||||
|
||||
if (!IS_NODE_ACTIVE)
|
||||
{
|
||||
UpdateEntity(child);
|
||||
continue;
|
||||
}
|
||||
|
||||
const bool HAS_TRANSFORM = SHComponentManager::HasComponent<SHTransformComponent>(child->GetEntityID());
|
||||
if (!HAS_TRANSFORM)
|
||||
continue;
|
||||
|
@ -61,13 +77,14 @@ namespace SHADE
|
|||
|
||||
UpdateEntity(child);
|
||||
|
||||
// Clear dirty flag after all children are updated
|
||||
childTransform->dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SHTransformSystem::UpdateTransform(SHTransformComponent& tf, const SHTransformComponent* parent)
|
||||
{
|
||||
SHMatrix localToWorld = SHMatrix::Identity;
|
||||
SHMatrix localToWorld = SHMatrix::Identity;
|
||||
SHMatrix worldToLocal = SHMatrix::Identity;
|
||||
|
||||
if (parent)
|
||||
|
@ -103,7 +120,8 @@ namespace SHADE
|
|||
|
||||
break;
|
||||
}
|
||||
default: break; // Redundant
|
||||
// Redundant
|
||||
default: break;
|
||||
}
|
||||
|
||||
tf.updateQueue.pop();
|
||||
|
|
Loading…
Reference in New Issue