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:
@@ -34,7 +34,7 @@ namespace EMotionFX
|
||||
virtual ~RenderActorInstance() = default;
|
||||
|
||||
virtual void OnTick(float timeDelta) = 0;
|
||||
virtual void DebugDraw(const EMotionFX::ActorRenderFlagBitset& renderFlags) = 0;
|
||||
virtual void DebugDraw(const EMotionFX::ActorRenderFlags& renderFlags) = 0;
|
||||
|
||||
SkinningMethod GetSkinningMethod() const;
|
||||
virtual void SetSkinningMethod(SkinningMethod skinningMethod);
|
||||
|
||||
@@ -7,38 +7,87 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/containers/bitset.h>
|
||||
#include <AzCore/Preprocessor/Enum.h>
|
||||
#include <Atom/RHI.Reflect/Bits.h>
|
||||
|
||||
namespace EMotionFX
|
||||
{
|
||||
enum ActorRenderFlag
|
||||
// The index of the render flag which is 0, 1, 2, 3.. based.
|
||||
// Do not confuse this with the actual ActorRenderFlags::Type which is 1, 2, 4, 8.. based.
|
||||
enum ActorRenderFlagIndex : AZ::u8
|
||||
{
|
||||
RENDER_SOLID = 0,
|
||||
RENDER_WIREFRAME = 1,
|
||||
RENDER_LIGHTING = 2,
|
||||
RENDER_SHADOWS = 3,
|
||||
RENDER_FACENORMALS = 4,
|
||||
RENDER_VERTEXNORMALS = 5,
|
||||
RENDER_TANGENTS = 6,
|
||||
RENDER_AABB = 7,
|
||||
RENDER_SKELETON = 8,
|
||||
RENDER_LINESKELETON = 9,
|
||||
RENDER_NODEORIENTATION = 10,
|
||||
RENDER_NODENAMES = 11,
|
||||
RENDER_GRID = 12,
|
||||
RENDER_BACKFACECULLING = 13,
|
||||
RENDER_ACTORBINDPOSE = 14,
|
||||
RENDER_RAGDOLL_COLLIDERS = 15,
|
||||
RENDER_RAGDOLL_JOINTLIMITS = 16,
|
||||
RENDER_HITDETECTION_COLLIDERS = 17,
|
||||
RENDER_USE_GRADIENTBACKGROUND = 18,
|
||||
RENDER_MOTIONEXTRACTION = 19,
|
||||
RENDER_CLOTH_COLLIDERS = 20,
|
||||
RENDER_SIMULATEDOBJECT_COLLIDERS = 21,
|
||||
RENDER_SIMULATEJOINTS = 22,
|
||||
RENDER_EMFX_DEBUG = 23,
|
||||
NUM_RENDERFLAGS = 24
|
||||
SOLID = 0,
|
||||
WIREFRAME = 1,
|
||||
LIGHTING = 2,
|
||||
SHADOWS = 3,
|
||||
FACENORMALS = 4,
|
||||
VERTEXNORMALS = 5,
|
||||
TANGENTS = 6,
|
||||
AABB = 7,
|
||||
SKELETON = 8,
|
||||
LINESKELETON = 9,
|
||||
NODEORIENTATION = 10,
|
||||
NODENAMES = 11,
|
||||
GRID = 12,
|
||||
BACKFACECULLING = 13,
|
||||
ACTORBINDPOSE = 14,
|
||||
RAGDOLL_COLLIDERS = 15,
|
||||
RAGDOLL_JOINTLIMITS = 16,
|
||||
HITDETECTION_COLLIDERS = 17,
|
||||
USE_GRADIENTBACKGROUND = 18,
|
||||
MOTIONEXTRACTION = 19,
|
||||
CLOTH_COLLIDERS = 20,
|
||||
SIMULATEDOBJECT_COLLIDERS = 21,
|
||||
SIMULATEJOINTS = 22,
|
||||
EMFX_DEBUG = 23,
|
||||
NUM_RENDERFLAGINDEXES = 24
|
||||
};
|
||||
|
||||
using ActorRenderFlagBitset = AZStd::bitset<ActorRenderFlag::NUM_RENDERFLAGS>;
|
||||
//! A set of combinable flags which indicate which render option in turned on for the actor.
|
||||
AZ_ENUM_CLASS_WITH_UNDERLYING_TYPE(ActorRenderFlags, AZ::u32,
|
||||
(None, 0),
|
||||
(Solid, AZ_BIT(ActorRenderFlagIndex::SOLID)),
|
||||
(Wireframe, AZ_BIT(ActorRenderFlagIndex::WIREFRAME)),
|
||||
(Lighting, AZ_BIT(ActorRenderFlagIndex::LIGHTING)),
|
||||
(Default, Solid | Lighting),
|
||||
(Shadows, AZ_BIT(ActorRenderFlagIndex::SHADOWS)),
|
||||
(FaceNormals, AZ_BIT(ActorRenderFlagIndex::FACENORMALS)),
|
||||
(VertexNormals, AZ_BIT(ActorRenderFlagIndex::VERTEXNORMALS)),
|
||||
(Tangents, AZ_BIT(ActorRenderFlagIndex::TANGENTS)),
|
||||
(AABB, AZ_BIT(ActorRenderFlagIndex::AABB)),
|
||||
(Skeleton, AZ_BIT(ActorRenderFlagIndex::SKELETON)),
|
||||
(LineSkeleton, AZ_BIT(ActorRenderFlagIndex::LINESKELETON)),
|
||||
(NodeOrientation, AZ_BIT(ActorRenderFlagIndex::NODEORIENTATION)),
|
||||
(NodeNames, AZ_BIT(ActorRenderFlagIndex::NODENAMES)),
|
||||
(Grid, AZ_BIT(ActorRenderFlagIndex::GRID)),
|
||||
(BackfaceCulling, AZ_BIT(ActorRenderFlagIndex::BACKFACECULLING)),
|
||||
(ActorBindPose, AZ_BIT(ActorRenderFlagIndex::ACTORBINDPOSE)),
|
||||
(RagdollColliders, AZ_BIT(ActorRenderFlagIndex::RAGDOLL_COLLIDERS)),
|
||||
(RagdollJointLimits, AZ_BIT(ActorRenderFlagIndex::RAGDOLL_JOINTLIMITS)),
|
||||
(HitDetectionColliders, AZ_BIT(ActorRenderFlagIndex::HITDETECTION_COLLIDERS)),
|
||||
(UseGradientBackground, AZ_BIT(ActorRenderFlagIndex::USE_GRADIENTBACKGROUND)),
|
||||
(MotionExtraction, AZ_BIT(ActorRenderFlagIndex::MOTIONEXTRACTION)),
|
||||
(ClothColliders, AZ_BIT(ActorRenderFlagIndex::CLOTH_COLLIDERS)),
|
||||
(SimulatedObjectColliders, AZ_BIT(ActorRenderFlagIndex::SIMULATEDOBJECT_COLLIDERS)),
|
||||
(SimulatedJoints, AZ_BIT(ActorRenderFlagIndex::SIMULATEJOINTS)),
|
||||
(EmfxDebug, AZ_BIT(ActorRenderFlagIndex::EMFX_DEBUG))
|
||||
);
|
||||
|
||||
AZ_DEFINE_ENUM_BITWISE_OPERATORS(ActorRenderFlags);
|
||||
|
||||
class ActorRenderFlagUtil
|
||||
{
|
||||
public:
|
||||
// Check the bit value with the offset start at 0 from the right.
|
||||
// CheckBit(flags, 0) means check the last digit of the flags, CheckBit(flags, 1) means the second digit from right, etc.
|
||||
static bool CheckBit(ActorRenderFlags flags, AZ::u8 offset)
|
||||
{
|
||||
return (flags & ActorRenderFlags(AZ_BIT(offset))) != ActorRenderFlags(0);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
AZ_TYPE_INFO_SPECIALIZE(EMotionFX::ActorRenderFlags, "{2D2187FA-2C1A-4485-AF7C-AD34C0514105}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user