EMotion FX: Update skeleton transforms when either solid mesh rendering or any of the debug visualizations is enabled (#7747)
* Disabled depth testing for joint orientation debug rendering, so that we can also see them through the solid mesh rendering. * Update transforms in case solid mesh rendering or any of the debug visualizations are enabled. Signed-off-by: Benjamin Jillich <jillich@amazon.com>
This commit is contained in:
@@ -758,6 +758,9 @@ namespace AZ::Render
|
||||
EMotionFX::JointSelectionRequestBus::BroadcastResult(
|
||||
cachedSelectedJointIndices, &EMotionFX::JointSelectionRequests::FindSelectedJointIndices, actorInstance);
|
||||
|
||||
const int oldState = debugDisplay->GetState();
|
||||
debugDisplay->DepthTestOff();
|
||||
|
||||
const size_t numEnabled = actorInstance->GetNumEnabledNodes();
|
||||
for (size_t i = 0; i < numEnabled; ++i)
|
||||
{
|
||||
@@ -774,6 +777,8 @@ namespace AZ::Render
|
||||
}
|
||||
RenderLineAxis(debugDisplay, worldTM, size, selected);
|
||||
}
|
||||
|
||||
debugDisplay->SetState(oldState);
|
||||
}
|
||||
|
||||
void AtomActorDebugDraw::RenderLineAxis(
|
||||
|
||||
@@ -569,17 +569,20 @@ namespace EMotionFX
|
||||
m_renderActorInstance->OnTick(deltaTime);
|
||||
m_renderActorInstance->UpdateBounds();
|
||||
AZ::Interface<AzFramework::IEntityBoundsUnion>::Get()->RefreshEntityLocalBoundsUnion(GetEntityId());
|
||||
|
||||
const bool isInCameraFrustum = m_renderActorInstance->IsInCameraFrustum();
|
||||
const bool renderActorSolid = AZ::RHI::CheckBitsAny(m_configuration.m_renderFlags, ActorRenderFlags::Solid);
|
||||
m_renderActorInstance->SetIsVisible(isInCameraFrustum && renderActorSolid);
|
||||
|
||||
// Optimization: Set the actor instance invisible when character is out of camera view. This will stop the joint transforms update, except the root joint.
|
||||
// Calling it after the bounds on the render actor updated.
|
||||
if (!m_configuration.m_forceUpdateJointsOOV)
|
||||
{
|
||||
const bool isInCameraFrustum = m_renderActorInstance->IsInCameraFrustum();
|
||||
m_actorInstance->SetIsVisible(isInCameraFrustum && renderActorSolid);
|
||||
// Update the skeleton in case solid mesh rendering or any of the debug visualizations are enabled and the character is in the camera frustum.
|
||||
const bool updateTransforms = AZ::RHI::CheckBitsAny(m_configuration.m_renderFlags, s_requireUpdateTransforms);
|
||||
m_actorInstance->SetIsVisible(isInCameraFrustum && updateTransforms);
|
||||
}
|
||||
|
||||
m_renderActorInstance->SetIsVisible(renderActorSolid);
|
||||
m_renderActorInstance->DebugDraw(m_configuration.m_renderFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,14 @@ namespace EMotionFX
|
||||
|
||||
AZ_DEFINE_ENUM_BITWISE_OPERATORS(ActorRenderFlags);
|
||||
|
||||
static constexpr ActorRenderFlags s_requireUpdateTransforms =
|
||||
ActorRenderFlags::Solid | ActorRenderFlags::Wireframe | ActorRenderFlags::AABB |
|
||||
ActorRenderFlags::FaceNormals |ActorRenderFlags::VertexNormals | ActorRenderFlags::Tangents |
|
||||
ActorRenderFlags::Skeleton | ActorRenderFlags::LineSkeleton | ActorRenderFlags::NodeOrientation | ActorRenderFlags::NodeNames |
|
||||
ActorRenderFlags::RagdollColliders | ActorRenderFlags::RagdollJointLimits | ActorRenderFlags::HitDetectionColliders |
|
||||
ActorRenderFlags::ClothColliders | ActorRenderFlags::SimulatedObjectColliders | ActorRenderFlags::SimulatedJoints |
|
||||
ActorRenderFlags::EmfxDebug;
|
||||
|
||||
class ActorRenderFlagUtil
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user