RavEngine
Loading...
Searching...
No Matches
PxParticleSystem.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_PARTICLE_SYSTEM_H
30#define PX_PARTICLE_SYSTEM_H
34#include "foundation/PxSimpleTypes.h"
35
36#include "PxActor.h"
37#include "PxFiltering.h"
38#include "PxParticleSystemFlag.h"
39
40#include "cudamanager/PxCudaTypes.h"
41
42#if !PX_DOXYGEN
43namespace physx
44{
45#endif
46
47#if PX_VC
48#pragma warning(push)
49#pragma warning(disable : 4435)
50#endif
51
52class PxCudaContextManager;
53class PxGpuParticleSystem;
54
55class PxParticleAndDiffuseBuffer;
56class PxParticleBuffer;
57class PxParticleMaterial;
58
63template <typename Type>
65{
66 Type* mDevicePtr;
67 Type* mHostPtr;
68
69 PxGpuMirroredPointer(Type* devicePtr, Type* hostPtr) : mDevicePtr(devicePtr), mHostPtr(hostPtr) { }
70};
71
77{
78public:
86 virtual void onBegin(const PxGpuMirroredPointer<PxGpuParticleSystem>& gpuParticleSystem, CUstream stream) = 0;
87
95 virtual void onAdvance(const PxGpuMirroredPointer<PxGpuParticleSystem>& gpuParticleSystem, CUstream stream) = 0;
96
104 virtual void onPostSolve(const PxGpuMirroredPointer<PxGpuParticleSystem>& gpuParticleSystem, CUstream stream) = 0;
105
110};
111
126
127typedef PxFlags<PxParticleFlag::Enum, PxU32> PxParticleFlags;
128
137{
138public:
139
158 virtual void setSolverIterationCounts(PxU32 minPositionIters, PxU32 minVelocityIters = 1) = 0;
159
165 virtual void getSolverIterationCounts(PxU32& minPositionIters, PxU32& minVelocityIters) const = 0;
166
173
181 virtual void setSimulationFilterData(const PxFilterData& data) = 0;
182
191 virtual void setParticleFlag(PxParticleFlag::Enum flag, bool val) = 0;
192
200 virtual void setParticleFlags(PxParticleFlags flags) = 0;
201
208
216 virtual void setMaxDepenetrationVelocity(PxReal maxDepenetrationVelocity) = 0;
217
223 virtual PxReal getMaxDepenetrationVelocity() = 0;
224
232 virtual void setMaxVelocity(PxReal maxVelocity) = 0;
233
239 virtual PxReal getMaxVelocity() = 0;
240
241
247 virtual PxCudaContextManager* getCudaContextManager() const = 0;
248
256 virtual void setRestOffset(PxReal restOffset) = 0;
257
264 virtual PxReal getRestOffset() const = 0;
265
274 virtual void setContactOffset(PxReal contactOffset) = 0;
275
282 virtual PxReal getContactOffset() const = 0;
283
292 virtual void setParticleContactOffset(PxReal particleContactOffset) = 0;
293
300 virtual PxReal getParticleContactOffset() const = 0;
301
309 virtual void setSolidRestOffset(PxReal solidRestOffset) = 0;
310
317 virtual PxReal getSolidRestOffset() const = 0;
318
319
331 virtual void addRigidAttachment(PxRigidActor* actor) = 0;
332
343 virtual void removeRigidAttachment(PxRigidActor* actor) = 0;
344
345
351 virtual void enableCCD(bool enable) = 0;
352
353
363 virtual PxU32 createPhase(PxParticleMaterial* material, PxParticlePhaseFlags flags) = 0;
364
365
370 virtual PxU32 getNbParticleMaterials() const = 0;
371
372
384
392
399 virtual void setPeriodicBoundary(const PxVec3& boundary) = 0;
400
407 virtual PxVec3 getPeriodicBoundary() const = 0;
408
415 virtual void addParticleBuffer(PxParticleBuffer* particleBuffer) = 0;
416
423 virtual void removeParticleBuffer(PxParticleBuffer* particleBuffer) = 0;
424
429 virtual PxU32 getGpuParticleSystemIndex() = 0;
430
431protected:
432
433 virtual ~PxParticleSystem() {}
434
435 PX_INLINE PxParticleSystem(PxType concreteType, PxBaseFlags baseFlags) : PxActor(concreteType, baseFlags) {}
436 PX_INLINE PxParticleSystem(PxBaseFlags baseFlags) : PxActor(baseFlags) {}
437 virtual bool isKindOf(const char* name) const PX_OVERRIDE { return !::strcmp("PxParticleSystem", name) || PxActor::isKindOf(name); }
438};
439
440
441#if PX_VC
442#pragma warning(pop)
443#endif
444
445
446#if !PX_DOXYGEN
447} // namespace physx
448#endif
449
451#endif
PxActor is the base class for the main simulation objects in the physics SDK.
Definition PxActor.h:201
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition PxActor.h:368
The shared base class for all particle buffers, can be instantiated directly to simulate granular and...
Definition PxParticleBuffer.h:81
Material class to represent a set of particle material properties.
Definition PxParticleMaterial.h:50
Particle system callback base class to schedule work that should be done before, while or after the p...
Definition PxParticleSystem.h:77
virtual void onPostSolve(const PxGpuMirroredPointer< PxGpuParticleSystem > &gpuParticleSystem, CUstream stream)=0
Method gets called after the particle system simulation step completed.
virtual ~PxParticleSystemCallback()
Destructor.
Definition PxParticleSystem.h:109
virtual void onAdvance(const PxGpuMirroredPointer< PxGpuParticleSystem > &gpuParticleSystem, CUstream stream)=0
Method gets called when the simulation step of the particle system is performed.
virtual void onBegin(const PxGpuMirroredPointer< PxGpuParticleSystem > &gpuParticleSystem, CUstream stream)=0
Method gets called when dirty data from the particle system is uploated to the gpu.
The shared base class for all particle systems.
Definition PxParticleSystem.h:137
virtual void addRigidAttachment(PxRigidActor *actor)=0
Creates a rigid attachment between a particle and a rigid actor.
virtual void setSimulationFilterData(const PxFilterData &data)=0
Set collision filter settings.
virtual PxU32 getNbParticleMaterials() const =0
Returns number of particle materials.
virtual bool isKindOf(const char *name) const PX_OVERRIDE
Returns whether a given type name matches with the type of this instance.
Definition PxParticleSystem.h:437
virtual PxReal getContactOffset() const =0
Return the contact offset.
virtual void setMaxVelocity(PxReal maxVelocity)=0
Set the maximal velocity particles can reach.
virtual PxParticleFlags getParticleFlags() const =0
Retrieves the particle flags.
virtual void setMaxDepenetrationVelocity(PxReal maxDepenetrationVelocity)=0
Set the maximal depenetration velocity particles can reach.
virtual PxU32 createPhase(PxParticleMaterial *material, PxParticlePhaseFlags flags)=0
Creates combined particle flag with particle material and particle phase flags.
virtual PxParticleSystemCallback * getParticleSystemCallback() const =0
Retrieves the simulationEventCallback pointer set with setSimulationEventCallback().
virtual void removeRigidAttachment(PxRigidActor *actor)=0
Removes a rigid attachment between a particle and a rigid body.
virtual PxReal getMaxDepenetrationVelocity()=0
Retrieves maximal depenetration velocity a particle can have.
virtual PxCudaContextManager * getCudaContextManager() const =0
Return the cuda context manager.
virtual PxReal getSolidRestOffset() const =0
Return the solid rest offset.
virtual PxVec3 getPeriodicBoundary() const =0
Gets periodic boundary wrap value.
virtual void addParticleBuffer(PxParticleBuffer *particleBuffer)=0
Add an existing particle buffer to the particle system.
virtual void getSolverIterationCounts(PxU32 &minPositionIters, PxU32 &minVelocityIters) const =0
Retrieves the solver iteration counts.
virtual PxFilterData getSimulationFilterData() const =0
Retrieves the collision filter settings.
virtual void enableCCD(bool enable)=0
Enable continuous collision detection for particles.
virtual void setParticleContactOffset(PxReal particleContactOffset)=0
Set the contact offset for the interactions between particles.
virtual PxReal getParticleContactOffset() const =0
Return the particle contact offset.
virtual PxU32 getGpuParticleSystemIndex()=0
Returns the GPU particle system index.
virtual PxReal getMaxVelocity()=0
Retrieves maximal velocity a particle can have.
virtual void setContactOffset(PxReal contactOffset)=0
Set the contact offset for the collision between particles and rigids or soft bodies.
virtual void setSolidRestOffset(PxReal solidRestOffset)=0
Set the solid rest offset.
virtual void setParticleFlags(PxParticleFlags flags)=0
Set particle flags.
virtual void setParticleSystemCallback(PxParticleSystemCallback *callback)=0
Sets a user notify object which receives special simulation events when they occur.
virtual void setPeriodicBoundary(const PxVec3 &boundary)=0
Sets periodic boundary wrap value.
virtual void setSolverIterationCounts(PxU32 minPositionIters, PxU32 minVelocityIters=1)=0
Sets the solver iteration counts for the body.
virtual void removeParticleBuffer(PxParticleBuffer *particleBuffer)=0
Remove particle buffer from the particle system.
virtual void setRestOffset(PxReal restOffset)=0
Set the rest offset for the collision between particles and rigids or soft bodies.
virtual PxReal getRestOffset() const =0
Return the rest offset.
virtual void setParticleFlag(PxParticleFlag::Enum flag, bool val)=0
Set particle flag.
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
3 Element vector class.
Definition PxVec3.h:50
#define PX_OVERRIDE
Definition PxPreprocessor.h:375
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxFilterData is user-definable data which gets passed into the collision filtering shader and/or call...
Definition PxFiltering.h:365
Container to hold a pair of corresponding device and host pointers. These pointers should point to GP...
Definition PxParticleSystem.h:65
Flags which control the behaviour of a particle system.
Definition PxParticleSystem.h:118
Enum
Definition PxParticleSystem.h:120
@ eDISABLE_SELF_COLLISION
Disables particle self-collision.
Definition PxParticleSystem.h:121
@ eFULL_DIFFUSE_ADVECTION
Enables full advection of diffuse particles. By default, diffuse particles are advected only by parti...
Definition PxParticleSystem.h:123
@ eDISABLE_RIGID_COLLISION
Disables particle-rigid body collision.
Definition PxParticleSystem.h:122