|
|
|
|
@ -22,49 +22,15 @@ namespace AzPhysics
|
|
|
|
|
|
|
|
|
|
namespace PhysX
|
|
|
|
|
{
|
|
|
|
|
enum class BaseActorType : AZ::u32
|
|
|
|
|
{
|
|
|
|
|
PHYSX_DEFAULT = 0,
|
|
|
|
|
TOUCHBENDING_TRIGGER,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
///PxActor.userData is the custom data pointer that NVIDIA PhysX provides for applications to attach
|
|
|
|
|
///private data. The PhysX Gem requires that this userData points to objects that subclass BaseActorData.
|
|
|
|
|
///For Example:
|
|
|
|
|
///The TouchBending Gem defines "struct TouchBendingInstanceHandle : public PhysX::BaseActorData",
|
|
|
|
|
///While regular PhysX Gem Components use "class ActorData : public BaseActorData".
|
|
|
|
|
class BaseActorData
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
using PxActorUniquePtr = AZStd::unique_ptr<physx::PxActor, AZStd::function<void(physx::PxActor*)> >;
|
|
|
|
|
|
|
|
|
|
///This is an arbitary value used to verify the cast from void* userdata pointer on a pxActor to BaseActorData
|
|
|
|
|
///is safe. If m_sanity does not have this value, then it is not safe to use the casted pointer.
|
|
|
|
|
///Helps to debug if someone is setting userData pointer to something other than this class during development
|
|
|
|
|
static const AZ::u32 s_sanityValue = 0xba5eba11;
|
|
|
|
|
|
|
|
|
|
AZ::u32 m_sanity = s_sanityValue;
|
|
|
|
|
BaseActorType m_actorType = BaseActorType::PHYSX_DEFAULT;
|
|
|
|
|
PxActorUniquePtr m_actor;
|
|
|
|
|
|
|
|
|
|
BaseActorData() = default;
|
|
|
|
|
BaseActorData(BaseActorType type, physx::PxActor* actor);
|
|
|
|
|
BaseActorData(BaseActorData&& other);
|
|
|
|
|
BaseActorData& operator=(BaseActorData&& other);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
bool IsValid() const;
|
|
|
|
|
BaseActorType GetType() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ActorData : public BaseActorData
|
|
|
|
|
///private data. The PhysX Gem requires that this userData points to ActorData objects.
|
|
|
|
|
class ActorData
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ActorData() = default;
|
|
|
|
|
ActorData(physx::PxActor* actor);
|
|
|
|
|
ActorData(ActorData&& actorData) = default;
|
|
|
|
|
ActorData& operator=(ActorData&& actorData) = default;
|
|
|
|
|
ActorData(ActorData&& actorData);
|
|
|
|
|
ActorData& operator=(ActorData&& actorData);
|
|
|
|
|
|
|
|
|
|
void Invalidate();
|
|
|
|
|
AZ::EntityId GetEntityId() const;
|
|
|
|
|
@ -86,7 +52,18 @@ namespace PhysX
|
|
|
|
|
|
|
|
|
|
AzPhysics::SimulatedBody* GetSimulatedBody() const;
|
|
|
|
|
|
|
|
|
|
bool IsValid() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
using PxActorUniquePtr = AZStd::unique_ptr<physx::PxActor, AZStd::function<void(physx::PxActor*)> >;
|
|
|
|
|
|
|
|
|
|
///This is an arbitary value used to verify the cast from void* userdata pointer on a pxActor to ActorData
|
|
|
|
|
///is safe. If m_sanity does not have this value, then it is not safe to use the casted pointer.
|
|
|
|
|
///Helps to debug if someone is setting userData pointer to something other than this class during development
|
|
|
|
|
static const AZ::u32 s_sanityValue = 0xba5eba11;
|
|
|
|
|
|
|
|
|
|
AZ::u32 m_sanity = s_sanityValue;
|
|
|
|
|
PxActorUniquePtr m_actor;
|
|
|
|
|
|
|
|
|
|
struct Payload
|
|
|
|
|
{
|
|
|
|
|
|