RavEngine
Loading...
Searching...
No Matches
PxParticleExt.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_EXT_H
30#define PX_PARTICLE_EXT_H
35#include "PxParticleSystem.h"
36#include "PxParticleBuffer.h"
37#include "foundation/PxArray.h"
38#include "foundation/PxHashMap.h"
39#include "foundation/PxUserAllocated.h"
40#include "PxAttachment.h"
41
42#if !PX_DOXYGEN
43namespace physx
44{
45#endif
46
47namespace ExtGpu
48{
49
54{
55 PxVec4* positions;
56 PxVec4* velocities;
57 PxU32* phases;
58 PxParticleVolume* volumes;
59 PxU32 numActiveParticles;
60 PxU32 maxParticles;
61 PxU32 numVolumes;
62 PxU32 maxVolumes;
63
64 PxParticleBufferDesc() : positions(NULL), velocities(NULL), phases(NULL), volumes(NULL), numActiveParticles(0), maxParticles(0), numVolumes(0), maxVolumes(0) { }
65};
66
71{
72 PxDiffuseParticleParams diffuseParams;
73 PxU32 maxDiffuseParticles;
74 PxU32 maxActiveDiffuseParticles;
75
77};
78
83{
84 PxParticleRigidDesc() : rigidOffsets(NULL), rigidCoefficients(NULL), rigidTranslations(NULL), rigidRotations(NULL),
85 rigidLocalPositions(NULL), rigidLocalNormals(NULL), maxRigids(0), numActiveRigids(0) { }
86
87 PxU32* rigidOffsets;
88 PxReal* rigidCoefficients;
89 PxVec4* rigidTranslations;
90 PxQuat* rigidRotations;
91 PxVec4* rigidLocalPositions;
92 PxVec4* rigidLocalNormals;
93 PxU32 maxRigids;
94 PxU32 numActiveRigids;
95};
96
98
103{
104public:
105 virtual void release() = 0;
106
107 virtual PxU32 getMaxCloths() const = 0;
108 virtual PxU32 getNumCloths() const = 0;
109 virtual PxU32 getMaxSprings() const = 0;
110 virtual PxU32 getNumSprings() const = 0;
111 virtual PxU32 getMaxTriangles() const = 0;
112 virtual PxU32 getNumTriangles() const = 0;
113 virtual PxU32 getMaxParticles() const = 0;
114 virtual PxU32 getNumParticles() const = 0;
115
129 virtual void addCloth(const PxParticleCloth& particleCloth,
130 const PxU32* triangles, const PxU32 numTriangles,
131 const PxParticleSpring* springs, const PxU32 numSprings, const PxVec4* restPositions, const PxU32 numParticles) = 0;
132
151 virtual void addCloth(const PxReal blendScale, const PxReal restVolume, const PxReal pressure,
152 const PxU32* triangles, const PxU32 numTriangles,
153 const PxParticleSpring* springs, const PxU32 numSprings,
154 const PxVec4* restPositions, const PxU32 numParticles) = 0;
155
164
165protected:
167};
168
169
174{
176 PxU32 count;
177};
178
183{
184public:
185 virtual void release() = 0;
186
187 virtual PxU32 getMaxVolumes() const = 0;
188 virtual PxU32 getNumVolumes() const = 0;
189 virtual PxU32 getMaxTriangles() const = 0;
190 virtual PxU32 getNumTriangles() const = 0;
191
194 virtual PxU32* getTriangles() = 0;
195
204 virtual void addVolume(const PxParticleVolume& volume, const PxParticleVolumeMesh& volumeMesh, const PxU32* triangles, const PxU32 numTriangles) = 0;
205
214 virtual void addVolume(const PxU32 particleOffset, const PxU32 numParticles, const PxU32* triangles, const PxU32 numTriangles) = 0;
215
216protected:
218};
219
220
225{
226public:
227 virtual void release() = 0;
228
229 virtual PxU32 getMaxRigids() const = 0;
230 virtual PxU32 getNumRigids() const = 0;
231 virtual PxU32 getMaxParticles() const = 0;
232 virtual PxU32 getNumParticles() const = 0;
233
244 virtual void addRigid(const PxVec3& translation, const PxQuat& rotation, const PxReal coefficient,
245 const PxVec4* localPositions, const PxVec4* localNormals, PxU32 numParticles) = 0;
246
253
254protected:
256};
257
259
264{
267 PxHashMap<PxRigidActor*, PxU32> mReferencedBodies;
268 PxArray<PxRigidActor*> mNewReferencedBodies;
269 PxArray<PxRigidActor*> mDestroyedRefrencedBodies;
270
271 PxParticleBuffer& mParticleBuffer;
272
273 PxParticleRigidAttachment* mDeviceAttachments;
274 PxParticleRigidFilterPair* mDeviceFilters;
275 PxU32 mNumDeviceAttachments;
276 PxU32 mNumDeviceFilters;
277
278 PxCudaContextManager* mCudaContextManager;
279
280 PxParticleSystem& mParticleSystem;
281
282 bool mDirty;
283
285
286public:
287
288 PxParticleAttachmentBuffer(PxParticleBuffer& particleBuffer, PxParticleSystem& particleSystem);
289
291
292 // adds attachment to attachment buffer - localPose is in actor space for attachments to all types of rigids.
293 void addRigidAttachment(PxRigidActor* rigidBody, const PxU32 particleID, const PxVec3& localPose, PxConeLimitedConstraint* coneLimit = NULL);
294 bool removeRigidAttachment(PxRigidActor* rigidBody, const PxU32 particleID);
295 void addRigidFilter(PxRigidActor* rigidBody, const PxU32 particleID);
296 bool removeRigidFilter(PxRigidActor* rigidBody, const PxU32 particleID);
297
298 void copyToDevice(CUstream stream = 0);
299};
300
310PxParticleRigidBufferHelper* PxCreateParticleRigidBufferHelper(PxU32 maxRigids, PxU32 maxParticles, PxCudaContextManager* cudaContextManager);
311
323PxParticleClothBufferHelper* PxCreateParticleClothBufferHelper(const PxU32 maxCloths, const PxU32 maxTriangles, const PxU32 maxSprings, const PxU32 maxParticles, PxCudaContextManager* cudaContextManager);
324
334PxParticleVolumeBufferHelper* PxCreateParticleVolumeBufferHelper(PxU32 maxVolumes, PxU32 maxTriangles, PxCudaContextManager* cudaContextManager);
335
343PxParticleAttachmentBuffer* PxCreateParticleAttachmentBuffer(PxParticleBuffer& particleBuffer, PxParticleSystem& particleSystem);
344
352PxParticleBuffer* PxCreateAndPopulateParticleBuffer(const ExtGpu::PxParticleBufferDesc& desc, PxCudaContextManager* cudaContextManager);
353
361PxParticleAndDiffuseBuffer* PxCreateAndPopulateParticleAndDiffuseBuffer(const ExtGpu::PxParticleAndDiffuseBufferDesc& desc, PxCudaContextManager* cudaContextManager);
362
372PxParticleClothBuffer* PxCreateAndPopulateParticleClothBuffer(const ExtGpu::PxParticleBufferDesc& desc, const PxParticleClothDesc& clothDesc,
373 PxPartitionedParticleCloth& output, PxCudaContextManager* cudaContextManager);
374
383PxParticleRigidBuffer* PxCreateAndPopulateParticleRigidBuffer(const ExtGpu::PxParticleBufferDesc& desc, const ExtGpu::PxParticleRigidDesc& rigidDesc,
384 PxCudaContextManager* cudaContextManager);
385
386} // namespace ExtGpu
387
388#if !PX_DOXYGEN
389} // namespace physx
390#endif
391
393#endif
394
Holds user-defined attachment data to attach particles to other bodies.
Definition PxParticleExt.h:264
Helper class to manage PxParticleClothDesc buffers used for communicating particle based cloths to Px...
Definition PxParticleExt.h:103
virtual PxU32 getNumTriangles() const =0
virtual PxU32 getMaxSprings() const =0
virtual void addCloth(const PxParticleCloth &particleCloth, const PxU32 *triangles, const PxU32 numTriangles, const PxParticleSpring *springs, const PxU32 numSprings, const PxVec4 *restPositions, const PxU32 numParticles)=0
Adds a PxParticleCloth to this PxParticleClothBufferHelper instance.
virtual PxU32 getMaxTriangles() const =0
virtual PxU32 getNumSprings() const =0
virtual PxParticleClothDesc & getParticleClothDesc()=0
Returns a PxParticleClothDesc for this PxParticleClothBufferHelper instance to be used for spring par...
virtual PxU32 getNumParticles() const =0
virtual void addCloth(const PxReal blendScale, const PxReal restVolume, const PxReal pressure, const PxU32 *triangles, const PxU32 numTriangles, const PxParticleSpring *springs, const PxU32 numSprings, const PxVec4 *restPositions, const PxU32 numParticles)=0
Adds a cloth to this PxParticleClothBufferHelper instance.
virtual PxU32 getMaxParticles() const =0
Helper class to manage PxParticleRigidDesc buffers used for communicating particle based rigids to Px...
Definition PxParticleExt.h:225
virtual PxU32 getMaxParticles() const =0
virtual void addRigid(const PxVec3 &translation, const PxQuat &rotation, const PxReal coefficient, const PxVec4 *localPositions, const PxVec4 *localNormals, PxU32 numParticles)=0
Adds a rigid.
virtual PxU32 getNumParticles() const =0
virtual PxParticleRigidDesc & getParticleRigidDesc()=0
Get the PxParticleRigidDesc for this buffer.
Helper class to manage communicating PxParticleVolumes data to PxParticleBuffer.
Definition PxParticleExt.h:183
virtual PxParticleVolumeMesh * getParticleVolumeMeshes()=0
virtual PxU32 getNumTriangles() const =0
virtual PxU32 getMaxTriangles() const =0
virtual PxParticleVolume * getParticleVolumes()=0
virtual void addVolume(const PxParticleVolume &volume, const PxParticleVolumeMesh &volumeMesh, const PxU32 *triangles, const PxU32 numTriangles)=0
Adds a PxParticleVolume with a PxParticleVolumeMesh.
virtual void addVolume(const PxU32 particleOffset, const PxU32 numParticles, const PxU32 *triangles, const PxU32 numTriangles)=0
Adds a volume.
Definition PxArray.h:53
Parameters to configure the behavior of diffuse particles.
Definition PxParticleBuffer.h:238
Definition PxHashMap.h:78
A particle buffer used to simulate diffuse particles.
Definition PxParticleBuffer.h:283
The shared base class for all particle buffers, can be instantiated directly to simulate granular and...
Definition PxParticleBuffer.h:81
A particle buffer used to simulate particle cloth.
Definition PxParticleBuffer.h:429
A particle buffer used to simulate rigid bodies using shape matching with particles.
Definition PxParticleBuffer.h:491
The shared base class for all particle systems.
Definition PxParticleSystem.h:137
This is a quaternion class. For more information on quaternion mathematics consult a mathematics sour...
Definition PxQuat.h:50
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
Definition PxUserAllocated.h:43
3 Element vector class.
Definition PxVec3.h:50
Definition PxVec4.h:50
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Structure to define user-defined particle state when constructing a new particle system that includes...
Definition PxParticleExt.h:71
Structure to define user-defined particle state when constructing a new particle system.
Definition PxParticleExt.h:54
Structure to define user-defined particle state when constructing a new particle system that includes...
Definition PxParticleExt.h:83
Helper struct that holds information about a specific mesh in a PxParticleVolumeBufferHelper.
Definition PxParticleExt.h:174
PxU32 count
The number of triangles of this mesh.
Definition PxParticleExt.h:176
PxU32 startIndex
The index of the first triangle of this mesh in the triangle array of the PxParticleVolumeBufferHelpe...
Definition PxParticleExt.h:175
A constraint descriptor for limiting movement to a conical region.
Definition PxConeLimitedConstraint.h:48
Structure to describe the set of particle cloths in the same #PxParticleClothBuffer....
Definition PxParticleBuffer.h:372
Particle cloth structure. Holds information about a single piece of cloth that is part of a #PxPartic...
Definition PxParticleBuffer.h:352
Struct to specify attachment between a particle/vertex and a rigid.
Definition PxAttachment.h:49
Struct for storing a particle/vertex - rigid filter pair with comparison operators.
Definition PxFiltering.h:751
Particle volume structure. Used to track the bounding volume of a user-specified set of particles....
Definition PxParticleBuffer.h:64
Structure to describe the output of the particle cloth preprocessing. Used as an input to specify clo...
Definition PxParticleBuffer.h:395