Added missing transpose to transform update and a test component to application
This commit is contained in:
parent
2c0fa3a6b2
commit
6d646851e2
|
@ -8,6 +8,7 @@
|
|||
#include "Scene/SHSceneManager.h"
|
||||
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
||||
#include "Scripting/SHScriptEngine.h"
|
||||
#include "Math/Transform/SHTransformComponent.h"
|
||||
|
||||
using namespace SHADE;
|
||||
|
||||
|
@ -38,11 +39,15 @@ namespace Sandbox
|
|||
auto matInst = graphicsSystem->AddMaterialInstance();
|
||||
|
||||
// Create entity and add mesh
|
||||
testObj = SHADE::SHEntityManager::CreateEntity<SHADE::SHRenderable>();
|
||||
testObj = SHADE::SHEntityManager::CreateEntity<SHADE::SHRenderable, SHADE::SHTransformComponent>();
|
||||
auto& renderable = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHRenderable>(testObj);
|
||||
renderable.Mesh = CUBE_MESH;
|
||||
renderable.SetMaterial(matInst);
|
||||
renderable.TransformMatrix.Translate(0.0f, 0.0f, 2.0f);
|
||||
// Create transform
|
||||
auto& transform = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHTransformComponent>(testObj);
|
||||
transform.SetLocalPosition(SHVec3{ 0.0f, 0.0f, 2.0f });
|
||||
|
||||
renderable.TransformMatrix = SHMatrix::Translate(0.0f, 0.0f, 2.0f);
|
||||
SHADE::SHScriptEngine* scriptEngine = static_cast<SHADE::SHScriptEngine*>(SHADE::SHSystemManager::GetSystem<SHADE::SHScriptEngine>());
|
||||
scriptEngine->AddScript(*SHADE::SHEntityManager::GetEntityByID(testObj), "TestScript");
|
||||
}
|
||||
|
|
|
@ -74,11 +74,9 @@ namespace SHADE
|
|||
SHASSERT(IS_NODE_ACTIVE == IS_ENTITY_ACTIVE, "Entity and Node active states are not synced!")
|
||||
#endif
|
||||
|
||||
// Anything below is inactive
|
||||
if (!IS_NODE_ACTIVE)
|
||||
{
|
||||
UpdateEntity(child);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
const bool HAS_TRANSFORM = SHComponentManager::HasComponent<SHTransformComponent>(child->GetEntityID());
|
||||
if (!HAS_TRANSFORM)
|
||||
|
@ -104,7 +102,7 @@ namespace SHADE
|
|||
if (parent)
|
||||
{
|
||||
localToWorld = parent->GetTRS();
|
||||
worldToLocal = SHMatrix::Inverse(tf.local.trs);
|
||||
worldToLocal = SHMatrix::Inverse(localToWorld);
|
||||
}
|
||||
|
||||
while (!tf.updateQueue.empty())
|
||||
|
@ -148,6 +146,10 @@ namespace SHADE
|
|||
tf.world.scale = tf.local.scale * (parent ? parent->GetLocalScale() : SHVec3::One);
|
||||
|
||||
tf.world.ComputeTRS();
|
||||
|
||||
// Transpose TRS to column major
|
||||
tf.local.trs.Transpose();
|
||||
tf.world.trs.Transpose();
|
||||
}
|
||||
|
||||
} // namespace SHADE
|
Loading…
Reference in New Issue