include/PxScene.h
File members: include/PxScene.h
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_SCENE_H
#define PX_SCENE_H
#include "PxSceneQuerySystem.h"
#include "PxSceneDesc.h"
#include "PxVisualizationParameter.h"
#include "PxSimulationStatistics.h"
#include "PxClient.h"
#include "task/PxTask.h"
#include "PxArticulationFlag.h"
#include "PxSoftBodyFlag.h"
#include "PxHairSystemFlag.h"
#include "PxActorData.h"
#include "PxParticleSystemFlag.h"
#include "PxParticleSolverType.h"
#include "cudamanager/PxCudaTypes.h"
#include "pvd/PxPvdSceneClient.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
class PxCollection;
class PxConstraint;
class PxSimulationEventCallback;
class PxPhysics;
class PxAggregate;
class PxRenderBuffer;
class PxArticulationReducedCoordinate;
class PxParticleSystem;
struct PxContactPairHeader;
typedef PxU8 PxDominanceGroup;
class PxPvdSceneClient;
class PxSoftBody;
class PxFEMCloth;
class PxHairSystem;
struct PxDominanceGroupPair
{
PxDominanceGroupPair(PxU8 a, PxU8 b)
: dominance0(a), dominance1(b) {}
PxU8 dominance0;
PxU8 dominance1;
};
struct PxActorTypeFlag
{
enum Enum
{
eRIGID_STATIC = (1 << 0),
eRIGID_DYNAMIC = (1 << 1)
};
};
typedef PxFlags<PxActorTypeFlag::Enum,PxU16> PxActorTypeFlags;
PX_FLAGS_OPERATORS(PxActorTypeFlag::Enum,PxU16)
class PxActor;
class PxBroadPhaseCallback
{
public:
virtual ~PxBroadPhaseCallback() {}
virtual void onObjectOutOfBounds(PxShape& shape, PxActor& actor) = 0;
virtual void onObjectOutOfBounds(PxAggregate& aggregate) = 0;
};
class PxScene : public PxSceneSQSystem
{
protected:
/************************************************************************************************/
PxScene() : userData(NULL) {}
virtual ~PxScene() {}
public:
virtual void release() = 0;
virtual void setFlag(PxSceneFlag::Enum flag, bool value) = 0;
virtual PxSceneFlags getFlags() const = 0;
virtual void setLimits(const PxSceneLimits& limits) = 0;
virtual PxSceneLimits getLimits() const = 0;
virtual PxPhysics& getPhysics() = 0;
virtual PxU32 getTimestamp() const = 0;
virtual void setName(const char* name) = 0;
virtual const char* getName() const = 0;
/************************************************************************************************/
virtual bool addArticulation(PxArticulationReducedCoordinate& articulation) = 0;
virtual void removeArticulation(PxArticulationReducedCoordinate& articulation, bool wakeOnLostTouch = true) = 0;
/************************************************************************************************/
virtual bool addActor(PxActor& actor, const PxBVH* bvh = NULL) = 0;
virtual bool addActors(PxActor*const* actors, PxU32 nbActors) = 0;
virtual bool addActors(const PxPruningStructure& pruningStructure) = 0;
virtual void removeActor(PxActor& actor, bool wakeOnLostTouch = true) = 0;
virtual void removeActors(PxActor*const* actors, PxU32 nbActors, bool wakeOnLostTouch = true) = 0;
virtual bool addAggregate(PxAggregate& aggregate) = 0;
virtual void removeAggregate(PxAggregate& aggregate, bool wakeOnLostTouch = true) = 0;
virtual bool addCollection(const PxCollection& collection) = 0;
/************************************************************************************************/
virtual PxU32 getNbActors(PxActorTypeFlags types) const = 0;
virtual PxU32 getActors(PxActorTypeFlags types, PxActor** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
virtual PxActor** getActiveActors(PxU32& nbActorsOut) = 0;
virtual PxU32 getNbSoftBodies() const = 0;
virtual PxU32 getSoftBodies(PxSoftBody** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
virtual PxU32 getNbParticleSystems(PxParticleSolverType::Enum type) const = 0;
virtual PxU32 getParticleSystems(PxParticleSolverType::Enum type, PxParticleSystem** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
virtual PxU32 getNbFEMCloths() const = 0;
virtual PxU32 getFEMCloths(PxFEMCloth** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
virtual PxU32 getNbHairSystems() const = 0;
virtual PxU32 getHairSystems(PxHairSystem** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
virtual PxU32 getNbArticulations() const = 0;
virtual PxU32 getArticulations(PxArticulationReducedCoordinate** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
virtual PxU32 getNbConstraints() const = 0;
virtual PxU32 getConstraints(PxConstraint** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
virtual PxU32 getNbAggregates() const = 0;
virtual PxU32 getAggregates(PxAggregate** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
/************************************************************************************************/
virtual void setDominanceGroupPair(
PxDominanceGroup group1, PxDominanceGroup group2, const PxDominanceGroupPair& dominance) = 0;
virtual PxDominanceGroupPair getDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2) const = 0;
/************************************************************************************************/
virtual PxCpuDispatcher* getCpuDispatcher() const = 0;
virtual PxCudaContextManager* getCudaContextManager() const = 0;
/************************************************************************************************/
virtual PxClientID createClient() = 0;
/************************************************************************************************/
virtual void setSimulationEventCallback(PxSimulationEventCallback* callback) = 0;
virtual PxSimulationEventCallback* getSimulationEventCallback() const = 0;
virtual void setContactModifyCallback(PxContactModifyCallback* callback) = 0;
virtual void setCCDContactModifyCallback(PxCCDContactModifyCallback* callback) = 0;
virtual PxContactModifyCallback* getContactModifyCallback() const = 0;
virtual PxCCDContactModifyCallback* getCCDContactModifyCallback() const = 0;
virtual void setBroadPhaseCallback(PxBroadPhaseCallback* callback) = 0;
virtual PxBroadPhaseCallback* getBroadPhaseCallback() const = 0;
/************************************************************************************************/
virtual void setFilterShaderData(const void* data, PxU32 dataSize) = 0;
virtual const void* getFilterShaderData() const = 0;
virtual PxU32 getFilterShaderDataSize() const = 0;
virtual PxSimulationFilterShader getFilterShader() const = 0;
virtual PxSimulationFilterCallback* getFilterCallback() const = 0;
virtual bool resetFiltering(PxActor& actor) = 0;
virtual bool resetFiltering(PxRigidActor& actor, PxShape*const* shapes, PxU32 shapeCount) = 0;
virtual PxPairFilteringMode::Enum getKinematicKinematicFilteringMode() const = 0;
virtual PxPairFilteringMode::Enum getStaticKinematicFilteringMode() const = 0;
/************************************************************************************************/
virtual bool simulate(PxReal elapsedTime, physx::PxBaseTask* completionTask = NULL,
void* scratchMemBlock = 0, PxU32 scratchMemBlockSize = 0, bool controlSimulation = true) = 0;
virtual bool advance(physx::PxBaseTask* completionTask = 0) = 0;
virtual bool collide(PxReal elapsedTime, physx::PxBaseTask* completionTask = 0, void* scratchMemBlock = 0,
PxU32 scratchMemBlockSize = 0, bool controlSimulation = true) = 0;
virtual bool checkResults(bool block = false) = 0;
virtual bool fetchCollision(bool block = false) = 0;
virtual bool fetchResults(bool block = false, PxU32* errorState = 0) = 0;
virtual bool fetchResultsStart(const PxContactPairHeader*& contactPairs, PxU32& nbContactPairs, bool block = false) = 0;
virtual void processCallbacks(physx::PxBaseTask* continuation) = 0;
virtual void fetchResultsFinish(PxU32* errorState = 0) = 0;
virtual void fetchResultsParticleSystem() = 0;
virtual void flushSimulation(bool sendPendingReports = false) = 0;
virtual void setGravity(const PxVec3& vec) = 0;
virtual PxVec3 getGravity() const = 0;
virtual void setBounceThresholdVelocity(const PxReal t) = 0;
virtual PxReal getBounceThresholdVelocity() const = 0;
virtual void setCCDMaxPasses(PxU32 ccdMaxPasses) = 0;
virtual PxU32 getCCDMaxPasses() const = 0;
virtual void setCCDMaxSeparation(const PxReal t) = 0;
virtual PxReal getCCDMaxSeparation() const = 0;
virtual void setCCDThreshold(const PxReal t) = 0;
virtual PxReal getCCDThreshold() const = 0;
virtual void setMaxBiasCoefficient(const PxReal t) = 0;
virtual PxReal getMaxBiasCoefficient() const = 0;
virtual void setFrictionOffsetThreshold(const PxReal t) = 0;
virtual PxReal getFrictionOffsetThreshold() const = 0;
virtual void setFrictionCorrelationDistance(const PxReal t) = 0;
virtual PxReal getFrictionCorrelationDistance() const = 0;
virtual PxFrictionType::Enum getFrictionType() const = 0;
virtual PxSolverType::Enum getSolverType() const = 0;
/************************************************************************************************/
virtual bool setVisualizationParameter(PxVisualizationParameter::Enum param, PxReal value) = 0;
virtual PxReal getVisualizationParameter(PxVisualizationParameter::Enum paramEnum) const = 0;
virtual void setVisualizationCullingBox(const PxBounds3& box) = 0;
virtual PxBounds3 getVisualizationCullingBox() const = 0;
virtual const PxRenderBuffer& getRenderBuffer() = 0;
virtual void getSimulationStatistics(PxSimulationStatistics& stats) const = 0;
/************************************************************************************************/
virtual PxBroadPhaseType::Enum getBroadPhaseType() const = 0;
virtual bool getBroadPhaseCaps(PxBroadPhaseCaps& caps) const = 0;
virtual PxU32 getNbBroadPhaseRegions() const = 0;
virtual PxU32 getBroadPhaseRegions(PxBroadPhaseRegionInfo* userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
virtual PxU32 addBroadPhaseRegion(const PxBroadPhaseRegion& region, bool populateRegion=false) = 0;
virtual bool removeBroadPhaseRegion(PxU32 handle) = 0;
/************************************************************************************************/
virtual PxTaskManager* getTaskManager() const = 0;
virtual void lockRead(const char* file=NULL, PxU32 line=0) = 0;
virtual void unlockRead() = 0;
virtual void lockWrite(const char* file=NULL, PxU32 line=0) = 0;
virtual void unlockWrite() = 0;
virtual void setNbContactDataBlocks(PxU32 numBlocks) = 0;
virtual PxU32 getNbContactDataBlocksUsed() const = 0;
virtual PxU32 getMaxNbContactDataBlocksUsed() const = 0;
virtual PxU32 getContactReportStreamBufferSize() const = 0;
virtual void setSolverBatchSize(PxU32 solverBatchSize) = 0;
virtual PxU32 getSolverBatchSize() const = 0;
virtual void setSolverArticulationBatchSize(PxU32 solverBatchSize) = 0;
virtual PxU32 getSolverArticulationBatchSize() const = 0;
virtual PxReal getWakeCounterResetValue() const = 0;
virtual void shiftOrigin(const PxVec3& shift) = 0;
virtual PxPvdSceneClient* getScenePvdClient() = 0;
virtual void copyArticulationData(void* data, void* index, PxArticulationGpuDataType::Enum dataType, const PxU32 nbCopyArticulations, CUevent copyEvent = NULL) = 0;
virtual void applyArticulationData(void* data, void* index, PxArticulationGpuDataType::Enum dataType, const PxU32 nbUpdatedArticulations, CUevent waitEvent = NULL, CUevent signalEvent = NULL) = 0;
virtual void updateArticulationsKinematic(CUevent signalEvent = NULL) = 0;
virtual void copySoftBodyData(void** data, void* dataSizes, void* softBodyIndices, PxSoftBodyGpuDataFlag::Enum flag, const PxU32 nbCopySoftBodies, const PxU32 maxSize, CUevent copyEvent = NULL) = 0;
virtual void applySoftBodyData(void** data, void* dataSizes, void* softBodyIndices, PxSoftBodyGpuDataFlag::Enum flag, const PxU32 nbUpdatedSoftBodies, const PxU32 maxSize, CUevent applyEvent = NULL, CUevent signalEvent = NULL) = 0;
virtual void copyContactData(void* data, const PxU32 maxContactPairs, void* numContactPairs, CUevent copyEvent = NULL) = 0;
virtual void copyBodyData(PxGpuBodyData* data, PxGpuActorPair* index, const PxU32 nbCopyActors, CUevent copyEvent = NULL) = 0;
virtual void applyActorData(void* data, PxGpuActorPair* index, PxActorCacheFlag::Enum flag, const PxU32 nbUpdatedActors, CUevent waitEvent = NULL, CUevent signalEvent = NULL) = 0;
virtual void evaluateSDFDistances(const PxU32* sdfShapeIds, const PxU32 nbShapes, const PxVec4* localSamplePointsConcatenated,
const PxU32* samplePointCountPerShape, const PxU32 maxPointCount, PxVec4* localGradientAndSDFConcatenated, CUevent event = NULL) = 0;
virtual void computeDenseJacobians(const PxIndexDataPair* indices, PxU32 nbIndices, CUevent computeEvent = NULL) = 0;
virtual void computeGeneralizedMassMatrices(const PxIndexDataPair* indices, PxU32 nbIndices, CUevent computeEvent = NULL) = 0;
virtual void computeGeneralizedGravityForces(const PxIndexDataPair* indices, PxU32 nbIndices, CUevent computeEvent = NULL) = 0;
virtual void computeCoriolisAndCentrifugalForces(const PxIndexDataPair* indices, PxU32 nbIndices, CUevent computeEvent = NULL) = 0;
virtual PxgDynamicsMemoryConfig getGpuDynamicsConfig() const = 0;
virtual void applyParticleBufferData(const PxU32* indices, const PxGpuParticleBufferIndexPair* bufferIndexPair, const PxParticleBufferFlags* flags, PxU32 nbUpdatedBuffers, CUevent waitEvent = NULL, CUevent signalEvent = NULL) = 0;
void* userData;
};
#if !PX_DOXYGEN
} // namespace physx
#endif
#endif