Debug render aabb now include node, mesh and static aabb. (#6685)

Signed-off-by: rhhong <rhhong@amazon.com>
This commit is contained in:
Roman
2022-01-05 12:54:41 -08:00
committed by GitHub
parent 89067fe667
commit 55fb63da48
4 changed files with 59 additions and 6 deletions
@@ -63,7 +63,10 @@ namespace AZ::Render
// Render aabb
if (renderFlags[EMotionFX::ActorRenderFlag::RENDER_AABB])
{
RenderAABB(instance, renderActorSettings.m_staticAABBColor);
RenderAABB(instance,
renderActorSettings.m_enabledNodeBasedAabb, renderActorSettings.m_nodeAABBColor,
renderActorSettings.m_enabledMeshBasedAabb, renderActorSettings.m_meshAABBColor,
renderActorSettings.m_enabledStaticBasedAabb, renderActorSettings.m_staticAABBColor);
}
// Render simple line skeleton
@@ -201,11 +204,46 @@ namespace AZ::Render
return AzFramework::DebugDisplayRequestBus::FindFirstHandler(debugDisplayBus);
}
void AtomActorDebugDraw::RenderAABB(EMotionFX::ActorInstance* instance, const AZ::Color& aabbColor)
void AtomActorDebugDraw::RenderAABB(EMotionFX::ActorInstance* instance,
bool enableNodeAabb,
const AZ::Color& nodeAabbColor,
bool enableMeshAabb,
const AZ::Color& meshAabbColor,
bool enableStaticAabb,
const AZ::Color& staticAabbColor)
{
RPI::AuxGeomDrawPtr auxGeom = m_auxGeomFeatureProcessor->GetDrawQueue();
const AZ::Aabb& aabb = instance->GetAabb();
auxGeom->DrawAabb(aabb, aabbColor, RPI::AuxGeomDraw::DrawStyle::Line);
if (enableNodeAabb)
{
AZ::Aabb aabb;
instance->CalcNodeBasedAabb(&aabb);
if (aabb.IsValid())
{
auxGeom->DrawAabb(aabb, nodeAabbColor, RPI::AuxGeomDraw::DrawStyle::Line);
}
}
if (enableMeshAabb)
{
AZ::Aabb aabb;
const size_t lodLevel = instance->GetLODLevel();
instance->CalcMeshBasedAabb(lodLevel, &aabb);
if (aabb.IsValid())
{
auxGeom->DrawAabb(aabb, meshAabbColor, RPI::AuxGeomDraw::DrawStyle::Line);
}
}
if (enableStaticAabb)
{
AZ::Aabb aabb;
instance->CalcStaticBasedAabb(&aabb);
if (aabb.IsValid())
{
auxGeom->DrawAabb(aabb, staticAabbColor, RPI::AuxGeomDraw::DrawStyle::Line);
}
}
}
void AtomActorDebugDraw::RenderLineSkeleton(EMotionFX::ActorInstance* instance, const AZ::Color& skeletonColor)
@@ -49,7 +49,13 @@ namespace AZ::Render
void PrepareForMesh(EMotionFX::Mesh* mesh, const AZ::Transform& worldTM);
AzFramework::DebugDisplayRequests* GetDebugDisplay(AzFramework::ViewportId viewportId);
void RenderAABB(EMotionFX::ActorInstance* instance, const AZ::Color& aabbColor);
void RenderAABB(EMotionFX::ActorInstance* instance,
bool enableNodeAabb,
const AZ::Color& nodeAabbColor,
bool enableMeshAabb,
const AZ::Color& meshAabbColor,
bool enableStaticAabb,
const AZ::Color& staticAabbColor);
void RenderLineSkeleton(EMotionFX::ActorInstance* instance, const AZ::Color& skeletonColor);
void RenderSkeleton(EMotionFX::ActorInstance* instance, const AZ::Color& skeletonColor);
void RenderEMFXDebugDraw(EMotionFX::ActorInstance* instance);
@@ -1071,6 +1071,8 @@ namespace EMStudio
settings.m_mirroredBitangentsColor = m_mirroredBitangentsColor;
settings.m_bitangentsColor = m_bitangentsColor;
settings.m_wireframeColor = m_wireframeColor;
settings.m_nodeAABBColor = m_nodeAABBColor;
settings.m_meshAABBColor = m_meshAABBColor;
settings.m_staticAABBColor = m_staticAABBColor;
settings.m_skeletonColor = m_skeletonColor;
settings.m_lineSkeletonColor = m_lineSkeletonColor;
@@ -28,6 +28,10 @@ namespace AZ::Render
float m_wireframeScale = 1.0f;
float m_nodeOrientationScale = 1.0f;
bool m_enabledNodeBasedAabb = true;
bool m_enabledMeshBasedAabb = true;
bool m_enabledStaticBasedAabb = true;
AZ::Color m_hitDetectionColliderColor{0.44f, 0.44f, 0.44f, 1.0f};
AZ::Color m_selectedHitDetectionColliderColor{ 0.3f, 0.56f, 0.88f, 1.0f };
AZ::Color m_ragdollColliderColor{ 0.44f, 0.44f, 0.44f, 1.0f };
@@ -44,9 +48,12 @@ namespace AZ::Render
AZ::Color m_mirroredBitangentsColor{ 1.0f, 1.0f, 0.0f, 1.0f };
AZ::Color m_bitangentsColor{ 1.0f, 1.0f, 1.0f, 1.0f };
AZ::Color m_wireframeColor{ 0.0f, 0.0f, 0.0f, 1.0f };
AZ::Color m_staticAABBColor{ 0.0f, 0.7f, 0.7f, 1.0f };
AZ::Color m_lineSkeletonColor{ 0.33333f, 1.0f, 0.0f, 1.0f };
AZ::Color m_skeletonColor{ 0.19f, 0.58f, 0.19f, 1.0f };
AZ::Color m_jointNameColor{ 1.0f, 1.0f, 1.0f, 1.0f };
AZ::Color m_nodeAABBColor{ 1.0f, 0.0f, 0.0f, 1.0f };
AZ::Color m_meshAABBColor{ 0.0f, 0.0f, 0.7f, 1.0f };
AZ::Color m_staticAABBColor{ 0.0f, 0.7f, 0.7f, 1.0f };
};
} // namespace AZ::Render