From adab3cbc9301eef512592a3f73c0235c0fb3d996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 3 May 2018 13:33:29 +0200 Subject: [PATCH] Sdk/DebugSystem: Fix OBB not taking offset in account --- SDK/src/NDK/Systems/DebugSystem.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/SDK/src/NDK/Systems/DebugSystem.cpp b/SDK/src/NDK/Systems/DebugSystem.cpp index 1b5634eaf..182191f7d 100644 --- a/SDK/src/NDK/Systems/DebugSystem.cpp +++ b/SDK/src/NDK/Systems/DebugSystem.cpp @@ -62,9 +62,11 @@ namespace Ndk const DebugComponent& entityDebug = m_entityOwner->GetComponent(); const GraphicsComponent& entityGfx = m_entityOwner->GetComponent(); + Nz::Boxf aabb = entityGfx.GetBoundingVolume().aabb; + Nz::Matrix4f transformMatrix = Nz::Matrix4f::Identity(); - transformMatrix.SetScale(entityGfx.GetBoundingVolume().aabb.GetLengths()); - transformMatrix.SetTranslation(entityGfx.GetBoundingVolume().aabb.GetCenter()); + transformMatrix.SetScale(aabb.GetLengths()); + transformMatrix.SetTranslation(aabb.GetCenter()); renderQueue->AddMesh(0, m_material, m_meshData, Nz::Boxf::Zero(), transformMatrix, scissorRect); } @@ -82,8 +84,13 @@ namespace Ndk const DebugComponent& entityDebug = m_entityOwner->GetComponent(); const GraphicsComponent& entityGfx = m_entityOwner->GetComponent(); + Nz::Boxf obb = entityGfx.GetBoundingVolume().obb.localBox; + Nz::Matrix4f transformMatrix = instanceData.transformMatrix; - transformMatrix.ApplyScale(entityGfx.GetBoundingVolume().obb.localBox.GetLengths()); + Nz::Vector3f obbCenter = transformMatrix.Transform(obb.GetCenter(), 0.f); //< Apply rotation/scale to obb center, to display it at a correct position + + transformMatrix.ApplyScale(obb.GetLengths()); + transformMatrix.ApplyTranslation(obbCenter); renderQueue->AddMesh(0, m_material, m_meshData, Nz::Boxf::Zero(), transformMatrix, scissorRect); }