RavEngine
Loading...
Searching...
No Matches
NpParticleSystem.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 NP_PARTICLE_SYSTEM_H
30#define NP_PARTICLE_SYSTEM_H
31
32#include "foundation/PxBounds3.h"
33#include "foundation/PxErrors.h"
34#include "foundation/PxSimpleTypes.h"
35#include "foundation/PxUserAllocated.h"
36#include "foundation/PxVec3.h"
37
38#include "common/PxBase.h"
39#include "common/PxRenderOutput.h"
40
41#include "PxActor.h"
42#include "PxFiltering.h"
43#include "PxParticleBuffer.h"
44//#include "PxParticlePhase.h"
45#include "PxParticleSolverType.h"
46#include "PxParticleSystem.h"
47#include "PxPBDParticleSystem.h"
48#include "PxPBDMaterial.h"
49#include "PxSceneDesc.h"
50#include "PxSparseGridParams.h"
51
52#include "DyParticleSystem.h"
53
54#include "NpActor.h"
55#include "NpActorTemplate.h"
56#include "NpBase.h"
57
58#include "ScParticleSystemSim.h"
59
60#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
61#include "PxCustomParticleSystem.h"
62#include "PxFLIPParticleSystem.h"
63#include "PxFLIPMaterial.h"
64#include "PxMPMParticleSystem.h"
65#include "PxMPMMaterial.h"
66#endif
67
68namespace physx
69{
70 class NpScene;
71
72 class PxCudaContextManager;
73 class PxParticleMaterial;
74 class PxRigidActor;
75 class PxSerializationContext;
76
77 namespace Sc
78 {
79 class ParticleSystemSim;
80 }
81
82 template<class APIClass>
83 class NpParticleSystem : public NpActorTemplate<APIClass>
84 {
85 public:
86 NpParticleSystem(PxCudaContextManager& contextManager, PxType concreteType, NpType::Enum npType, PxActorType::Enum actorType) :
87 NpActorTemplate<APIClass>(concreteType, PxBaseFlag::eOWNS_MEMORY | PxBaseFlag::eIS_RELEASABLE, npType),
88 mCore(actorType),
89 mCudaContextManager(&contextManager),
90 mNextPhaseGroupID(0)
91 {
92
93 }
95 {}
96
97 virtual ~NpParticleSystem()
98 {
99 //TODO!!!!! Do this correctly
100 //sParticleSystemIdPool.tryRemoveID(mID);
101 }
102 virtual void exportData(PxSerializationContext& /*context*/) const {}
103 //external API
104
105 virtual PxBounds3 getWorldBounds(float inflation = 1.01f) const
106 {
107 NP_READ_CHECK(NpBase::getNpScene());
108
109 if (!NpBase::getNpScene())
110 {
111 PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Querying bounds of a PxParticleSystem which is not part of a PxScene is not supported.");
112 return PxBounds3::empty();
113 }
114
115 const Sc::ParticleSystemSim* sim = mCore.getSim();
116 PX_ASSERT(sim);
117
118 PX_SIMD_GUARD;
119
120 PxBounds3 bounds = sim->getBounds();
121 PX_ASSERT(bounds.isValid());
122
123 // PT: unfortunately we can't just scale the min/max vectors, we need to go through center/extents.
124 const PxVec3 center = bounds.getCenter();
125 const PxVec3 inflatedExtents = bounds.getExtents() * inflation;
126 return PxBounds3::centerExtents(center, inflatedExtents);
127 }
128
129 virtual void setSolverIterationCounts(PxU32 minPositionIters, PxU32 minVelocityIters = 1)
130 {
131 NpScene* npScene = NpBase::getNpScene();
132 NP_WRITE_CHECK(npScene);
133 PX_CHECK_AND_RETURN(minPositionIters > 0, "NpParticleSystem::setSolverIterationCounts: positionIters must be more than zero!");
134 PX_CHECK_AND_RETURN(minPositionIters <= 255, "NpParticleSystem::setSolverIterationCounts: positionIters must be no greater than 255!");
135 PX_CHECK_AND_RETURN(minVelocityIters <= 255, "NpParticleSystem::setSolverIterationCounts: velocityIters must be no greater than 255!");
136
137 PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxParticleSystem::setSolverIterationCounts() not allowed while simulation is running. Call will be ignored.")
138
139 mCore.setSolverIterationCounts((minVelocityIters & 0xff) << 8 | (minPositionIters & 0xff));
140
141 //UPDATE_PVD_PROPERTY
142 }
143
144 virtual void getSolverIterationCounts(PxU32& minPositionIters, PxU32& minVelocityIters) const
145 {
146 NP_READ_CHECK(NpBase::getNpScene());
147
148 PxU16 x = mCore.getSolverIterationCounts();
149 minVelocityIters = PxU32(x >> 8);
150 minPositionIters = PxU32(x & 0xff);
151 }
152
153 virtual PxCudaContextManager* getCudaContextManager() const { return mCudaContextManager; }
154
155 virtual void setRestOffset(PxReal restOffset) { scSetRestOffset(restOffset); }
156 virtual PxReal getRestOffset() const { return mCore.getRestOffset(); }
157
158 virtual void setContactOffset(PxReal contactOffset) { scSetContactOffset(contactOffset); }
159 virtual PxReal getContactOffset() const { return mCore.getContactOffset(); }
160
161 virtual void setParticleContactOffset(PxReal particleContactOffset) { scSetParticleContactOffset(particleContactOffset); }
162 virtual PxReal getParticleContactOffset() const { return mCore.getParticleContactOffset(); }
163
164 virtual void setSolidRestOffset(PxReal solidRestOffset) { scSetSolidRestOffset(solidRestOffset); }
165 virtual PxReal getSolidRestOffset() const { return mCore.getSolidRestOffset(); }
166
167 virtual void setMaxDepenetrationVelocity(PxReal v) {scSetMaxDepenetrationVelocity(v); }
168 virtual PxReal getMaxDepenetrationVelocity(){ return mCore.getMaxDepenetrationVelocity(); }
169
170 virtual void setMaxVelocity(PxReal v) { scSetMaxVelocity(v); }
171 virtual PxReal getMaxVelocity() { return mCore.getMaxVelocity(); }
172
173 virtual void setParticleSystemCallback(PxParticleSystemCallback* callback) { mCore.setParticleSystemCallback(callback); }
174 virtual PxParticleSystemCallback* getParticleSystemCallback() const { return mCore.getParticleSystemCallback(); }
175 // TOFIX
176 virtual void enableCCD(bool enable) { scSnableCCD(enable); }
177
178 virtual PxU32 createPhase(PxParticleMaterial* material, PxParticlePhaseFlags flags) = 0;
179
180 virtual PxFilterData getSimulationFilterData() const
181 {
182 return mCore.getShapeCore().getSimulationFilterData();
183 }
184
185 virtual void setSimulationFilterData(const PxFilterData& data)
186 {
187 mCore.getShapeCore().setSimulationFilterData(data);
188 }
189
190 virtual void setParticleFlag(PxParticleFlag::Enum flag, bool val)
191 {
192 PxParticleFlags flags = mCore.getFlags();
193 if (val)
194 flags.raise(flag);
195 else
196 flags.clear(flag);
197 mCore.setFlags(flags);
198 }
199
200 virtual void setParticleFlags(PxParticleFlags flags)
201 {
202 mCore.setFlags(flags);
203 }
204
205 virtual PxParticleFlags getParticleFlags() const
206 {
207 return mCore.getFlags();
208 }
209
210
211 void setSolverType(const PxParticleSolverType::Enum solverType) { scSetSolverType(solverType); }
212 virtual PxParticleSolverType::Enum getSolverType() const { return mCore.getSolverType(); }
213
214
215 virtual PxU32 getNbParticleMaterials() const
216 {
217 const Sc::ParticleSystemShapeCore& shapeCore = mCore.getShapeCore();
218 return shapeCore.getNbMaterialIndices();
219 }
220
221 virtual void setPeriodicBoundary(const PxVec3& boundary)
222 {
223 mCore.setPeriodicBoundary(boundary);
224 scSetDirtyFlag();
225 }
226
227
228 virtual PxVec3 getPeriodicBoundary() const
229 {
230 return mCore.getPeriodicBoundary();
231 }
232
233 virtual void addParticleBuffer(PxParticleBuffer* userBuffer) = 0;
234 virtual void removeParticleBuffer(PxParticleBuffer* userBuffer) = 0;
235
236 virtual PxU32 getGpuParticleSystemIndex()
237 {
238 NP_READ_CHECK(NpBase::getNpScene());
239 PX_CHECK_AND_RETURN_VAL(NpBase::getNpScene(), "NpParticleSystem::getGpuParticleSystemIndex: particle system must be in a scene.", 0xffffffff);
240
241 if (NpBase::getNpScene()->getFlags() & PxSceneFlag::eSUPPRESS_READBACK)
242 return mCore.getSim()->getLowLevelParticleSystem()->getGpuRemapId();
243 return 0xffffffff;
244 }
245
246 PX_FORCE_INLINE const Sc::ParticleSystemCore& getCore() const { return mCore; }
247 PX_FORCE_INLINE Sc::ParticleSystemCore& getCore() { return mCore; }
248 static PX_FORCE_INLINE size_t getCoreOffset() { return PX_OFFSET_OF_RT(NpParticleSystem, mCore); }
249
250 PX_INLINE void scSetDirtyFlag()
251 {
252 NP_READ_CHECK(NpBase::getNpScene());
253 NpScene* scene = NpBase::getNpScene();
254 if (scene)
255 {
256 mCore.getSim()->getLowLevelParticleSystem()->mFlag |= Dy::ParticleSystemFlag::eUPDATE_PARAMS;
257 }
258 }
259
260 PX_INLINE void scSetSleepThreshold(const PxReal v)
261 {
262 PX_ASSERT(!NpBase::isAPIWriteForbidden());
263 mCore.setSleepThreshold(v);
264 //UPDATE_PVD_PROPERTY
265 }
266
267 PX_INLINE void scSetRestOffset(const PxReal v)
268 {
269 PX_ASSERT(!NpBase::isAPIWriteForbidden());
270 mCore.setRestOffset(v);
271 scSetDirtyFlag();
272 //UPDATE_PVD_PROPERTY
273 }
274
275 PX_INLINE void scSetContactOffset(const PxReal v)
276 {
277 PX_ASSERT(!NpBase::isAPIWriteForbidden());
278 mCore.setContactOffset(v);
279 scSetDirtyFlag();
280 //UPDATE_PVD_PROPERTY
281 }
282
283 PX_INLINE void scSetParticleContactOffset(const PxReal v)
284 {
285 PX_ASSERT(!NpBase::isAPIWriteForbidden());
286 mCore.setParticleContactOffset(v);
287 scSetDirtyFlag();
288 //UPDATE_PVD_PROPERTY
289 }
290
291 PX_INLINE void scSetSolidRestOffset(const PxReal v)
292 {
293 PX_ASSERT(!NpBase::isAPIWriteForbidden());
294 mCore.setSolidRestOffset(v);
295 scSetDirtyFlag();
296 //UPDATE_PVD_PROPERTY
297 }
298
299 PX_INLINE void scSetFluidRestOffset(const PxReal v)
300 {
301 PX_ASSERT(!NpBase::isAPIWriteForbidden());
302 mCore.setFluidRestOffset(v);
303 scSetDirtyFlag();
304 //UPDATE_PVD_PROPERTY
305 }
306
307 PX_INLINE void scSetGridSizeX(const PxU32 v)
308 {
309 PX_ASSERT(!NpBase::isAPIWriteForbidden());
310 mCore.setGridSizeX(v);
311 //UPDATE_PVD_PROPERTY
312 }
313
314 PX_INLINE void scSetGridSizeY(const PxU32 v)
315 {
316 PX_ASSERT(!NpBase::isAPIWriteForbidden());
317 mCore.setGridSizeY(v);
318 //UPDATE_PVD_PROPERTY
319 }
320
321 PX_INLINE void scSetGridSizeZ(const PxU32 v)
322 {
323 PX_ASSERT(!NpBase::isAPIWriteForbidden());
324 mCore.setGridSizeZ(v);
325 //UPDATE_PVD_PROPERTY
326 }
327
328 PX_INLINE void scSnableCCD(const bool enable)
329 {
330 PX_ASSERT(!NpBase::isAPIWriteForbidden());
331 mCore.enableCCD(enable);
332 scSetDirtyFlag();
333 //UPDATE_PVD_PROPERTY
334 }
335
336 PX_INLINE void scSetWind(const PxVec3& v)
337 {
338 PX_ASSERT(!NpBase::isAPIWriteForbidden());
339 mCore.setWind(v);
340 scSetDirtyFlag();
341 //UPDATE_PVD_PROPERTY
342 }
343
344 PX_INLINE void scSetMaxDepenetrationVelocity(const PxReal v)
345 {
346 PX_CHECK_AND_RETURN(v > 0.f, "PxParticleSystem::setMaxDepenetrationVelocity: Max Depenetration Velocity must be > 0!");
347 PX_ASSERT(!NpBase::isAPIWriteForbidden());
348 mCore.setMaxDepenetrationVelocity(v);
349 scSetDirtyFlag();
350 //UPDATE_PVD_PROPERTY
351 }
352
353 PX_INLINE void scSetMaxVelocity(const PxReal v)
354 {
355 PX_CHECK_AND_RETURN(v > 0.f, "PxParticleSystem::setMaxVelocity: Max Velocity must be > 0!");
356 PX_ASSERT(!NpBase::isAPIWriteForbidden());
357 mCore.setMaxVelocity(v);
358 scSetDirtyFlag();
359 //UPDATE_PVD_PROPERTY
360 }
361
362 PX_INLINE void scSetSolverType(const PxParticleSolverType::Enum solverType)
363 {
364 PX_ASSERT(!NpBase::isAPIWriteForbidden());
365 mCore.setSolverType(solverType);
366 //UPDATE_PVD_PROPERTY
367 }
368
369#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
370 PX_INLINE void scSetSparseGridParams(const PxSparseGridParams& params)
371 {
372 PX_CHECK_AND_RETURN(params.subgridSizeX > 1 && params.subgridSizeX % 2 == 0, "PxParticleSystem::setSparseGridParams: Sparse grid subgridSizeX must be > 1 and even number!");
373 PX_CHECK_AND_RETURN(params.subgridSizeY > 1 && params.subgridSizeY % 2 == 0, "PxParticleSystem::setSparseGridParams: Sparse grid subgridSizeY must be > 1 and even number!");
374 PX_CHECK_AND_RETURN(params.subgridSizeZ > 1 && params.subgridSizeZ % 2 == 0, "PxParticleSystem::setSparseGridParams: Sparse grid subgridSizeZ must be > 1 and even number!");
375 PX_ASSERT(!NpBase::isAPIWriteForbidden());
376 mCore.setSparseGridParams(params);
377 //UPDATE_PVD_PROPERTY
378 }
379#endif
380
381#if PX_ENABLE_DEBUG_VISUALIZATION
382 virtual void visualize(PxRenderOutput& out, NpScene& npScene) const = 0;
383#else
384 PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION
385#endif
386 // Debug name
387 void setName(const char* debugName)
388 {
389 NP_WRITE_CHECK(NpBase::getNpScene());
390 NpActor::mName = debugName;
391 }
392
393 const char* getName() const
394 {
395 NP_READ_CHECK(NpBase::getNpScene());
396 return NpActor::mName;
397 }
398
399 virtual void setGridSizeX(PxU32 gridSizeX) { scSetGridSizeX(gridSizeX); }
400 virtual void setGridSizeY(PxU32 gridSizeY) { scSetGridSizeY(gridSizeY); }
401 virtual void setGridSizeZ(PxU32 gridSizeZ) { scSetGridSizeZ(gridSizeZ); }
402
403 protected:
405 PxCudaContextManager* mCudaContextManager;
406 PxU32 mNextPhaseGroupID;
407 };
408
409
411 {
412 public:
413 NpParticleClothPreProcessor(PxCudaContextManager* cudaContextManager) : mCudaContextManager(cudaContextManager), mNbPartitions(0){}
415
416 virtual void release();
417
419
420 private:
421 PxU32 computeSpringPartition(const PxParticleSpring& springs, const PxU32 partitionStartIndex, PxU32* partitionProgresses);
422
423 PxU32* partitions(const PxParticleSpring* springs, PxU32* orderedSpringIndices);
424
425 PxU32 combinePartitions(const PxParticleSpring* springs, const PxU32* orderedSpringIndices, const PxU32* accumulatedSpringsPerPartition,
426 PxU32* accumulatedSpringsPerCombinedPartitions, PxParticleSpring* orderedSprings, PxU32* accumulatedCopiesPerParticles, PxU32* remapOutput);
427
428 void classifySprings(const PxParticleSpring* springs, PxU32* partitionProgresses, PxU32* tempSprings, physx::PxArray<PxU32>& springsPerPartition);
429
430 void writeSprings(const PxParticleSpring* springs, PxU32* partitionProgresses, PxU32* tempSprings, PxU32* orderedSprings,
431 PxU32* accumulatedSpringsPerPartition);
432
433
434 PxCudaContextManager* mCudaContextManager;
435
436 PxU32 mNumSprings;
437 PxU32 mNbPartitions;
438 PxU32 mNumParticles;
439 PxU32 mMaxSpringsPerPartition;
440 };
441
442
443 class NpPBDParticleSystem : public NpParticleSystem<PxPBDParticleSystem>
444 {
445 public:
446
447 NpPBDParticleSystem(PxU32 maxNeighborhood, PxCudaContextManager& contextManager);
448
449 virtual ~NpPBDParticleSystem(){}
450
451 virtual PxU32 createPhase(PxParticleMaterial* material, PxParticlePhaseFlags flags) PX_OVERRIDE;
452
453 virtual void release();
454
455
456 virtual void setWind(const PxVec3& wind) { scSetWind(wind); }
457 virtual PxVec3 getWind() const { return mCore.getWind(); }
458
459 virtual void setFluidBoundaryDensityScale(PxReal fluidBoundaryDensityScale) { scSetFluidBoundaryDensityScale(fluidBoundaryDensityScale); }
460 virtual PxReal getFluidBoundaryDensityScale() const { return mCore.getFluidBoundaryDensityScale(); }
461
462 virtual void setFluidRestOffset(PxReal fluidRestOffset) { scSetFluidRestOffset(fluidRestOffset); }
463 virtual PxReal getFluidRestOffset() const { return mCore.getFluidRestOffset(); }
464
465
466#if PX_ENABLE_DEBUG_VISUALIZATION
467 virtual void visualize(PxRenderOutput& out, NpScene& npScene) const;
468#else
469 PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION
470#endif
471
472 //external API
473 virtual PxActorType::Enum getType() const { return PxActorType::ePBD_PARTICLESYSTEM; }
474
475 virtual void addParticleBuffer(PxParticleBuffer* particleBuffer);
476 virtual void removeParticleBuffer(PxParticleBuffer* particleBuffer);
477
478 virtual void addRigidAttachment(PxRigidActor* actor);
479 virtual void removeRigidAttachment(PxRigidActor* actor);
480
481 private:
482
483 PX_FORCE_INLINE void scSetFluidBoundaryDensityScale(const PxReal v)
484 {
485 PX_ASSERT(!NpBase::isAPIWriteForbidden());
486 mCore.setFluidBoundaryDensityScale(v);
487 scSetDirtyFlag();
488 //UPDATE_PVD_PROPERTY
489 }
490 };
491
492#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
493 class NpFLIPParticleSystem : public NpParticleSystem<PxFLIPParticleSystem>
494 {
495 public:
496
497 NpFLIPParticleSystem(PxCudaContextManager& contextManager);
498
499 virtual ~NpFLIPParticleSystem() {}
500
501 virtual PxU32 createPhase(PxParticleMaterial* material, PxParticlePhaseFlags flags) PX_OVERRIDE;
502 virtual void release();
503
504 virtual void setSparseGridParams(const PxSparseGridParams& params) { scSetSparseGridParams(params); }
505 virtual PxSparseGridParams getSparseGridParams() const { return mCore.getSparseGridParams(); }
506
507 virtual void* getSparseGridDataPointer(PxSparseGridDataFlag::Enum flags);
508
509 virtual void getSparseGridCoord(PxI32& x, PxI32& y, PxI32& z, PxU32 id);
510
511 virtual void setFLIPParams(const PxFLIPParams& params) { scSetFLIPParams(params); }
512 virtual PxFLIPParams getFLIPParams() const { return mCore.getFLIPParams(); }
513
514#if PX_ENABLE_DEBUG_VISUALIZATION
515 virtual void visualize(PxRenderOutput& out, NpScene& npScene) const;
516#else
517 PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION
518#endif
519
520 virtual void addParticleBuffer(PxParticleBuffer* particleBuffer);
521 virtual void removeParticleBuffer(PxParticleBuffer* particleBuffer);
522
523 virtual void addRigidAttachment(PxRigidActor* /*actor*/) {}
524 virtual void removeRigidAttachment(PxRigidActor* /*actor*/) {}
525
526 //external API
527 virtual PxActorType::Enum getType() const { return PxActorType::eFLIP_PARTICLESYSTEM; }
528
529
530
531 private:
532
533 PX_FORCE_INLINE void scSetFLIPParams(const PxFLIPParams& params)
534 {
535 PX_CHECK_AND_RETURN(params.blendingFactor >= 0.f && params.blendingFactor <= 1.f, "PxParticleSystem::setFLIPParams: FLIP blending factor must be >= 0 and <= 1!");
536 PX_ASSERT(!isAPIWriteForbidden());
537 mCore.setFLIPParams(params);
538 //UPDATE_PVD_PROPERTY
539 }
540
541 };
542
543 class NpMPMParticleSystem :public NpParticleSystem<PxMPMParticleSystem>
544 {
545 public:
546
547 NpMPMParticleSystem(PxCudaContextManager& contextManager);
548
549 virtual ~NpMPMParticleSystem() {}
550
551 virtual PxU32 createPhase(PxParticleMaterial* material, PxParticlePhaseFlags flags) PX_OVERRIDE;
552 virtual void release();
553
554 virtual void setSparseGridParams(const PxSparseGridParams& params) { scSetSparseGridParams(params); }
555 virtual PxSparseGridParams getSparseGridParams() const { return mCore.getSparseGridParams(); }
556
557 virtual void* getSparseGridDataPointer(PxSparseGridDataFlag::Enum flags);
558
559 virtual void getSparseGridCoord(PxI32& x, PxI32& y, PxI32& z, PxU32 id);
560
561 virtual void setMPMParams(const PxMPMParams& params) { scSetMPMParams(params); }
562 virtual PxMPMParams getMPMParams() const { return mCore.getMPMParams(); }
563
564 virtual void* getMPMDataPointer(PxMPMParticleDataFlag::Enum flags);
565#if PX_ENABLE_DEBUG_VISUALIZATION
566 virtual void visualize(PxRenderOutput& out, NpScene& npScene) const;
567#else
568 PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION
569#endif
570
571 virtual void addParticleBuffer(PxParticleBuffer* particleBuffer);
572 virtual void removeParticleBuffer(PxParticleBuffer* particleBuffer);
573
574 virtual void addRigidAttachment(PxRigidActor* actor);
575 virtual void removeRigidAttachment(PxRigidActor* actor);
576
577 //external API
578 virtual PxActorType::Enum getType() const { return PxActorType::eMPM_PARTICLESYSTEM; }
579
580 private:
581 PX_INLINE void scSetMPMParams(const PxMPMParams& params)
582 {
583 mCore.setMPMParams(params);
584 //UPDATE_PVD_PROPERTY
585 }
586 };
587
588 class NpCustomParticleSystem : public NpParticleSystem<PxCustomParticleSystem>
589 {
590 public:
591
592 NpCustomParticleSystem(PxCudaContextManager& contextManager, PxU32 maxNeighborhood);
593
594 virtual ~NpCustomParticleSystem() {}
595
596 virtual void release();
597
598
599
600 virtual void setSparseGridParams(const PxSparseGridParams& params) { scSetSparseGridParams(params); }
601 virtual PxSparseGridParams getSparseGridParams() const { return mCore.getSparseGridParams(); }
602
603 virtual void* getSparseGridDataPointer(PxSparseGridDataFlag::Enum flags);
604
605 virtual void getSparseGridCoord(PxI32& x, PxI32& y, PxI32& z, PxU32 id);
606
607 virtual PxU32 createPhase(PxParticleMaterial* material, PxParticlePhaseFlags flags) PX_OVERRIDE;
608
609#if PX_ENABLE_DEBUG_VISUALIZATION
610 virtual void visualize(PxRenderOutput& out, NpScene& npScene) const;
611#else
612 PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION
613#endif
614
615 virtual void addParticleBuffer(PxParticleBuffer* particleBuffer);
616 virtual void removeParticleBuffer(PxParticleBuffer* particleBuffer);
617
618 virtual void addRigidAttachment(PxRigidActor* /*actor*/) {}
619 virtual void removeRigidAttachment(PxRigidActor* /*actor*/) {}
620
621 //external API
622 virtual PxActorType::Enum getType() const { return PxActorType::eCUSTOM_PARTICLESYSTEM; }
623
624 virtual void setCustomParticleCallback(PxCustomParticleSystemSolverCallback* callback);
625 virtual PxCustomParticleSystemSolverCallback* getCustomParticleCallback() const;
626 };
627#endif
628
629}
630#endif
Definition NpActorTemplate.h:54
Definition NpParticleSystem.h:444
Definition NpParticleSystem.h:411
virtual void release()
Release this object and deallocate all the memory.
virtual void partitionSprings(const PxParticleClothDesc &clothDesc, PxPartitionedParticleCloth &output) PX_OVERRIDE
Partition the spring constraints for particle cloth simulation.
Definition NpParticleSystem.h:84
Definition NpScene.h:130
Definition PxArray.h:53
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isValid() const
Definition PxBounds3.h:482
static PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 empty()
Return empty bounds.
Definition PxBounds3.h:284
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getCenter() const
returns the center of this axis aligned box.
Definition PxBounds3.h:396
static PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 centerExtents(const PxVec3 &center, const PxVec3 &extent)
returns the AABB from center and extents vectors.
Definition PxBounds3.h:299
PX_CUDA_CALLABLE PX_FORCE_INLINE float getExtents(uint32_t axis) const
get component of the box's extents along a given axis
Definition PxBounds3.h:408
The shared base class for all particle buffers, can be instantiated directly to simulate granular and...
Definition PxParticleBuffer.h:81
Preprocessor to prepare particle cloths for simulation.
Definition PxParticleBuffer.h:569
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
Definition PxRenderOutput.h:50
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
Binary serialization context class.
Definition PxSerialFramework.h:99
Definition PxUserAllocated.h:43
3 Element vector class.
Definition PxVec3.h:50
Definition ScParticleSystemCore.h:51
Definition ScParticleSystemShapeCore.h:48
Definition ScParticleSystemSim.h:42
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_OVERRIDE
Definition PxPreprocessor.h:375
PX_C_EXPORT PX_FOUNDATION_API physx::PxFoundation &PX_CALL_CONV PxGetFoundation()
Retrieves the Foundation SDK after it has been created.
Definition FdFoundation.cpp:279
#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
Enum
Definition PxActor.h:121
@ ePBD_PARTICLESYSTEM
A PBD ParticleSystem.
Definition PxActor.h:157
@ eINVALID_OPERATION
method was called at a time when an operation is not possible
Definition PxErrors.h:65
PxFilterData is user-definable data which gets passed into the collision filtering shader and/or call...
Definition PxFiltering.h:365
Structure to describe the set of particle cloths in the same #PxParticleClothBuffer....
Definition PxParticleBuffer.h:372
Enum
Definition PxParticleSystem.h:120
Enum
Definition PxParticleSolverType.h:53
Structure to describe the output of the particle cloth preprocessing. Used as an input to specify clo...
Definition PxParticleBuffer.h:395
Parameters to define the sparse grid settings like grid spacing, maximal number of subgrids etc.
Definition PxSparseGridParams.h:46
PxU16 subgridSizeZ
Subgrid resolution in z dimension (must be an even number)
Definition PxSparseGridParams.h:109
PxU16 subgridSizeY
Subgrid resolution in y dimension (must be an even number)
Definition PxSparseGridParams.h:108
PxU16 subgridSizeX
Subgrid resolution in x dimension (must be an even number)
Definition PxSparseGridParams.h:107