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:
@@ -33,7 +33,7 @@ namespace AZ::Render
|
||||
m_auxGeomFeatureProcessor = RPI::Scene::GetFeatureProcessorForEntity<RPI::AuxGeomFeatureProcessorInterface>(entityId);
|
||||
}
|
||||
|
||||
void AtomActorDebugDraw::DebugDraw(const EMotionFX::ActorRenderFlagBitset& renderFlags, EMotionFX::ActorInstance* instance)
|
||||
void AtomActorDebugDraw::DebugDraw(const EMotionFX::ActorRenderFlags& renderFlags, EMotionFX::ActorInstance* instance)
|
||||
{
|
||||
if (!m_auxGeomFeatureProcessor || !instance)
|
||||
{
|
||||
@@ -46,10 +46,12 @@ namespace AZ::Render
|
||||
return;
|
||||
}
|
||||
|
||||
using AZ::RHI::CheckBitsAny;
|
||||
|
||||
// Update the mesh deformers (perform cpu skinning and morphing) when needed.
|
||||
if (renderFlags[EMotionFX::ActorRenderFlag::RENDER_AABB] || renderFlags[EMotionFX::ActorRenderFlag::RENDER_FACENORMALS] ||
|
||||
renderFlags[EMotionFX::ActorRenderFlag::RENDER_TANGENTS] || renderFlags[EMotionFX::ActorRenderFlag::RENDER_VERTEXNORMALS] ||
|
||||
renderFlags[EMotionFX::ActorRenderFlag::RENDER_WIREFRAME])
|
||||
if (CheckBitsAny(renderFlags,
|
||||
EMotionFX::ActorRenderFlags::AABB | EMotionFX::ActorRenderFlags::FaceNormals | EMotionFX::ActorRenderFlags::Tangents |
|
||||
EMotionFX::ActorRenderFlags::VertexNormals | EMotionFX::ActorRenderFlags::Wireframe))
|
||||
{
|
||||
instance->UpdateMeshDeformers(0.0f, true);
|
||||
}
|
||||
@@ -61,7 +63,7 @@ namespace AZ::Render
|
||||
const float scaleMultiplier = CalculateScaleMultiplier(instance);
|
||||
|
||||
// Render aabb
|
||||
if (renderFlags[EMotionFX::ActorRenderFlag::RENDER_AABB])
|
||||
if (CheckBitsAny(renderFlags, EMotionFX::ActorRenderFlags::AABB))
|
||||
{
|
||||
RenderAABB(instance,
|
||||
renderActorSettings.m_enabledNodeBasedAabb, renderActorSettings.m_nodeAABBColor,
|
||||
@@ -70,39 +72,39 @@ namespace AZ::Render
|
||||
}
|
||||
|
||||
// Render simple line skeleton
|
||||
if (renderFlags[EMotionFX::ActorRenderFlag::RENDER_LINESKELETON])
|
||||
if (CheckBitsAny(renderFlags, EMotionFX::ActorRenderFlags::LineSkeleton))
|
||||
{
|
||||
RenderLineSkeleton(instance, renderActorSettings.m_lineSkeletonColor);
|
||||
}
|
||||
|
||||
// Render advanced skeleton
|
||||
if (renderFlags[EMotionFX::ActorRenderFlag::RENDER_SKELETON])
|
||||
if (CheckBitsAny(renderFlags, EMotionFX::ActorRenderFlags::Skeleton))
|
||||
{
|
||||
RenderSkeleton(instance, renderActorSettings.m_skeletonColor);
|
||||
}
|
||||
|
||||
if (renderFlags[EMotionFX::ActorRenderFlag::RENDER_NODENAMES])
|
||||
if (CheckBitsAny(renderFlags, EMotionFX::ActorRenderFlags::NodeNames))
|
||||
{
|
||||
RenderJointNames(instance, viewport, renderActorSettings.m_jointNameColor);
|
||||
}
|
||||
|
||||
// Render internal EMFX debug lines.
|
||||
if (renderFlags[EMotionFX::ActorRenderFlag::RENDER_EMFX_DEBUG])
|
||||
if (CheckBitsAny(renderFlags, EMotionFX::ActorRenderFlags::EmfxDebug))
|
||||
{
|
||||
RenderEMFXDebugDraw(instance);
|
||||
}
|
||||
|
||||
// Render
|
||||
if (renderFlags[EMotionFX::ActorRenderFlag::RENDER_NODEORIENTATION])
|
||||
if (CheckBitsAny(renderFlags, EMotionFX::ActorRenderFlags::NodeOrientation))
|
||||
{
|
||||
RenderNodeOrientations(instance, debugDisplay, renderActorSettings.m_nodeOrientationScale * scaleMultiplier);
|
||||
}
|
||||
|
||||
// Render vertex normal, face normal, tagent and wireframe.
|
||||
const bool renderVertexNormals = renderFlags[EMotionFX::ActorRenderFlag::RENDER_VERTEXNORMALS];
|
||||
const bool renderFaceNormals = renderFlags[EMotionFX::ActorRenderFlag::RENDER_FACENORMALS];
|
||||
const bool renderTangents = renderFlags[EMotionFX::ActorRenderFlag::RENDER_TANGENTS];
|
||||
const bool renderWireframe = renderFlags[EMotionFX::ActorRenderFlag::RENDER_WIREFRAME];
|
||||
const bool renderVertexNormals = CheckBitsAny(renderFlags, EMotionFX::ActorRenderFlags::VertexNormals);
|
||||
const bool renderFaceNormals = CheckBitsAny(renderFlags, EMotionFX::ActorRenderFlags::FaceNormals);
|
||||
const bool renderTangents = CheckBitsAny(renderFlags, EMotionFX::ActorRenderFlags::Tangents);
|
||||
const bool renderWireframe = CheckBitsAny(renderFlags, EMotionFX::ActorRenderFlags::Wireframe);
|
||||
|
||||
if (renderVertexNormals || renderFaceNormals || renderTangents || renderWireframe)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace AZ::Render
|
||||
public:
|
||||
AtomActorDebugDraw(AZ::EntityId entityId);
|
||||
|
||||
void DebugDraw(const EMotionFX::ActorRenderFlagBitset& renderFlags, EMotionFX::ActorInstance* instance);
|
||||
void DebugDraw(const EMotionFX::ActorRenderFlags& renderFlags, EMotionFX::ActorInstance* instance);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace AZ::Render
|
||||
UpdateBounds();
|
||||
}
|
||||
|
||||
void AtomActorInstance::DebugDraw(const EMotionFX::ActorRenderFlagBitset& renderFlags)
|
||||
void AtomActorInstance::DebugDraw(const EMotionFX::ActorRenderFlags& renderFlags)
|
||||
{
|
||||
m_atomActorDebugDraw->DebugDraw(renderFlags, m_actorInstance);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace AZ
|
||||
|
||||
// RenderActorInstance overrides ...
|
||||
void OnTick(float timeDelta) override;
|
||||
void DebugDraw(const EMotionFX::ActorRenderFlagBitset& renderFlags);
|
||||
void DebugDraw(const EMotionFX::ActorRenderFlags& renderFlags);
|
||||
void UpdateBounds() override;
|
||||
void SetMaterials(const EMotionFX::Integration::ActorAsset::MaterialList& materialPerLOD) override { AZ_UNUSED(materialPerLOD); };
|
||||
void SetSkinningMethod(EMotionFX::Integration::SkinningMethod emfxSkinningMethod) override;
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace EMStudio
|
||||
return result;
|
||||
}
|
||||
|
||||
void AnimViewportRenderer::UpdateActorRenderFlag(EMotionFX::ActorRenderFlagBitset renderFlags)
|
||||
void AnimViewportRenderer::UpdateActorRenderFlag(EMotionFX::ActorRenderFlags renderFlags)
|
||||
{
|
||||
for (AZ::Entity* entity : m_actorEntities)
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace EMStudio
|
||||
//! Return the center position of the existing objects.
|
||||
AZ::Vector3 GetCharacterCenter() const;
|
||||
|
||||
void UpdateActorRenderFlag(EMotionFX::ActorRenderFlagBitset renderFlags);
|
||||
void UpdateActorRenderFlag(EMotionFX::ActorRenderFlags renderFlags);
|
||||
AZStd::shared_ptr<AzFramework::Scene> GetFrameworkScene() const;
|
||||
AZ::EntityId GetEntityId() const;
|
||||
AzFramework::EntityContextId GetEntityContextId() const;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace EMStudio
|
||||
virtual void UpdateCameraFollowUp(bool followUp) = 0;
|
||||
|
||||
//! Update render flags
|
||||
virtual void UpdateRenderFlags(EMotionFX::ActorRenderFlagBitset renderFlags) = 0;
|
||||
virtual void UpdateRenderFlags(EMotionFX::ActorRenderFlags renderFlags) = 0;
|
||||
};
|
||||
|
||||
using AnimViewportRequestBus = AZ::EBus<AnimViewportRequests>;
|
||||
|
||||
@@ -61,35 +61,35 @@ namespace EMStudio
|
||||
renderOptionsButton->setIcon(QIcon(":/EMotionFXAtom/Visualization.svg"));
|
||||
addWidget(renderOptionsButton);
|
||||
|
||||
CreateViewOptionEntry(contextMenu, "Solid", EMotionFX::ActorRenderFlag::RENDER_SOLID);
|
||||
CreateViewOptionEntry(contextMenu, "Wireframe", EMotionFX::ActorRenderFlag::RENDER_WIREFRAME);
|
||||
CreateViewOptionEntry(contextMenu, "Solid", EMotionFX::ActorRenderFlagIndex::SOLID);
|
||||
CreateViewOptionEntry(contextMenu, "Wireframe", EMotionFX::ActorRenderFlagIndex::WIREFRAME);
|
||||
// [EMFX-TODO] Add those option once implemented.
|
||||
// CreateViewOptionEntry(contextMenu, "Lighting", EMotionFX::ActorRenderFlag::RENDER_LIGHTING);
|
||||
// CreateViewOptionEntry(contextMenu, "Backface Culling", EMotionFX::ActorRenderFlag::RENDER_BACKFACECULLING);
|
||||
// CreateViewOptionEntry(contextMenu, "Lighting", EMotionFX::ActorRenderFlagIndex::RENDER_LIGHTING);
|
||||
// CreateViewOptionEntry(contextMenu, "Backface Culling", EMotionFX::ActorRenderFlagIndex::RENDER_BACKFACECULLING);
|
||||
contextMenu->addSeparator();
|
||||
CreateViewOptionEntry(contextMenu, "Vertex Normals", EMotionFX::ActorRenderFlag::RENDER_VERTEXNORMALS);
|
||||
CreateViewOptionEntry(contextMenu, "Face Normals", EMotionFX::ActorRenderFlag::RENDER_FACENORMALS);
|
||||
CreateViewOptionEntry(contextMenu, "Tangents", EMotionFX::ActorRenderFlag::RENDER_TANGENTS);
|
||||
CreateViewOptionEntry(contextMenu, "Actor Bounding Boxes", EMotionFX::ActorRenderFlag::RENDER_AABB);
|
||||
CreateViewOptionEntry(contextMenu, "Vertex Normals", EMotionFX::ActorRenderFlagIndex::VERTEXNORMALS);
|
||||
CreateViewOptionEntry(contextMenu, "Face Normals", EMotionFX::ActorRenderFlagIndex::FACENORMALS);
|
||||
CreateViewOptionEntry(contextMenu, "Tangents", EMotionFX::ActorRenderFlagIndex::TANGENTS);
|
||||
CreateViewOptionEntry(contextMenu, "Actor Bounding Boxes", EMotionFX::ActorRenderFlagIndex::AABB);
|
||||
contextMenu->addSeparator();
|
||||
CreateViewOptionEntry(contextMenu, "Line Skeleton", EMotionFX::ActorRenderFlag::RENDER_LINESKELETON);
|
||||
CreateViewOptionEntry(contextMenu, "Solid Skeleton", EMotionFX::ActorRenderFlag::RENDER_SKELETON);
|
||||
CreateViewOptionEntry(contextMenu, "Joint Names", EMotionFX::ActorRenderFlag::RENDER_NODENAMES);
|
||||
CreateViewOptionEntry(contextMenu, "Joint Orientations", EMotionFX::ActorRenderFlag::RENDER_NODEORIENTATION);
|
||||
CreateViewOptionEntry(contextMenu, "Line Skeleton", EMotionFX::ActorRenderFlagIndex::LINESKELETON);
|
||||
CreateViewOptionEntry(contextMenu, "Solid Skeleton", EMotionFX::ActorRenderFlagIndex::SKELETON);
|
||||
CreateViewOptionEntry(contextMenu, "Joint Names", EMotionFX::ActorRenderFlagIndex::NODENAMES);
|
||||
CreateViewOptionEntry(contextMenu, "Joint Orientations", EMotionFX::ActorRenderFlagIndex::NODEORIENTATION);
|
||||
// [EMFX-TODO] Add those option once implemented.
|
||||
// CreateViewOptionEntry(contextMenu, "Actor Bind Pose", EMotionFX::ActorRenderFlag::RENDER_ACTORBINDPOSE);
|
||||
// CreateViewOptionEntry(contextMenu, "Actor Bind Pose", EMotionFX::ActorRenderFlagIndex::RENDER_ACTORBINDPOSE);
|
||||
contextMenu->addSeparator();
|
||||
CreateViewOptionEntry(contextMenu, "Hit Detection Colliders", EMotionFX::ActorRenderFlag::RENDER_HITDETECTION_COLLIDERS, true,
|
||||
CreateViewOptionEntry(contextMenu, "Hit Detection Colliders", EMotionFX::ActorRenderFlagIndex::HITDETECTION_COLLIDERS, true,
|
||||
":/EMotionFXAtom/HitDetection.svg");
|
||||
CreateViewOptionEntry(contextMenu, "Ragdoll Colliders", EMotionFX::ActorRenderFlag::RENDER_RAGDOLL_COLLIDERS, true,
|
||||
CreateViewOptionEntry(contextMenu, "Ragdoll Colliders", EMotionFX::ActorRenderFlagIndex::RAGDOLL_COLLIDERS, true,
|
||||
":/EMotionFXAtom/RagdollCollider.svg");
|
||||
CreateViewOptionEntry(contextMenu, "Ragdoll Joint Limits", EMotionFX::ActorRenderFlag::RENDER_RAGDOLL_JOINTLIMITS, true,
|
||||
CreateViewOptionEntry(contextMenu, "Ragdoll Joint Limits", EMotionFX::ActorRenderFlagIndex::RAGDOLL_JOINTLIMITS, true,
|
||||
":/EMotionFXAtom/RagdollJointLimit.svg");
|
||||
CreateViewOptionEntry(contextMenu, "Cloth Colliders", EMotionFX::ActorRenderFlag::RENDER_CLOTH_COLLIDERS, true,
|
||||
CreateViewOptionEntry(contextMenu, "Cloth Colliders", EMotionFX::ActorRenderFlagIndex::CLOTH_COLLIDERS, true,
|
||||
":/EMotionFXAtom/Cloth.svg");
|
||||
CreateViewOptionEntry(contextMenu, "Simulated Object Colliders", EMotionFX::ActorRenderFlag::RENDER_SIMULATEDOBJECT_COLLIDERS, true,
|
||||
CreateViewOptionEntry(contextMenu, "Simulated Object Colliders", EMotionFX::ActorRenderFlagIndex::SIMULATEDOBJECT_COLLIDERS, true,
|
||||
":/EMotionFXAtom/SimulatedObjectCollider.svg");
|
||||
CreateViewOptionEntry(contextMenu, "Simulated Joints", EMotionFX::ActorRenderFlag::RENDER_SIMULATEJOINTS);
|
||||
CreateViewOptionEntry(contextMenu, "Simulated Joints", EMotionFX::ActorRenderFlagIndex::SIMULATEJOINTS);
|
||||
}
|
||||
|
||||
// Add the camera button
|
||||
@@ -158,7 +158,7 @@ namespace EMStudio
|
||||
}
|
||||
|
||||
void AnimViewportToolBar::CreateViewOptionEntry(
|
||||
QMenu* menu, const char* menuEntryName, uint32_t actionIndex, bool visible, const char* iconFileName)
|
||||
QMenu* menu, const char* menuEntryName, AZ::u8 actionIndex, bool visible, const char* iconFileName)
|
||||
{
|
||||
QAction* action = menu->addAction(
|
||||
menuEntryName,
|
||||
@@ -194,13 +194,13 @@ namespace EMStudio
|
||||
m_manipulatorActions[mode]->setChecked(true);
|
||||
}
|
||||
|
||||
const EMotionFX::ActorRenderFlagBitset renderFlags = renderOptions->GetRenderFlags();
|
||||
for (size_t i = 0; i < renderFlags.size(); ++i)
|
||||
const EMotionFX::ActorRenderFlags renderFlags = renderOptions->GetRenderFlags();
|
||||
for (uint8 i = 0; i < EMotionFX::ActorRenderFlagIndex::NUM_RENDERFLAGINDEXES; ++i)
|
||||
{
|
||||
QAction* action = m_renderActions[i];
|
||||
if (action)
|
||||
{
|
||||
action->setChecked(renderFlags[i]);
|
||||
action->setChecked(EMotionFX::ActorRenderFlagUtil::CheckBit(renderFlags, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ namespace EMStudio
|
||||
|
||||
private:
|
||||
void CreateViewOptionEntry(
|
||||
QMenu* menu, const char* menuEntryName, uint32_t actionIndex, bool visible = true, const char* iconFileName = nullptr);
|
||||
QMenu* menu, const char* menuEntryName, AZ::u8 actionIndex, bool visible = true, const char* iconFileName = nullptr);
|
||||
|
||||
AtomRenderPlugin* m_plugin = nullptr;
|
||||
QAction* m_manipulatorActions[RenderOptions::ManipulatorMode::NUM_MODES] = { nullptr };
|
||||
QAction* m_renderActions[EMotionFX::ActorRenderFlag::NUM_RENDERFLAGS] = { nullptr };
|
||||
QAction* m_renderActions[EMotionFX::ActorRenderFlagIndex::NUM_RENDERFLAGINDEXES] = { nullptr };
|
||||
QAction* m_followCharacterAction = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace EMStudio
|
||||
}
|
||||
}
|
||||
|
||||
void AnimViewportWidget::UpdateRenderFlags(EMotionFX::ActorRenderFlagBitset renderFlags)
|
||||
void AnimViewportWidget::UpdateRenderFlags(EMotionFX::ActorRenderFlags renderFlags)
|
||||
{
|
||||
m_renderer->UpdateActorRenderFlag(renderFlags);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace EMStudio
|
||||
// AnimViewportRequestBus::Handler overrides
|
||||
void UpdateCameraViewMode(RenderOptions::CameraViewMode mode);
|
||||
void UpdateCameraFollowUp(bool follow);
|
||||
void UpdateRenderFlags(EMotionFX::ActorRenderFlagBitset renderFlags);
|
||||
void UpdateRenderFlags(EMotionFX::ActorRenderFlags renderFlags);
|
||||
|
||||
// ViewportPluginRequestBus::Handler overrides
|
||||
AZ::s32 GetViewportId() const;
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace EMStudio
|
||||
return &m_renderOptions;
|
||||
}
|
||||
|
||||
void AtomRenderPlugin::Render([[maybe_unused]]EMotionFX::ActorRenderFlagBitset renderFlags)
|
||||
void AtomRenderPlugin::Render([[maybe_unused]]EMotionFX::ActorRenderFlags renderFlags)
|
||||
{
|
||||
if (!m_animViewportWidget)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace EMStudio
|
||||
void SaveRenderOptions();
|
||||
RenderOptions* GetRenderOptions();
|
||||
|
||||
void Render(EMotionFX::ActorRenderFlagBitset renderFlags) override;
|
||||
void Render(EMotionFX::ActorRenderFlags renderFlags) override;
|
||||
void SetManipulatorMode(RenderOptions::ManipulatorMode mode);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user