Change actorRenderFlag to use AZ ENUM CLASS instead of azstd::bitset (#7542)
* Fixes the problem with using actor render flags in actor component Signed-off-by: rhhong <rhhong@amazon.com> * In progress work for actor render flag rework Signed-off-by: rhhong <rhhong@amazon.com> * add an utlity function to check bit Signed-off-by: rhhong <rhhong@amazon.com> * code cleanup Signed-off-by: rhhong <rhhong@amazon.com> * More CR cleanup Signed-off-by: rhhong <rhhong@amazon.com> * build fix Signed-off-by: rhhong <rhhong@amazon.com> * CR feedback Signed-off-by: rhhong <rhhong@amazon.com>
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Preprocessor/EnumReflectUtils.h>
|
||||
|
||||
#include <AzFramework/Physics/Ragdoll.h>
|
||||
#include <AzFramework/Physics/RagdollPhysicsBus.h>
|
||||
@@ -131,7 +132,10 @@ namespace EMotionFX
|
||||
return AZ::Edit::PropertyVisibility::Show;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
AZ_ENUM_DEFINE_REFLECT_UTILITIES(ActorRenderFlags);
|
||||
|
||||
void ActorComponent::Configuration::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
BoundingBoxConfiguration::Reflect(context);
|
||||
@@ -139,19 +143,19 @@ namespace EMotionFX
|
||||
auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
|
||||
if (serializeContext)
|
||||
{
|
||||
ActorRenderFlagsReflect(*serializeContext);
|
||||
|
||||
serializeContext->Class<Configuration>()
|
||||
->Version(4)
|
||||
->Version(5)
|
||||
->Field("ActorAsset", &Configuration::m_actorAsset)
|
||||
->Field("MaterialPerLOD", &Configuration::m_materialPerLOD)
|
||||
->Field("RenderSkeleton", &Configuration::m_renderSkeleton)
|
||||
->Field("RenderCharacter", &Configuration::m_renderCharacter)
|
||||
->Field("RenderBounds", &Configuration::m_renderBounds)
|
||||
->Field("AttachmentType", &Configuration::m_attachmentType)
|
||||
->Field("AttachmentTarget", &Configuration::m_attachmentTarget)
|
||||
->Field("SkinningMethod", &Configuration::m_skinningMethod)
|
||||
->Field("LODLevel", &Configuration::m_lodLevel)
|
||||
->Field("BoundingBoxConfig", &Configuration::m_bboxConfig)
|
||||
->Field("ForceJointsUpdateOOV", &Configuration::m_forceUpdateJointsOOV)
|
||||
->Field("RenderFlags", &Configuration::m_renderFlags)
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -250,8 +254,6 @@ namespace EMotionFX
|
||||
{
|
||||
m_configuration = *configuration;
|
||||
}
|
||||
|
||||
m_debugRenderFlags[RENDER_SOLID] = true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -344,20 +346,24 @@ namespace EMotionFX
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool ActorComponent::GetRenderCharacter() const
|
||||
{
|
||||
return m_configuration.m_renderCharacter;
|
||||
return AZ::RHI::CheckBitsAny(m_configuration.m_renderFlags, ActorRenderFlags::Solid);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ActorComponent::SetRenderCharacter(bool enable)
|
||||
{
|
||||
if (m_configuration.m_renderCharacter != enable)
|
||||
if (enable)
|
||||
{
|
||||
m_configuration.m_renderCharacter = enable;
|
||||
m_configuration.m_renderFlags |= ActorRenderFlags::Solid;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_configuration.m_renderFlags &= ~ActorRenderFlags::Solid;
|
||||
}
|
||||
|
||||
if (m_renderActorInstance)
|
||||
{
|
||||
m_renderActorInstance->SetIsVisible(m_configuration.m_renderCharacter);
|
||||
}
|
||||
if (m_renderActorInstance)
|
||||
{
|
||||
m_renderActorInstance->SetIsVisible(enable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,9 +400,9 @@ namespace EMotionFX
|
||||
return m_sceneFinishSimHandler.IsConnected();
|
||||
}
|
||||
|
||||
void ActorComponent::SetRenderFlag(ActorRenderFlagBitset renderFlags)
|
||||
void ActorComponent::SetRenderFlag(ActorRenderFlags renderFlags)
|
||||
{
|
||||
m_debugRenderFlags = renderFlags;
|
||||
m_configuration.m_renderFlags = renderFlags;
|
||||
}
|
||||
|
||||
void ActorComponent::CheckActorCreation()
|
||||
@@ -456,7 +462,7 @@ namespace EMotionFX
|
||||
|
||||
if (m_renderActorInstance)
|
||||
{
|
||||
m_renderActorInstance->SetIsVisible(m_configuration.m_renderCharacter);
|
||||
m_renderActorInstance->SetIsVisible(AZ::RHI::CheckBitsAny(m_configuration.m_renderFlags, ActorRenderFlags::Solid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,22 +569,18 @@ namespace EMotionFX
|
||||
m_renderActorInstance->OnTick(deltaTime);
|
||||
m_renderActorInstance->UpdateBounds();
|
||||
AZ::Interface<AzFramework::IEntityBoundsUnion>::Get()->RefreshEntityLocalBoundsUnion(GetEntityId());
|
||||
const bool renderActorSolid = AZ::RHI::CheckBitsAny(m_configuration.m_renderFlags, ActorRenderFlags::Solid);
|
||||
|
||||
// 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 && m_configuration.m_renderCharacter);
|
||||
m_actorInstance->SetIsVisible(isInCameraFrustum && renderActorSolid);
|
||||
}
|
||||
|
||||
m_renderActorInstance->SetIsVisible(m_debugRenderFlags[RENDER_SOLID]);
|
||||
|
||||
// The configuration stores some debug option. When that is enabled, we override it on top of the render flags.
|
||||
m_debugRenderFlags[RENDER_AABB] = m_debugRenderFlags[RENDER_AABB] || m_configuration.m_renderBounds;
|
||||
m_debugRenderFlags[RENDER_LINESKELETON] = m_debugRenderFlags[RENDER_LINESKELETON] || m_configuration.m_renderSkeleton;
|
||||
m_debugRenderFlags[RENDER_EMFX_DEBUG] = true;
|
||||
m_renderActorInstance->DebugDraw(m_debugRenderFlags);
|
||||
m_renderActorInstance->SetIsVisible(renderActorSolid);
|
||||
m_renderActorInstance->DebugDraw(m_configuration.m_renderFlags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user