RavEngine
Loading...
Searching...
No Matches
NpScene.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_SCENE_H
30#define NP_SCENE_H
31
32#define NEW_DIRTY_SHADERS_CODE
33
34#include "foundation/PxUserAllocated.h"
35#include "foundation/PxHashSet.h"
36#include "foundation/PxSync.h"
37#include "foundation/PxArray.h"
38#include "foundation/PxThread.h"
39#include "PxPhysXConfig.h"
40
41#include "CmRenderBuffer.h"
42#include "CmIDPool.h"
43
44#if PX_SUPPORT_GPU_PHYSX
45 #include "device/PhysXIndicator.h"
46#endif
47
48#include "NpSceneQueries.h"
49#include "NpSceneAccessor.h"
50#include "NpPruningStructure.h"
51
52#if PX_SUPPORT_PVD
53 #include "PxPhysics.h"
54 #include "NpPvdSceneClient.h"
55#endif
56
57#include "ScScene.h"
58
59namespace physx
60{
61namespace Sc
62{
63 class Joint;
64 class ConstraintBreakEvent;
65}
66
67namespace Sq
68{
69 class PrunerManager;
70}
71
72class PhysicsThread;
73class NpMaterial;
74class NpScene;
75class NpArticulationReducedCoordinate;
76class NpAggregate;
77class NpObjectFactory;
78class NpRigidStatic;
79class NpRigidDynamic;
80class NpConstraint;
81class NpArticulationLink;
82class NpArticulationJointReducedCoordinate;
83class NpArticulationAttachment;
84class NpArticulationTendonJoint;
85class NpArticulationSpatialTendon;
86class NpArticulationFixedTendon;
87class NpArticulationSensor;
88class NpShapeManager;
89class NpBatchQuery;
90class NpActor;
91class NpShape;
92class NpPhysics;
93
94#if PX_SUPPORT_GPU_PHYSX
95class NpSoftBody;
96class NpFEMCloth;
97class NpHairSystem;
98
99class NpPBDParticleSystem;
100class NpFLIPParticleSystem;
101class NpMPMParticleSystem;
102class NpCustomParticleSystem;
103class NpFEMSoftBodyMaterial;
104class NpFEMClothMaterial;
105class NpPBDMaterial;
106class NpFLIPMaterial;
107class NpMPMMaterial;
108class NpCustomMaterial;
109#endif
110
112{
113 NpScene* mScene;
114 const PxContactPairHeader* mContactPairHeaders;
115 uint32_t mNbContactPairHeaders;
116
117public:
118
119 void setData(NpScene* scene, const PxContactPairHeader* contactPairHeaders, const uint32_t nbContactPairHeaders);
120
121 virtual void run();
122
123 virtual const char* getName() const
124 {
125 return "NpContactCallbackTask";
126 }
127};
128
130{
131 //virtual interfaces:
132
133 PX_NOCOPY(NpScene)
134 public:
135
136 virtual void release();
137
138 virtual void setFlag(PxSceneFlag::Enum flag, bool value);
139 virtual PxSceneFlags getFlags() const;
140
141 // implement PxScene:
142
143 virtual void setGravity(const PxVec3&);
144 virtual PxVec3 getGravity() const;
145
146 virtual void setBounceThresholdVelocity(const PxReal t);
147 virtual PxReal getBounceThresholdVelocity() const;
148 virtual void setMaxBiasCoefficient(const PxReal t);
149 virtual PxReal getMaxBiasCoefficient() const;
150 virtual void setFrictionOffsetThreshold(const PxReal t);
151 virtual PxReal getFrictionOffsetThreshold() const;
152 virtual void setFrictionCorrelationDistance(const PxReal t);
153 virtual PxReal getFrictionCorrelationDistance() const;
154
155 virtual void setLimits(const PxSceneLimits& limits);
156 virtual PxSceneLimits getLimits() const;
157
158 virtual bool addActor(PxActor& actor, const PxBVH* bvh);
159 virtual void removeActor(PxActor& actor, bool wakeOnLostTouch);
160
161 virtual PxU32 getNbConstraints() const;
162 virtual PxU32 getConstraints(PxConstraint** buffer, PxU32 bufferSize, PxU32 startIndex=0) const;
163
165 virtual void removeArticulation(PxArticulationReducedCoordinate&, bool wakeOnLostTouch);
166
167 virtual PxU32 getNbArticulations() const;
168 virtual PxU32 getArticulations(PxArticulationReducedCoordinate** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const;
169
170 virtual PxU32 getNbSoftBodies() const;
171 virtual PxU32 getSoftBodies(PxSoftBody** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const;
172
173 virtual PxU32 getNbParticleSystems(PxParticleSolverType::Enum type) const;
174 virtual PxU32 getParticleSystems(PxParticleSolverType::Enum type, PxParticleSystem** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const;
175
176 virtual PxU32 getNbFEMCloths() const;
177 virtual PxU32 getFEMCloths(PxFEMCloth** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const;
178
179 virtual PxU32 getNbHairSystems() const;
180 virtual PxU32 getHairSystems(PxHairSystem** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const;
181
182 // Aggregates
183 virtual bool addAggregate(PxAggregate&);
184 virtual void removeAggregate(PxAggregate&, bool wakeOnLostTouch);
185 virtual PxU32 getNbAggregates() const;
186 virtual PxU32 getAggregates(PxAggregate** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const;
187
188 virtual bool addCollection(const PxCollection& collection);
189
190 // Groups
191 virtual void setDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2, const PxDominanceGroupPair& dominance);
193
194 // Actors
195 virtual PxU32 getNbActors(PxActorTypeFlags types) const;
196 virtual PxU32 getActors(PxActorTypeFlags types, PxActor** buffer, PxU32 bufferSize, PxU32 startIndex=0) const;
197 virtual PxActor** getActiveActors(PxU32& nbActorsOut);
198
199 // Run
200 virtual void getSimulationStatistics(PxSimulationStatistics& s) const;
201
202 // Multiclient
203 virtual PxClientID createClient();
204
205 // FrictionModel
207
208 // Callbacks
215 virtual void setBroadPhaseCallback(PxBroadPhaseCallback* callback);
217
218 //CCD
219 virtual void setCCDMaxPasses(PxU32 ccdMaxPasses);
220 virtual PxU32 getCCDMaxPasses() const;
221 virtual void setCCDMaxSeparation(const PxReal t);
222 virtual PxReal getCCDMaxSeparation() const;
223 virtual void setCCDThreshold(const PxReal t);
224 virtual PxReal getCCDThreshold() const;
225
226 // Collision filtering
227 virtual void setFilterShaderData(const void* data, PxU32 dataSize);
228 virtual const void* getFilterShaderData() const;
229 virtual PxU32 getFilterShaderDataSize() const;
232 virtual bool resetFiltering(PxActor& actor);
233 virtual bool resetFiltering(PxRigidActor& actor, PxShape*const* shapes, PxU32 shapeCount);
236
237 // Get Physics SDK
238 virtual PxPhysics& getPhysics();
239
240 // new API methods
241 virtual bool simulate(PxReal elapsedTime, physx::PxBaseTask* completionTask, void* scratchBlock, PxU32 scratchBlockSize, bool controlSimulation);
242 virtual bool advance(physx::PxBaseTask* completionTask);
243 virtual bool collide(PxReal elapsedTime, physx::PxBaseTask* completionTask, void* scratchBlock, PxU32 scratchBlockSize, bool controlSimulation = true);
244 virtual bool checkResults(bool block);
245 virtual bool checkCollision(bool block);
246 virtual bool fetchCollision(bool block);
247 virtual bool fetchResults(bool block, PxU32* errorState);
248 virtual bool fetchResultsStart(const PxContactPairHeader*& contactPairs, PxU32& nbContactPairs, bool block = false);
249 virtual void processCallbacks(physx::PxBaseTask* continuation);
250 virtual void fetchResultsFinish(PxU32* errorState = 0);
251
252 virtual void flush(bool sendPendingReports) { flushSimulation(sendPendingReports); }
253 virtual void flushSimulation(bool sendPendingReports);
254 virtual const PxRenderBuffer& getRenderBuffer();
255
256 virtual void setSolverBatchSize(PxU32 solverBatchSize);
257 virtual PxU32 getSolverBatchSize(void) const;
258
259 virtual void setSolverArticulationBatchSize(PxU32 solverBatchSize);
260 virtual PxU32 getSolverArticulationBatchSize(void) const;
261
262 virtual bool setVisualizationParameter(PxVisualizationParameter::Enum param, PxReal value);
264
265 virtual void setVisualizationCullingBox(const PxBounds3& box);
267
268 virtual PxTaskManager* getTaskManager() const { return mTaskManager; }
269 void checkBeginWrite() const {}
270
271 virtual PxCudaContextManager* getCudaContextManager() { return mCudaContextManager; }
272
273 virtual void setNbContactDataBlocks(PxU32 numBlocks);
274 virtual PxU32 getNbContactDataBlocksUsed() const;
275 virtual PxU32 getMaxNbContactDataBlocksUsed() const;
276
277 virtual PxU32 getContactReportStreamBufferSize() const;
278
279 virtual PxU32 getTimestamp() const;
280
281 virtual PxCpuDispatcher* getCpuDispatcher() const;
282 virtual PxCudaContextManager* getCudaContextManager() const;
283
284
286 virtual bool getBroadPhaseCaps(PxBroadPhaseCaps& caps) const;
287 virtual PxU32 getNbBroadPhaseRegions() const;
288 virtual PxU32 getBroadPhaseRegions(PxBroadPhaseRegionInfo* userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const;
289 virtual PxU32 addBroadPhaseRegion(const PxBroadPhaseRegion& region, bool populateRegion);
290 virtual bool removeBroadPhaseRegion(PxU32 handle);
291
292 virtual bool addActors(PxActor*const* actors, PxU32 nbActors);
293 virtual bool addActors(const PxPruningStructure& prunerStructure);
294 virtual void removeActors(PxActor*const* actors, PxU32 nbActors, bool wakeOnLostTouch);
295
296 virtual void lockRead(const char* file=NULL, PxU32 line=0);
297 virtual void unlockRead();
298
299 virtual void lockWrite(const char* file=NULL, PxU32 line=0);
300 virtual void unlockWrite();
301
302 virtual PxReal getWakeCounterResetValue() const;
303
304 virtual void shiftOrigin(const PxVec3& shift);
305
306 virtual PxPvdSceneClient* getScenePvdClient();
307
308 virtual void copyArticulationData(void* data, void* index, PxArticulationGpuDataType::Enum dataType, const PxU32 nbCopyArticulations, void* copyEvent);
309 virtual void applyArticulationData(void* data, void* index, PxArticulationGpuDataType::Enum dataType, const PxU32 nbUpdatedArticulations, void* waitEvent, void* signalEvent);
310 virtual void copyContactData(void* data, const PxU32 numContactPatches, void* numContactPairs, void* copyEvent);
311
312 virtual void copySoftBodyData(void** data, void* dataSizes, void* softBodyIndices, PxSoftBodyDataFlag::Enum flag, const PxU32 nbCopySoftBodies, const PxU32 maxSize, void* copyEvent);
313 virtual void applySoftBodyData(void** data, void* dataSizes, void* softBodyIndices, PxSoftBodyDataFlag::Enum flag, const PxU32 nbUpdatedSoftBodies, const PxU32 maxSize, void* applyEvent);
314
315 virtual void copyBodyData(PxGpuBodyData* data, PxGpuActorPair* index, const PxU32 nbCopyActors, void* copyEvent);
316 virtual void applyActorData(void* data, PxGpuActorPair* index, PxActorCacheFlag::Enum flag, const PxU32 nbUpdatedActors, void* waitEvent, void* signalEvent);
317
318 virtual void computeDenseJacobians(const PxIndexDataPair* indices, PxU32 nbIndices, void* computeEvent);
319 virtual void computeGeneralizedMassMatrices(const PxIndexDataPair* indices, PxU32 nbIndices, void* computeEvent);
320 virtual void computeGeneralizedGravityForces(const PxIndexDataPair* indices, PxU32 nbIndices, void* computeEvent);
321 virtual void computeCoriolisAndCentrifugalForces(const PxIndexDataPair* indices, PxU32 nbIndices, void* computeEvent);
322 virtual void applyParticleBufferData(const PxU32* indices, const PxGpuParticleBufferIndexPair* bufferIndexPairs, const PxParticleBufferFlags* flags, PxU32 nbUpdatedBuffers, void* waitEvent, void* signalEvent);
323
324 virtual PxSolverType::Enum getSolverType() const;
325
326 // NpSceneAccessor
327 virtual PxsSimulationController* getSimulationController();
328 virtual void setActiveActors(PxActor** actors, PxU32 nbActors);
329 virtual PxActor** getFrozenActors(PxU32& nbActorsOut);
330 virtual void setFrozenActorFlag(const bool buildFrozenActors);
331 virtual void forceSceneQueryRebuild();
332 virtual void frameEnd();
333 //~NpSceneAccessor
334
335 // PxSceneQuerySystemBase
336 virtual void setDynamicTreeRebuildRateHint(PxU32 dynamicTreeRebuildRateHint);
337 virtual PxU32 getDynamicTreeRebuildRateHint() const;
338 virtual void forceRebuildDynamicTree(PxU32 prunerIndex);
339 virtual void setUpdateMode(PxSceneQueryUpdateMode::Enum updateMode);
341 virtual PxU32 getStaticTimestamp() const;
342 virtual void flushUpdates();
343 virtual bool raycast(
344 const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, // Ray data
345 PxRaycastCallback& hitCall, PxHitFlags hitFlags,
346 const PxQueryFilterData& filterData, PxQueryFilterCallback* filterCall,
347 const PxQueryCache* cache, PxGeometryQueryFlags flags) const;
348
349 virtual bool sweep(
350 const PxGeometry& geometry, const PxTransform& pose, // GeomObject data
351 const PxVec3& unitDir, const PxReal distance, // Ray data
352 PxSweepCallback& hitCall, PxHitFlags hitFlags,
353 const PxQueryFilterData& filterData, PxQueryFilterCallback* filterCall,
354 const PxQueryCache* cache, const PxReal inflation, PxGeometryQueryFlags flags) const;
355
356 virtual bool overlap(
357 const PxGeometry& geometry, const PxTransform& transform, // GeomObject data
358 PxOverlapCallback& hitCall,
359 const PxQueryFilterData& filterData, PxQueryFilterCallback* filterCall,
360 const PxQueryCache* cache, PxGeometryQueryFlags flags) const;
361 //~PxSceneQuerySystemBase
362
363 // PxSceneSQSystem
366 virtual void sceneQueriesUpdate(physx::PxBaseTask* completionTask, bool controlSimulation);
367 virtual bool checkQueries(bool block);
368 virtual bool fetchQueries(bool block);
369 //~PxSceneSQSystem
370
371 //internal public methods:
372 public:
373 NpScene(const PxSceneDesc& desc, NpPhysics&);
374 ~NpScene();
375
376 PX_FORCE_INLINE NpSceneQueries& getNpSQ() { return mNpSQ; }
377 PX_FORCE_INLINE const NpSceneQueries& getNpSQ() const { return mNpSQ; }
378
379 PX_FORCE_INLINE PxSceneQuerySystem& getSQAPI() { return mNpSQ.getSQAPI(); }
380 PX_FORCE_INLINE const PxSceneQuerySystem& getSQAPI() const { return mNpSQ.getSQAPI(); }
381
382 PX_FORCE_INLINE PxU64 getContextId() const { return PxU64(this); }
383
384 PX_FORCE_INLINE PxTaskManager* getTaskManagerFast() const { return mTaskManager; }
385
386 PX_FORCE_INLINE Sc::SimulationStage::Enum getSimulationStage() const { return mScene.getSimulationStage(); }
387 PX_FORCE_INLINE void setSimulationStage(Sc::SimulationStage::Enum stage) { mScene.setSimulationStage(stage); }
388
389 bool addActorInternal(PxActor& actor, const PxBVH* bvh);
390 void removeActorInternal(PxActor& actor, bool wakeOnLostTouch, bool removeFromAggregate);
391 bool addActorsInternal(PxActor*const* PX_RESTRICT actors, PxU32 nbActors, const Sq::PruningStructure* ps = NULL);
392
393 bool addArticulationInternal(PxArticulationReducedCoordinate&);
394 void removeArticulationInternal(PxArticulationReducedCoordinate&, bool wakeOnLostTouch, bool removeFromAggregate);
395 // materials
396 void addMaterial(const NpMaterial& mat);
397 void updateMaterial(const NpMaterial& mat);
398 void removeMaterial(const NpMaterial& mat);
399#if PX_SUPPORT_GPU_PHYSX
400 void addMaterial(const NpFEMSoftBodyMaterial& mat);
401 void updateMaterial(const NpFEMSoftBodyMaterial& mat);
402 void removeMaterial(const NpFEMSoftBodyMaterial& mat);
403
404 void addMaterial(const NpFEMClothMaterial& mat);
405 void updateMaterial(const NpFEMClothMaterial& mat);
406 void removeMaterial(const NpFEMClothMaterial& mat);
407
408 void addMaterial(const NpPBDMaterial& mat);
409 void updateMaterial(const NpPBDMaterial& mat);
410 void removeMaterial(const NpPBDMaterial& mat);
411
412 void addMaterial(const NpFLIPMaterial& mat);
413 void updateMaterial(const NpFLIPMaterial& mat);
414 void removeMaterial(const NpFLIPMaterial& mat);
415
416 void addMaterial(const NpMPMMaterial& mat);
417 void updateMaterial(const NpMPMMaterial& mat);
418 void removeMaterial(const NpMPMMaterial& mat);
419
420 void addMaterial(const NpCustomMaterial& mat);
421 void updateMaterial(const NpCustomMaterial& mat);
422 void removeMaterial(const NpCustomMaterial& mat);
423#endif
424
425 void executeScene(PxBaseTask* continuation);
426 void executeCollide(PxBaseTask* continuation);
427 void executeAdvance(PxBaseTask* continuation);
428 void constraintBreakEventNotify(PxConstraint *const *constraints, PxU32 count);
429
430 bool loadFromDesc(const PxSceneDesc&);
431
432 template<typename T>
433 void removeFromRigidActorList(T&);
434 void removeFromRigidDynamicList(NpRigidDynamic&);
435 void removeFromRigidStaticList(NpRigidStatic&);
436 PX_FORCE_INLINE void removeFromArticulationList(PxArticulationReducedCoordinate&);
437 PX_FORCE_INLINE void removeFromSoftBodyList(PxSoftBody&);
438 PX_FORCE_INLINE void removeFromFEMClothList(PxFEMCloth&);
439 PX_FORCE_INLINE void removeFromParticleSystemList(PxPBDParticleSystem&);
440 PX_FORCE_INLINE void removeFromParticleSystemList(PxFLIPParticleSystem&);
441 PX_FORCE_INLINE void removeFromParticleSystemList(PxMPMParticleSystem&);
442 PX_FORCE_INLINE void removeFromParticleSystemList(PxCustomParticleSystem&);
443 PX_FORCE_INLINE void removeFromHairSystemList(PxHairSystem&);
444 PX_FORCE_INLINE void removeFromAggregateList(PxAggregate&);
445
446#ifdef NEW_DIRTY_SHADERS_CODE
447 void addDirtyConstraint(NpConstraint* constraint);
448#endif
449 void addToConstraintList(PxConstraint&);
450 void removeFromConstraintList(PxConstraint&);
451
452 void addArticulationLink(NpArticulationLink& link);
453 void addArticulationLinkBody(NpArticulationLink& link);
454 void addArticulationLinkConstraint(NpArticulationLink& link);
455 void removeArticulationLink(NpArticulationLink& link, bool wakeOnLostTouch);
456
457 void addArticulationAttachment(NpArticulationAttachment& attachment);
458 void removeArticulationAttachment(NpArticulationAttachment& attachment);
459
460 void addArticulationTendonJoint(NpArticulationTendonJoint& joint);
461 void removeArticulationTendonJoint(NpArticulationTendonJoint& joint);
462
463 void removeArticulationTendons(PxArticulationReducedCoordinate& articulation);
464 void removeArticulationSensors(PxArticulationReducedCoordinate& articulation);
465
467 {
468 enum Enum { eOK, eNO_LOCK, eIN_FETCHRESULTS, eRACE_DETECTED };
469 };
470
471 StartWriteResult::Enum startWrite(bool allowReentry);
472 void stopWrite(bool allowReentry);
473
474 bool startRead() const;
475 void stopRead() const;
476
477 PxU32 getReadWriteErrorCount() const { return PxU32(mConcurrentErrorCount); }
478
479#if PX_CHECKED
480 void checkPositionSanity(const PxRigidActor& a, const PxTransform& pose, const char* fnName) const;
481#endif
482
483#if PX_SUPPORT_GPU_PHYSX
484 void updatePhysXIndicator();
485#else
486 PX_FORCE_INLINE void updatePhysXIndicator() {}
487#endif
488
489 void scAddAggregate(NpAggregate&);
490 void scRemoveAggregate(NpAggregate&);
491
492 void scSwitchRigidToNoSim(NpActor&);
493 void scSwitchRigidFromNoSim(NpActor&);
494
495#if PX_SUPPORT_PVD
496 PX_FORCE_INLINE Vd::PvdSceneClient& getScenePvdClientInternal() { return mScenePvdClient; }
497 PX_FORCE_INLINE const Vd::PvdSceneClient& getScenePvdClientInternal() const { return mScenePvdClient; }
498#endif
499 PX_FORCE_INLINE bool isAPIReadForbidden() const { return mIsAPIReadForbidden; }
500 PX_FORCE_INLINE void setAPIReadToForbidden() { mIsAPIReadForbidden = true; }
501 PX_FORCE_INLINE void setAPIReadToAllowed() { mIsAPIReadForbidden = false; }
502
503 PX_FORCE_INLINE bool isCollisionPhaseActive() const { return mScene.isCollisionPhaseActive(); }
504
505 PX_FORCE_INLINE bool isAPIWriteForbidden() const { return mIsAPIWriteForbidden; }
506 PX_FORCE_INLINE void setAPIWriteToForbidden() { mIsAPIWriteForbidden = true; }
507 PX_FORCE_INLINE void setAPIWriteToAllowed() { mIsAPIWriteForbidden = false; }
508
509 PX_FORCE_INLINE const Sc::Scene& getScScene() const { return mScene; }
510 PX_FORCE_INLINE Sc::Scene& getScScene() { return mScene; }
511
512 PX_FORCE_INLINE PxU32 getFlagsFast() const { return mScene.getFlags(); }
513 PX_FORCE_INLINE PxReal getWakeCounterResetValueInternal() const { return mWakeCounterResetValue; }
514
515 // PT: TODO: consider merging the "sc" methods with the np ones, as we did for constraints
516
517 void scAddActor(NpRigidStatic&, bool noSim, PxBounds3* uninflatedBounds, const Gu::BVH* bvh);
518 void scRemoveActor(NpRigidStatic&, bool wakeOnLostTouch, bool noSim);
519 void scAddActor(NpRigidDynamic&, bool noSim, PxBounds3* uninflatedBounds, const Gu::BVH* bvh);
520 void scRemoveActor(NpRigidDynamic&, bool wakeOnLostTouch, bool noSim);
521 void scAddActor(NpArticulationLink&, bool noSim, PxBounds3* uninflatedBounds, const Gu::BVH* bvh);
522 void scRemoveActor(NpArticulationLink&, bool wakeOnLostTouch, bool noSim);
523
524#if PX_SUPPORT_GPU_PHYSX
525 void scAddSoftBody(NpSoftBody&);
526 void scRemoveSoftBody(NpSoftBody&);
527#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
528 void scAddFEMCloth(NpScene* npScene, NpFEMCloth&);
529 void scRemoveFEMCloth(NpFEMCloth&);
530#endif
531 void scAddParticleSystem(NpPBDParticleSystem&);
532 void scRemoveParticleSystem(NpPBDParticleSystem&);
533#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
534 void scAddParticleSystem(NpFLIPParticleSystem&);
535 void scRemoveParticleSystem(NpFLIPParticleSystem&);
536
537 void scAddParticleSystem(NpMPMParticleSystem&);
538 void scRemoveParticleSystem(NpMPMParticleSystem&);
539
540 void scAddParticleSystem(NpCustomParticleSystem&);
541 void scRemoveParticleSystem(NpCustomParticleSystem&);
542#endif
543 void scAddHairSystem(NpHairSystem&);
544 void scRemoveHairSystem(NpHairSystem&);
545#endif
546 void scAddArticulation(NpArticulationReducedCoordinate&);
547 void scRemoveArticulation(NpArticulationReducedCoordinate&);
548
549 void scAddArticulationJoint(NpArticulationJointReducedCoordinate&);
550 void scRemoveArticulationJoint(NpArticulationJointReducedCoordinate&);
551
552 void scAddArticulationSpatialTendon(NpArticulationSpatialTendon&);
553 void scRemoveArticulationSpatialTendon(NpArticulationSpatialTendon&);
554
555 void scAddArticulationFixedTendon(NpArticulationFixedTendon&);
556 void scRemoveArticulationFixedTendon(NpArticulationFixedTendon&);
557
558 void scAddArticulationSensor(NpArticulationSensor&);
559 void scRemoveArticulationSensor(NpArticulationSensor&);
560
561 void createInOmniPVD(const PxSceneDesc& desc);
562 PX_FORCE_INLINE void updatePvdProperties()
563 {
564#if PX_SUPPORT_PVD
565 // PT: TODO: shouldn't we test PxPvdInstrumentationFlag::eDEBUG here?
566 if(mScenePvdClient.isConnected())
567 mScenePvdClient.updatePvdProperties();
568#endif
569 }
570
571 void updateConstants(const PxArray<NpConstraint*>& constraints);
572
573 virtual PxgDynamicsMemoryConfig getGpuDynamicsConfig() const { return mGpuDynamicsConfig; }
574private:
575 bool checkResultsInternal(bool block);
576 bool checkCollisionInternal(bool block);
577 bool checkSceneQueriesInternal(bool block);
578 bool simulateOrCollide(PxReal elapsedTime, physx::PxBaseTask* completionTask, void* scratchBlock, PxU32 scratchBlockSize, bool controlSimulation, const char* invalidCallMsg, Sc::SimulationStage::Enum simStage);
579
580 bool addRigidStatic(NpRigidStatic& , const Gu::BVH* bvh, const Sq::PruningStructure* ps = NULL);
581 void removeRigidStatic(NpRigidStatic&, bool wakeOnLostTouch, bool removeFromAggregate);
582 bool addRigidDynamic(NpRigidDynamic& , const Gu::BVH* bvh, const Sq::PruningStructure* ps = NULL);
583 void removeRigidDynamic(NpRigidDynamic&, bool wakeOnLostTouch, bool removeFromAggregate);
584
585 bool addSoftBody(PxSoftBody&);
586 void removeSoftBody(PxSoftBody&, bool wakeOnLostTouch);
587
588 bool addParticleSystem(PxParticleSystem& particleSystem);
589 void removeParticleSystem(PxParticleSystem& particleSystem, bool wakeOnLostTouch);
590#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
591 bool addFEMCloth(PxFEMCloth&);
592 void removeFEMCloth(PxFEMCloth&, bool wakeOnLostTouch);
593
594 bool addHairSystem(PxHairSystem&);
595 void removeHairSystem(PxHairSystem&, bool wakeOnLostTouch);
596#endif
597 void visualize();
598
599 void updateDirtyShaders();
600
601 void fireOutOfBoundsCallbacks();
602 void fetchResultsPreContactCallbacks();
603 void fetchResultsPostContactCallbacks();
604 void fetchResultsParticleSystem();
605
606 bool addSpatialTendonInternal(NpArticulationReducedCoordinate* npaRC, Sc::ArticulationSim* scArtSim);
607 bool addFixedTendonInternal(NpArticulationReducedCoordinate* npaRC, Sc::ArticulationSim* scArtSim);
608
609 bool addArticulationSensorInternal(NpArticulationReducedCoordinate* npaRC, Sc::ArticulationSim* scArtSim);
610
611 void syncSQ();
612 void sceneQueriesStaticPrunerUpdate(PxBaseTask* continuation);
613 void sceneQueriesDynamicPrunerUpdate(PxBaseTask* continuation);
614
615 NpSceneQueries mNpSQ;
616 PxPruningStructureType::Enum mPrunerType[2];
617 typedef Cm::DelegateTask<NpScene, &NpScene::sceneQueriesStaticPrunerUpdate> SceneQueriesStaticPrunerUpdate;
618 typedef Cm::DelegateTask<NpScene, &NpScene::sceneQueriesDynamicPrunerUpdate> SceneQueriesDynamicPrunerUpdate;
619 SceneQueriesStaticPrunerUpdate mSceneQueriesStaticPrunerUpdate;
620 SceneQueriesDynamicPrunerUpdate mSceneQueriesDynamicPrunerUpdate;
621
622 Cm::RenderBuffer mRenderBuffer;
623 public:
624 Cm::IDPool mRigidActorIndexPool;
625 private:
626 PxArray<NpRigidDynamic*> mRigidDynamics; // no hash set used because it would be quite a bit slower when adding a large number of actors
627 PxArray<NpRigidStatic*> mRigidStatics; // no hash set used because it would be quite a bit slower when adding a large number of actors
628 PxCoalescedHashSet<PxArticulationReducedCoordinate*> mArticulations;
629 PxCoalescedHashSet<PxSoftBody*> mSoftBodies;
630 PxCoalescedHashSet<PxFEMCloth*> mFEMCloths;
631 PxCoalescedHashSet<PxPBDParticleSystem*> mPBDParticleSystems;
632 PxCoalescedHashSet<PxFLIPParticleSystem*> mFLIPParticleSystems;
633 PxCoalescedHashSet<PxMPMParticleSystem*> mMPMParticleSystems;
634 PxCoalescedHashSet<PxCustomParticleSystem*> mCustomParticleSystems;
635 PxCoalescedHashSet<PxHairSystem*> mHairSystems;
636 PxCoalescedHashSet<PxAggregate*> mAggregates;
637
638#ifdef NEW_DIRTY_SHADERS_CODE
639 PxArray<NpConstraint*> mAlwaysUpdatedConstraints;
640 PxArray<NpConstraint*> mDirtyConstraints;
641 PxMutex mDirtyConstraintsLock;
642#endif
643
644 PxBounds3 mSanityBounds;
645#if PX_SUPPORT_GPU_PHYSX
646 PhysXIndicator mPhysXIndicator;
647#endif
648
649 PxSync mPhysicsDone; // physics thread signals this when update ready
650 PxSync mCollisionDone; // physics thread signals this when all collisions ready
651 PxSync mSceneQueriesDone; // physics thread signals this when all scene queries update ready
652
653 //legacy timing settings:
654 PxReal mElapsedTime; //needed to transfer the elapsed time param from the user to the sim thread.
655
656 PxU32 mNbClients; // Tracks reserved clients for multiclient support.
657
658 struct SceneCompletion : public Cm::Task
659 {
660 SceneCompletion(PxU64 contextId, PxSync& sync) : Cm::Task(contextId), mSync(sync){}
661 virtual void runInternal() {}
662 //ML: As soon as mSync.set is called, and the scene is shutting down,
663 //the scene may be deleted. That means this running task may also be deleted.
664 //As such, we call mSync.set() inside release() to avoid a crash because the v-table on this
665 //task might be deleted between the call to runInternal() and release() in the worker thread.
666 virtual void release()
667 {
668 //We cache the continuation pointer because this class may be deleted
669 //as soon as mSync.set() is called if the application releases the scene.
670 PxBaseTask* c = mCont;
671 //once mSync.set(), fetchResults() will be allowed to run.
672 mSync.set();
673 //Call the continuation task that we cached above. If we use mCont or
674 //any other member variable of this class, there is a small chance
675 //that the variables might have become corrupted if the class
676 //was deleted.
677 if(c) c->removeReference();
678 }
679 virtual const char* getName() const { return "NpScene.completion"; }
680
681 // //This method just is called in the split sim approach as a way to set continuation after the task has been initialized
682 void setDependent(PxBaseTask* task){PX_ASSERT(mCont == NULL); mCont = task; if(task)task->addReference();}
683 PxSync& mSync;
684 private:
685 SceneCompletion& operator=(const SceneCompletion&);
686 };
687
688 typedef Cm::DelegateTask<NpScene, &NpScene::executeScene> SceneExecution;
689 typedef Cm::DelegateTask<NpScene, &NpScene::executeCollide> SceneCollide;
690 typedef Cm::DelegateTask<NpScene, &NpScene::executeAdvance> SceneAdvance;
691
692 PxTaskManager* mTaskManager;
693 PxCudaContextManager* mCudaContextManager;
694 SceneCompletion mSceneCompletion;
695 SceneCompletion mCollisionCompletion;
696 SceneCompletion mSceneQueriesCompletion;
697 SceneExecution mSceneExecution;
698 SceneCollide mSceneCollide;
699 SceneAdvance mSceneAdvance;
700 PxSQBuildStepHandle mStaticBuildStepHandle;
701 PxSQBuildStepHandle mDynamicBuildStepHandle;
702 bool mControllingSimulation;
703 bool mIsAPIReadForbidden; // Set to true when the user is not allowed to call certain read APIs
704 // (properties that get written to during the simulation. Search the macros PX_CHECK_SCENE_API_READ_FORBIDDEN...
705 // to see which calls)
706 bool mIsAPIWriteForbidden; // Set to true when the user is not allowed to do API write calls
707
708 PxU32 mSimThreadStackSize;
709
710 volatile PxI32 mConcurrentWriteCount;
711 mutable volatile PxI32 mConcurrentReadCount;
712 mutable volatile PxI32 mConcurrentErrorCount;
713
714 // TLS slot index, keeps track of re-entry depth for this thread
715 PxU32 mThreadReadWriteDepth;
716 PxThread::Id mCurrentWriter;
717 PxReadWriteLock mRWLock;
718
719 bool mSQUpdateRunning;
720
721 bool mHasSimulatedOnce;
722 bool mBetweenFetchResults;
723 bool mBuildFrozenActors;
724
725 //
726 public:
727 enum MATERIAL_EVENT
728 {
729 MATERIAL_ADD,
730 MATERIAL_UPDATE,
731 MATERIAL_REMOVE
732 };
733
735 {
736 public:
737 PX_FORCE_INLINE MaterialEvent(PxU16 handle, MATERIAL_EVENT type) : mHandle(handle), mType(type) {}
739
740 PxU16 mHandle;//handle to the master material table
741 MATERIAL_EVENT mType;
742 };
743 private:
744 PxArray<MaterialEvent> mSceneMaterialBuffer;
745 PxArray<MaterialEvent> mSceneFEMSoftBodyMaterialBuffer;
746 PxArray<MaterialEvent> mSceneFEMClothMaterialBuffer;
747 PxArray<MaterialEvent> mScenePBDMaterialBuffer;
748 PxArray<MaterialEvent> mSceneFLIPMaterialBuffer;
749 PxArray<MaterialEvent> mSceneMPMMaterialBuffer;
750 PxArray<MaterialEvent> mSceneCustomMaterialBuffer;
751 PxMutex mSceneMaterialBufferLock;
752 PxMutex mSceneFEMSoftBodyMaterialBufferLock;
753 PxMutex mSceneFEMClothMaterialBufferLock;
754 PxMutex mScenePBDMaterialBufferLock;
755 PxMutex mSceneFLIPMaterialBufferLock;
756 PxMutex mSceneMPMMaterialBufferLock;
757 PxMutex mSceneCustomMaterialBufferLock;
758 Sc::Scene mScene;
759#if PX_SUPPORT_PVD
760 Vd::PvdSceneClient mScenePvdClient;
761#endif
762 PxReal mWakeCounterResetValue;
763
764 PxgDynamicsMemoryConfig mGpuDynamicsConfig;
765
766 NpPhysics& mPhysics;
767};
768
769template<>
770PX_FORCE_INLINE void NpScene::removeFromRigidActorList<NpRigidDynamic>(NpRigidDynamic& rigidDynamic)
771{
772 removeFromRigidDynamicList(rigidDynamic);
773}
774
775template<>
776PX_FORCE_INLINE void NpScene::removeFromRigidActorList<NpRigidStatic>(NpRigidStatic& rigidStatic)
777{
778 removeFromRigidStaticList(rigidStatic);
779}
780
781PX_FORCE_INLINE void NpScene::removeFromArticulationList(PxArticulationReducedCoordinate& articulation)
782{
783 const bool exists = mArticulations.erase(&articulation);
784 PX_ASSERT(exists);
785 PX_UNUSED(exists);
786}
787
788PX_FORCE_INLINE void NpScene::removeFromSoftBodyList(PxSoftBody& softBody)
789{
790 const bool exists = mSoftBodies.erase(&softBody);
791 PX_ASSERT(exists);
792 PX_UNUSED(exists);
793}
794
795PX_FORCE_INLINE void NpScene::removeFromFEMClothList(PxFEMCloth& femCloth)
796{
797 const bool exists = mFEMCloths.erase(&femCloth);
798 PX_ASSERT(exists);
799 PX_UNUSED(exists);
800}
801
802PX_FORCE_INLINE void NpScene::removeFromParticleSystemList(PxPBDParticleSystem& particleSystem)
803{
804 const bool exists = mPBDParticleSystems.erase(&particleSystem);
805 PX_ASSERT(exists);
806 PX_UNUSED(exists);
807}
808
809#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
810PX_FORCE_INLINE void NpScene::removeFromParticleSystemList(PxFLIPParticleSystem& particleSystem)
811{
812 const bool exists = mFLIPParticleSystems.erase(&particleSystem);
813 PX_ASSERT(exists);
814 PX_UNUSED(exists);
815}
816
817PX_FORCE_INLINE void NpScene::removeFromParticleSystemList(PxMPMParticleSystem& particleSystem)
818{
819 const bool exists = mMPMParticleSystems.erase(&particleSystem);
820 PX_ASSERT(exists);
821 PX_UNUSED(exists);
822}
823
824PX_FORCE_INLINE void NpScene::removeFromParticleSystemList(PxCustomParticleSystem& particleSystem)
825{
826 const bool exists = mCustomParticleSystems.erase(&particleSystem);
827 PX_ASSERT(exists);
828 PX_UNUSED(exists);
829}
830#endif
831
832PX_FORCE_INLINE void NpScene::removeFromHairSystemList(PxHairSystem& hairSystem)
833{
834 const bool exists = mHairSystems.erase(&hairSystem);
835 PX_ASSERT(exists);
836 PX_UNUSED(exists);
837}
838
839PX_FORCE_INLINE void NpScene::removeFromAggregateList(PxAggregate& aggregate)
840{
841 const bool exists = mAggregates.erase(&aggregate);
842 PX_ASSERT(exists);
843 PX_UNUSED(exists);
844}
845
846
847 PxU32 NpRigidStaticGetShapes(NpRigidStatic& rigid, NpShape* const *& shapes);
848 PxU32 NpRigidDynamicGetShapes(NpRigidDynamic& actor, NpShape* const *& shapes, bool* isCompound = NULL);
849 PxU32 NpArticulationGetShapes(NpArticulationLink& actor, NpShape* const *& shapes, bool* isCompound = NULL);
850
851}
852
853#endif
Definition NpScene.h:112
virtual void run()
The user-implemented run method where the task's work should be performed.
Definition NpSceneFetchResults.cpp:416
virtual const char * getName() const
Return a user-provided task name for profiling purposes.
Definition NpScene.h:123
Definition NpPhysics.h:93
Definition NpRigidDynamic.h:41
Definition NpSceneAccessor.h:39
Definition NpScene.h:735
Definition NpScene.h:130
virtual PxCpuDispatcher * getCpuDispatcher() const
Return the cpu dispatcher that was set in PxSceneDesc::cpuDispatcher when creating the scene with PxP...
Definition NpScene.cpp:3409
virtual bool collide(PxReal elapsedTime, physx::PxBaseTask *completionTask, void *scratchBlock, PxU32 scratchBlockSize, bool controlSimulation=true)
Performs collision detection for the scene over elapsedTime.
Definition NpScene.cpp:3130
virtual PxSceneFlags getFlags() const
Get the scene flags.
Definition NpScene.cpp:432
virtual void processCallbacks(physx::PxBaseTask *continuation)
Definition NpSceneFetchResults.cpp:431
virtual void setGravity(const PxVec3 &)
Sets a constant gravity for the entire scene.
Definition NpScene.cpp:323
virtual void setUpdateMode(PxSceneQueryUpdateMode::Enum updateMode)
Sets scene query update mode.
Definition NpSceneQueries.cpp:565
virtual PxBroadPhaseCallback * getBroadPhaseCallback() const
Retrieves the PxBroadPhaseCallback pointer set with setBroadPhaseCallback().
Definition NpScene.cpp:2615
virtual void setNbContactDataBlocks(PxU32 numBlocks)
set the cache blocks that can be used during simulate().
Definition NpScene.cpp:3379
virtual PxContactModifyCallback * getContactModifyCallback() const
Retrieves the PxContactModifyCallback pointer set with setContactModifyCallback().
Definition NpScene.cpp:2581
virtual void copySoftBodyData(void **data, void *dataSizes, void *softBodyIndices, PxSoftBodyDataFlag::Enum flag, const PxU32 nbCopySoftBodies, const PxU32 maxSize, void *copyEvent)
Copy GPU softbody data from the internal GPU buffer to a user-provided device buffer.
Definition NpScene.cpp:3852
virtual PxU32 getSoftBodies(PxSoftBody **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const
Retrieve an array of all the soft bodies in the scene.
Definition NpScene.cpp:1507
virtual bool advance(physx::PxBaseTask *completionTask)
Performs dynamics phase of the simulation pipeline.
Definition NpScene.cpp:3104
virtual void setMaxBiasCoefficient(const PxReal t)
Set the max bias coefficient.
Definition NpScene.cpp:3419
virtual PxU32 getStaticTimestamp() const
Retrieves the system's internal scene query timestamp, increased each time a change to the static sce...
Definition NpSceneQueries.cpp:603
virtual PxReal getFrictionCorrelationDistance() const
Gets the friction correlation distance.
Definition NpScene.cpp:3467
virtual void setLimits(const PxSceneLimits &limits)
Set new scene limits.
Definition NpScene.cpp:364
virtual void setCCDMaxPasses(PxU32 ccdMaxPasses)
Sets the maximum number of CCD passes.
Definition NpScene.cpp:2621
virtual PxSimulationFilterShader getFilterShader() const
Gets the custom collision filter shader in use for this scene.
Definition NpScene.cpp:2761
virtual void sceneQueriesUpdate(physx::PxBaseTask *completionTask, bool controlSimulation)
Executes scene queries update tasks.
Definition NpSceneQueries.cpp:696
virtual PxU32 getTimestamp() const
Retrieves the scene's internal timestamp, increased each time a simulation step is completed.
Definition NpScene.cpp:3404
virtual PxU32 getMaxNbContactDataBlocksUsed() const
get the maximum number of cache blocks used by the scene
Definition NpScene.cpp:3396
virtual PxReal getCCDMaxSeparation() const
Gets the maximum CCD separation.
Definition NpScene.cpp:2651
virtual void applyArticulationData(void *data, void *index, PxArticulationGpuDataType::Enum dataType, const PxU32 nbUpdatedArticulations, void *waitEvent, void *signalEvent)
Apply GPU articulation data from a user-provided device buffer to the internal GPU buffer.
Definition NpScene.cpp:3838
virtual void setCCDMaxSeparation(const PxReal t)
Set the maximum CCD separation.
Definition NpScene.cpp:2639
virtual bool setVisualizationParameter(PxVisualizationParameter::Enum param, PxReal value)
Function that lets you set debug visualization parameters.
Definition NpScene.cpp:3333
virtual void applySoftBodyData(void **data, void *dataSizes, void *softBodyIndices, PxSoftBodyDataFlag::Enum flag, const PxU32 nbUpdatedSoftBodies, const PxU32 maxSize, void *applyEvent)
Apply user-provided data to the internal softbody system.
Definition NpScene.cpp:3859
virtual PxPhysics & getPhysics()
Call this method to retrieve the Physics SDK.
Definition NpScene.cpp:2874
virtual PxFrictionType::Enum getFrictionType() const
Return the friction model.
Definition NpScene.cpp:2543
virtual void removeAggregate(PxAggregate &, bool wakeOnLostTouch)
Removes an aggregate from this scene.
Definition NpScene.cpp:2137
virtual bool fetchResults(bool block, PxU32 *errorState)
Definition NpSceneFetchResults.cpp:200
virtual PxU32 getNbContactDataBlocksUsed() const
get the number of cache blocks currently used by the scene
Definition NpScene.cpp:3388
virtual PxU32 getDynamicTreeRebuildRateHint() const
Retrieves the rebuild rate of the dynamic tree pruning structures.
Definition NpSceneQueries.cpp:588
virtual PxU32 getNbParticleSystems(PxParticleSolverType::Enum type) const
Retrieve the number of particle systems of the requested type in the scene.
Definition NpScene.cpp:1728
virtual PxReal getCCDThreshold() const
Gets the CCD threshold.
Definition NpScene.cpp:2669
virtual void applyActorData(void *data, PxGpuActorPair *index, PxActorCacheFlag::Enum flag, const PxU32 nbUpdatedActors, void *waitEvent, void *signalEvent)
Apply user-provided data to rigid body.
Definition NpScene.cpp:3895
virtual void shiftOrigin(const PxVec3 &shift)
Shift the scene origin by the specified vector.
Definition NpScene.cpp:3775
virtual PxU32 getAggregates(PxAggregate **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const
Retrieve all the aggregates in the scene.
Definition NpScene.cpp:2194
virtual PxTaskManager * getTaskManager() const
Get the task manager associated with this scene.
Definition NpScene.h:268
virtual PxU32 getHairSystems(PxHairSystem **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const
Retrieve an array of all the hair systems in the scene.
Definition NpScene.cpp:1867
virtual PxReal getVisualizationParameter(PxVisualizationParameter::Enum param) const
Function that lets you query debug visualization parameters.
Definition NpScene.cpp:3351
virtual PxU32 getCCDMaxPasses() const
Gets the maximum number of CCD passes.
Definition NpScene.cpp:2633
virtual void setVisualizationCullingBox(const PxBounds3 &box)
Defines a box in world space to which visualization geometry will be (conservatively) culled....
Definition NpScene.cpp:3361
virtual void setFlag(PxSceneFlag::Enum flag, bool value)
Sets a scene flag. You can only set one flag at a time.
Definition NpScene.cpp:407
virtual void setCCDContactModifyCallback(PxCCDContactModifyCallback *callback)
Sets a user callback object, which receives callbacks on all CCD contacts generated for specified act...
Definition NpScene.cpp:2587
virtual PxSimulationFilterCallback * getFilterCallback() const
Gets the custom collision filter callback in use for this scene.
Definition NpScene.cpp:2767
virtual bool addActor(PxActor &actor, const PxBVH *bvh)
Adds an actor to this scene.
Definition NpScene.cpp:470
virtual void computeGeneralizedMassMatrices(const PxIndexDataPair *indices, PxU32 nbIndices, void *computeEvent)
Compute the joint-space inertia matrices that maps joint accelerations to joint forces: forces = M * ...
Definition NpScene.cpp:3923
virtual void setSolverBatchSize(PxU32 solverBatchSize)
Sets the number of actors required to spawn a separate rigid body solver thread.
Definition NpScene.cpp:3295
virtual void computeGeneralizedGravityForces(const PxIndexDataPair *indices, PxU32 nbIndices, void *computeEvent)
Computes the joint DOF forces required to counteract gravitational forces for the given articulation ...
Definition NpScene.cpp:3937
virtual PxU32 getFilterShaderDataSize() const
Gets the size of the shared global filter data (PxSceneDesc.filterShaderData)
Definition NpScene.cpp:2755
virtual PxSimulationEventCallback * getSimulationEventCallback() const
Retrieves the simulationEventCallback pointer set with setSimulationEventCallback().
Definition NpScene.cpp:2564
virtual PxU32 getArticulations(PxArticulationReducedCoordinate **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const
Retrieve all the articulations in the scene.
Definition NpScene.cpp:2452
virtual void setFilterShaderData(const void *data, PxU32 dataSize)
Sets the shared global filter data which will get passed into the filter shader.
Definition NpScene.cpp:2737
virtual void setContactModifyCallback(PxContactModifyCallback *callback)
Sets a user callback object, which receives callbacks on all contacts generated for specified actors.
Definition NpScene.cpp:2570
virtual PxReal getBounceThresholdVelocity() const
Return the bounce threshold velocity.
Definition NpScene.cpp:356
virtual void removeActor(PxActor &actor, bool wakeOnLostTouch)
Removes an actor from this scene.
Definition NpScene.cpp:780
virtual void fetchResultsFinish(PxU32 *errorState=0)
Definition NpSceneFetchResults.cpp:452
virtual bool checkQueries(bool block)
This checks to see if the scene queries update has completed.
Definition NpSceneQueries.cpp:762
virtual bool overlap(const PxGeometry &geometry, const PxTransform &transform, PxOverlapCallback &hitCall, const PxQueryFilterData &filterData, PxQueryFilterCallback *filterCall, const PxQueryCache *cache, PxGeometryQueryFlags flags) const
Performs an overlap test of a given geometry against objects in the scene, returns results in a PxOve...
Definition NpSceneQueries.cpp:547
virtual PxDominanceGroupPair getDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2) const
Samples the dominance matrix.
Definition NpScene.cpp:3274
virtual PxReal getMaxBiasCoefficient() const
Gets the max bias coefficient.
Definition NpScene.cpp:3431
virtual void setFrictionOffsetThreshold(const PxReal t)
Set the friction offset threshold.
Definition NpScene.cpp:3437
virtual bool fetchCollision(bool block)
Definition NpScene.cpp:3152
virtual PxClientID createClient()
Reserves a new client ID.
Definition NpScene.cpp:2523
virtual PxCCDContactModifyCallback * getCCDContactModifyCallback() const
Retrieves the PxCCDContactModifyCallback pointer set with setContactModifyCallback().
Definition NpScene.cpp:2598
virtual bool removeBroadPhaseRegion(PxU32 handle)
Removes a new broad-phase region.
Definition NpScene.cpp:2724
virtual void lockWrite(const char *file=NULL, PxU32 line=0)
Lock the scene for writing from this thread.
Definition NpScene.cpp:3658
virtual PxU32 getNbFEMCloths() const
Retrieve the number of FEM cloths in the scene.
Definition NpScene.cpp:1563
virtual PxReal getWakeCounterResetValue() const
Returns the wake counter reset value.
Definition NpScene.cpp:3701
virtual PxPvdSceneClient * getScenePvdClient()
Returns the Pvd client associated with the scene.
Definition NpScene.cpp:3814
virtual PxSolverType::Enum getSolverType() const
Return the solver model.
Definition NpScene.cpp:2535
virtual void setFrictionCorrelationDistance(const PxReal t)
Set the friction correlation distance.
Definition NpScene.cpp:3455
virtual PxU32 getBroadPhaseRegions(PxBroadPhaseRegionInfo *userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const
Gets broad-phase regions.
Definition NpScene.cpp:2697
virtual PxU32 getNbAggregates() const
Returns the number of aggregates in the scene.
Definition NpScene.cpp:2188
virtual PxU32 getNbHairSystems() const
Retrieve the number of hair systems in the scene.
Definition NpScene.cpp:1857
virtual PxActor ** getActiveActors(PxU32 &nbActorsOut)
Queries the PxScene for a list of the PxActors whose transforms have been updated during the previous...
Definition NpScene.cpp:2405
virtual PxU32 getSolverArticulationBatchSize(void) const
Retrieves the number of articulations required to spawn a separate rigid body solver thread.
Definition NpScene.cpp:3324
virtual bool sweep(const PxGeometry &geometry, const PxTransform &pose, const PxVec3 &unitDir, const PxReal distance, PxSweepCallback &hitCall, PxHitFlags hitFlags, const PxQueryFilterData &filterData, PxQueryFilterCallback *filterCall, const PxQueryCache *cache, const PxReal inflation, PxGeometryQueryFlags flags) const
Performs a sweep test against objects in the scene, returns results in a PxSweepBuffer object or via ...
Definition NpSceneQueries.cpp:556
virtual void setBroadPhaseCallback(PxBroadPhaseCallback *callback)
Sets a broad-phase user callback object.
Definition NpScene.cpp:2604
virtual bool addArticulation(PxArticulationReducedCoordinate &)
Adds an articulation to this scene.
Definition NpScene.cpp:975
virtual PxU32 getContactReportStreamBufferSize() const
Return the value of PxSceneDesc::contactReportStreamBufferSize that was set when creating the scene w...
Definition NpScene.cpp:3473
virtual PxU32 getNbArticulations() const
Returns the number of articulations in the scene.
Definition NpScene.cpp:2446
virtual void setSolverArticulationBatchSize(PxU32 solverBatchSize)
Sets the number of articulations required to spawn a separate rigid body solver thread.
Definition NpScene.cpp:3313
virtual void lockRead(const char *file=NULL, PxU32 line=0)
Lock the scene for reading from the calling thread.
Definition NpScene.cpp:3629
virtual PxSceneLimits getLimits() const
Get current scene limits.
Definition NpScene.cpp:398
virtual bool addActors(PxActor *const *actors, PxU32 nbActors)
Adds actors to this scene. Only supports actors of type PxRigidStatic and PxRigidDynamic.
Definition NpScene.cpp:566
virtual void flushSimulation(bool sendPendingReports)
Clear internal buffers and free memory.
Definition NpScene.cpp:3173
virtual bool raycast(const PxVec3 &origin, const PxVec3 &unitDir, const PxReal distance, PxRaycastCallback &hitCall, PxHitFlags hitFlags, const PxQueryFilterData &filterData, PxQueryFilterCallback *filterCall, const PxQueryCache *cache, PxGeometryQueryFlags flags) const
Performs a raycast against objects in the scene, returns results in a PxRaycastBuffer object or via a...
Definition NpSceneQueries.cpp:538
virtual PxPruningStructureType::Enum getStaticStructure() const
Return the value of PxSceneQueryDesc::staticStructure that was set when creating the scene with PxPhy...
Definition NpSceneQueries.cpp:608
virtual void unlockRead()
Unlock the scene from reading.
Definition NpScene.cpp:3641
virtual PxSceneQueryUpdateMode::Enum getUpdateMode() const
Gets scene query update mode.
Definition NpSceneQueries.cpp:573
virtual void setDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2, const PxDominanceGroupPair &dominance)
Specifies the dominance behavior of contacts between two actors with two certain dominance groups.
Definition NpScene.cpp:3255
virtual void unlockWrite()
Unlock the scene from writing.
Definition NpScene.cpp:3680
virtual const PxRenderBuffer & getRenderBuffer()
Retrieves the render buffer.
Definition NpScene.cpp:2487
void removeArticulationInternal(PxArticulationReducedCoordinate &, bool wakeOnLostTouch, bool removeFromAggregate)
Definition NpScene.cpp:1387
virtual bool addAggregate(PxAggregate &)
Adds an aggregate to this scene.
Definition NpScene.cpp:2077
virtual void setDynamicTreeRebuildRateHint(PxU32 dynamicTreeRebuildRateHint)
Sets the rebuild rate of the dynamic tree pruning structures.
Definition NpSceneQueries.cpp:579
virtual bool resetFiltering(PxActor &actor)
Marks the object to reset interactions and re-run collision filters in the next simulation step.
Definition NpScene.cpp:2773
virtual void applyParticleBufferData(const PxU32 *indices, const PxGpuParticleBufferIndexPair *bufferIndexPairs, const PxParticleBufferFlags *flags, PxU32 nbUpdatedBuffers, void *waitEvent, void *signalEvent)
Apply user-provided data to particle buffers.
Definition NpScene.cpp:3965
virtual void computeCoriolisAndCentrifugalForces(const PxIndexDataPair *indices, PxU32 nbIndices, void *computeEvent)
Computes the joint DOF forces required to counteract coriolis and centrifugal forces for the given ar...
Definition NpScene.cpp:3951
virtual void release()
Deletes the scene.
Definition NpScene.cpp:275
virtual PxBounds3 getVisualizationCullingBox() const
Retrieves the visualization culling box.
Definition NpScene.cpp:3371
virtual PxPairFilteringMode::Enum getStaticKinematicFilteringMode() const
Gets the pair filtering mode for static-kinematic pairs.
Definition NpScene.cpp:2866
virtual PxReal getFrictionOffsetThreshold() const
Gets the friction offset threshold.
Definition NpScene.cpp:3449
virtual bool simulate(PxReal elapsedTime, physx::PxBaseTask *completionTask, void *scratchBlock, PxU32 scratchBlockSize, bool controlSimulation)
Advances the simulation by an elapsedTime time.
Definition NpScene.cpp:3098
virtual PxU32 getConstraints(PxConstraint **buffer, PxU32 bufferSize, PxU32 startIndex=0) const
Retrieve all the constraint shaders in the scene.
Definition NpScene.cpp:2479
virtual PxPruningStructureType::Enum getDynamicStructure() const
Return the value of PxSceneQueryDesc::dynamicStructure that was set when creating the scene with PxPh...
Definition NpSceneQueries.cpp:613
virtual bool checkResults(bool block)
This checks to see if the simulation run has completed.
Definition NpSceneFetchResults.cpp:84
virtual PxU32 getNbBroadPhaseRegions() const
Returns number of regions currently registered in the broad-phase.
Definition NpScene.cpp:2690
virtual void flushUpdates()
Flushes any changes to the scene query representation.
Definition NpSceneQueries.cpp:618
virtual void setBounceThresholdVelocity(const PxReal t)
Set the bounce threshold velocity. Collision speeds below this threshold will not cause a bounce.
Definition NpScene.cpp:344
virtual void setSimulationEventCallback(PxSimulationEventCallback *callback)
Sets a user notify object which receives special simulation events when they occur.
Definition NpScene.cpp:2553
virtual PxU32 getFEMCloths(PxFEMCloth **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const
Retrieve an array of all the FEM cloths in the scene.
Definition NpScene.cpp:1587
virtual PxU32 getParticleSystems(PxParticleSolverType::Enum type, PxParticleSystem **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const
Retrieve an array of all the particle systems of the requested type in the scene.
Definition NpScene.cpp:1779
virtual void copyArticulationData(void *data, void *index, PxArticulationGpuDataType::Enum dataType, const PxU32 nbCopyArticulations, void *copyEvent)
Copy GPU articulation data from the internal GPU buffer to a user-provided device buffer.
Definition NpScene.cpp:3823
virtual PxU32 addBroadPhaseRegion(const PxBroadPhaseRegion &region, bool populateRegion)
Adds a new broad-phase region.
Definition NpScene.cpp:2704
virtual PxU32 getNbActors(PxActorTypeFlags types) const
Retrieve the number of actors of certain types in the scene. For supported types, see PxActorTypeFlag...
Definition NpScene.cpp:2344
virtual void copyBodyData(PxGpuBodyData *data, PxGpuActorPair *index, const PxU32 nbCopyActors, void *copyEvent)
Copy GPU rigid body data from the internal GPU buffer to a user-provided device buffer.
Definition NpScene.cpp:3881
virtual PxU32 getNbSoftBodies() const
Retrieve the number of soft bodies in the scene.
Definition NpScene.cpp:1497
virtual bool fetchQueries(bool block)
Definition NpSceneQueries.cpp:767
virtual const void * getFilterShaderData() const
Gets the shared global filter data in use for this scene.
Definition NpScene.cpp:2749
virtual void copyContactData(void *data, const PxU32 numContactPatches, void *numContactPairs, void *copyEvent)
Copy contact data from the internal GPU buffer to a user-provided device buffer.
Definition NpScene.cpp:3867
virtual PxPairFilteringMode::Enum getKinematicKinematicFilteringMode() const
Gets the pair filtering mode for kinematic-kinematic pairs.
Definition NpScene.cpp:2860
virtual void removeActors(PxActor *const *actors, PxU32 nbActors, bool wakeOnLostTouch)
Removes actors from this scene. Only supports actors of type PxRigidStatic and PxRigidDynamic.
Definition NpScene.cpp:737
virtual void getSimulationStatistics(PxSimulationStatistics &s) const
Call this method to retrieve statistics for the current simulation step.
Definition NpScene.cpp:2501
virtual bool fetchResultsStart(const PxContactPairHeader *&contactPairs, PxU32 &nbContactPairs, bool block=false)
Definition NpSceneFetchResults.cpp:384
virtual void setCCDThreshold(const PxReal t)
Set the CCD threshold.
Definition NpScene.cpp:2657
virtual bool getBroadPhaseCaps(PxBroadPhaseCaps &caps) const
Gets broad-phase caps.
Definition NpScene.cpp:2682
virtual bool addCollection(const PxCollection &collection)
Adds objects in the collection to this scene.
Definition NpScene.cpp:2264
virtual PxBroadPhaseType::Enum getBroadPhaseType() const
Returns broad-phase type.
Definition NpScene.cpp:2675
virtual PxU32 getActors(PxActorTypeFlags types, PxActor **buffer, PxU32 bufferSize, PxU32 startIndex=0) const
Retrieve an array of all the actors of certain types in the scene. For supported types,...
Definition NpScene.cpp:2380
virtual void forceRebuildDynamicTree(PxU32 prunerIndex)
Forces dynamic trees to be immediately rebuilt.
Definition NpSceneQueries.cpp:594
virtual PxU32 getNbConstraints() const
Returns the number of constraint shaders in the scene.
Definition NpScene.cpp:2460
virtual PxU32 getSolverBatchSize(void) const
Retrieves the number of actors required to spawn a separate rigid body solver thread.
Definition NpScene.cpp:3306
virtual void removeArticulation(PxArticulationReducedCoordinate &, bool wakeOnLostTouch)
Removes an articulation from this scene.
Definition NpScene.cpp:1377
virtual void computeDenseJacobians(const PxIndexDataPair *indices, PxU32 nbIndices, void *computeEvent)
Compute dense Jacobian matrices for specified articulations on the GPU.
Definition NpScene.cpp:3909
virtual PxVec3 getGravity() const
Retrieves the current gravity setting.
Definition NpScene.cpp:336
PxActor is the base class for the main simulation objects in the physics SDK.
Definition PxActor.h:201
Class to aggregate actors into a single broad-phase entry.
Definition PxAggregate.h:98
Definition PxArray.h:53
Enum
Definition PxArticulationFlag.h:52
A tree structure of bodies connected by joints that is treated as a unit by the dynamics solver....
Definition PxArticulationReducedCoordinate.h:448
Class representing a bounding volume hierarchy.
Definition PxBVH.h:63
Base class of all task types.
Definition PxTask.h:45
virtual void addReference()=0
Implemented by derived implementation classes.
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
Broad-phase callback to receive broad-phase related events.
Definition PxScene.h:144
An interface class that the user can implement in order to modify CCD contact constraints.
Definition PxContactModifyCallback.h:500
Collection class for serialization.
Definition PxCollection.h:104
A plugin class for implementing constraints.
Definition PxConstraint.h:100
An interface class that the user can implement in order to modify contact constraints.
Definition PxContactModifyCallback.h:459
A PxBaseTask implementation with immediate execution and simple dependencies.
Definition PxTask.h:209
PxBaseTask * mCont
Continuation task, can be NULL.
Definition PxTask.h:306
Definition PxMutex.h:89
The shared base class for all particle systems.
Definition PxParticleSystem.h:137
Abstract singleton factory class used for instancing objects in the Physics SDK.
Definition PxPhysics.h:91
Interface for points, lines, triangles, and text buffer.
Definition PxRenderBuffer.h:136
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
Class used to retrieve limits(e.g. maximum number of bodies) for a scene. The limits are used as a hi...
Definition PxSceneDesc.h:318
Abstract class for collision shapes.
Definition PxShape.h:146
An interface class that the user can implement in order to receive simulation events.
Definition PxSimulationEventCallback.h:792
Filter callback to specify handling of collision pairs.
Definition PxFiltering.h:633
Class used to retrieve statistics for a simulation step.
Definition PxSimulationStatistics.h:50
Enum
Definition PxSoftBodyFlag.h:49
Represents a FEM softbody including everything to calculate its definition like geometry and material...
Definition PxSoftBody.h:104
The PxTaskManager interface.
Definition PxTaskManager.h:81
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
Definition PxUserAllocated.h:43
3 Element vector class.
Definition PxVec3.h:50
Definition ScScene.h:240
#define PX_RESTRICT
Definition PxPreprocessor.h:355
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxFilterFlags(* PxSimulationFilterShader)(PxFilterObjectAttributes attributes0, PxFilterData filterData0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, PxPairFlags &pairFlags, const void *constantBlock, PxU32 constantBlockSize)
Filter method to specify how a pair of potentially colliding objects should be processed.
Definition PxFiltering.h:604
PxU8 PxClientID
An ID to identify different clients for multiclient support.
Definition PxClient.h:44
PxU8 PxDominanceGroup
Group index which allows to specify 1- or 2-way interaction.
Definition PxActor.h:56
PxHitCallback< PxOverlapHit > PxOverlapCallback
Overlap query callback.
Definition PxQueryReport.h:207
PxHitCallback< PxRaycastHit > PxRaycastCallback
Raycast query callback.
Definition PxQueryReport.h:204
PxHitCallback< PxSweepHit > PxSweepCallback
Sweep query callback.
Definition PxQueryReport.h:210
Definition NpScene.h:467
Enum
Definition PxBroadPhase.h:79
An Instance of this class is passed to PxSimulationEventCallback.onContact().
Definition PxSimulationEventCallback.h:346
Expresses the dominance relationship of a contact. For the time being only three settings are permitt...
Definition PxScene.h:83
Enum
Definition PxSceneDesc.h:71
Enum
Definition PxFiltering.h:717
Enum
Definition PxParticleSolverType.h:53
Enum
Definition PxSceneQueryDesc.h:65
Enum
Definition PxSceneDesc.h:103
Enum
Definition PxSceneQueryDesc.h:134
Enum
Definition PxSceneDesc.h:89
Enum
Definition PxVisualizationParameter.h:63
Sizes of pre-allocated buffers use for GPU dynamics.
Definition PxSceneDesc.h:377