#ifndef PX_PHYSICS_NX_PHYSICS
#define PX_PHYSICS_NX_PHYSICS
#include "PxPhysXConfig.h"
#include "PxDeletionListener.h"
#include "foundation/PxTransform.h"
#include "PxShape.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
class PxPvd;
class PxPhysicsInsertionCallback;
class PxRigidActor;
class PxConstraintConnector;
struct PxConstraintShaderTable;
class PxGeometry;
class PxFoundation;
class PxSerializationRegistry;
class PxPruningStructure;
class PxBVHStructure;
class PxPhysics
{
public:
virtual ~PxPhysics() {}
virtual void release() = 0;
virtual PxFoundation& getFoundation() = 0;
virtual PxAggregate* createAggregate(PxU32 maxSize, bool enableSelfCollision) = 0;
virtual const PxTolerancesScale& getTolerancesScale() const = 0;
virtual PxTriangleMesh* createTriangleMesh(PxInputStream& stream) = 0;
virtual PxU32 getNbTriangleMeshes() const = 0;
virtual PxU32 getTriangleMeshes(PxTriangleMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
virtual PxHeightField* createHeightField(PxInputStream& stream) = 0;
virtual PxU32 getNbHeightFields() const = 0;
virtual PxU32 getHeightFields(PxHeightField** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
virtual PxConvexMesh* createConvexMesh(PxInputStream &stream) = 0;
virtual PxU32 getNbConvexMeshes() const = 0;
virtual PxU32 getConvexMeshes(PxConvexMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
virtual PxBVHStructure* createBVHStructure(PxInputStream &stream) = 0;
virtual PxU32 getNbBVHStructures() const = 0;
virtual PxU32 getBVHStructures(PxBVHStructure** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
virtual PxScene* createScene(const PxSceneDesc& sceneDesc) = 0;
virtual PxU32 getNbScenes() const = 0;
virtual PxU32 getScenes(PxScene** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
virtual PxRigidStatic* createRigidStatic(const PxTransform& pose) = 0;
virtual PxRigidDynamic* createRigidDynamic(const PxTransform& pose) = 0;
virtual PxPruningStructure* createPruningStructure(PxRigidActor*const* actors, PxU32 nbActors) = 0;
PX_FORCE_INLINE PxShape* createShape( const PxGeometry& geometry,
const PxMaterial& material,
bool isExclusive = false,
PxShapeFlags shapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE)
{
PxMaterial* materialPtr = const_cast<PxMaterial*>(&material);
return createShape(geometry, &materialPtr, 1, isExclusive, shapeFlags);
}
virtual PxShape* createShape(const PxGeometry& geometry,
PxMaterial*const * materials,
PxU16 materialCount,
bool isExclusive = false,
PxShapeFlags shapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE) = 0;
virtual PxU32 getNbShapes() const = 0;
virtual PxU32 getShapes(PxShape** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
virtual PxConstraint* createConstraint(PxRigidActor* actor0, PxRigidActor* actor1, PxConstraintConnector& connector, const PxConstraintShaderTable& shaders, PxU32 dataSize) = 0;
virtual PxArticulation* createArticulation() = 0;
virtual PxArticulationReducedCoordinate* createArticulationReducedCoordinate() = 0;
virtual PxMaterial* createMaterial(PxReal staticFriction, PxReal dynamicFriction, PxReal restitution) = 0;
virtual PxU32 getNbMaterials() const = 0;
virtual PxU32 getMaterials(PxMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
virtual void registerDeletionListener(PxDeletionListener& observer, const PxDeletionEventFlags& deletionEvents, bool restrictedObjectSet = false) = 0;
virtual void unregisterDeletionListener(PxDeletionListener& observer) = 0;
virtual void registerDeletionListenerObjects(PxDeletionListener& observer, const PxBase* const* observables, PxU32 observableCount) = 0;
virtual void unregisterDeletionListenerObjects(PxDeletionListener& observer, const PxBase* const* observables, PxU32 observableCount) = 0;
virtual PxPhysicsInsertionCallback& getPhysicsInsertionCallback() = 0;
};
#if !PX_DOXYGEN
} #endif
PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxRegisterArticulations(physx::PxPhysics& physics);
PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxRegisterArticulationsReducedCoordinate(physx::PxPhysics& physics);
PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxRegisterHeightFields(physx::PxPhysics& physics);
PX_C_EXPORT PX_PHYSX_CORE_API physx::PxPhysics* PX_CALL_CONV PxCreateBasePhysics(physx::PxU32 version,
physx::PxFoundation& foundation,
const physx::PxTolerancesScale& scale,
bool trackOutstandingAllocations = false,
physx::PxPvd* pvd = NULL);
PX_INLINE physx::PxPhysics* PxCreatePhysics(physx::PxU32 version,
physx::PxFoundation& foundation,
const physx::PxTolerancesScale& scale,
bool trackOutstandingAllocations = false,
physx::PxPvd* pvd = NULL )
{
physx::PxPhysics* physics = PxCreateBasePhysics(version, foundation, scale, trackOutstandingAllocations, pvd);
if(!physics)
return NULL;
PxRegisterArticulations(*physics);
PxRegisterArticulationsReducedCoordinate(*physics);
PxRegisterHeightFields(*physics);
return physics;
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
#endif
PX_C_EXPORT PX_PHYSX_CORE_API physx::PxPhysics& PX_CALL_CONV PxGetPhysics();
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif