RavEngine
Loading...
Searching...
No Matches
PxSceneQuerySystem.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_SCENE_QUERY_SYSTEM_H
30#define PX_SCENE_QUERY_SYSTEM_H
34#include "foundation/PxSimpleTypes.h"
35#include "foundation/PxBitMap.h"
36#include "foundation/PxTransform.h"
37#include "PxSceneQueryDesc.h"
38#include "PxQueryReport.h"
39#include "PxQueryFiltering.h"
40#include "geometry/PxGeometryQueryFlags.h"
41
42#if !PX_DOXYGEN
43namespace physx
44{
45#endif
46
47 class PxBaseTask;
48 class PxRenderOutput;
49 class PxGeometry;
50 class PxRigidActor;
51 class PxShape;
52 class PxBVH;
53 class PxPruningStructure;
54
64 {
65 PX_SCENE_PRUNER_STATIC = 0,
66 PX_SCENE_PRUNER_DYNAMIC = 1,
67 PX_SCENE_COMPOUND_PRUNER = 0xffffffff
68 };
69
78 {
79 protected:
81 virtual ~PxSceneQuerySystemBase() {}
82
83 public:
84
88
96 virtual void setDynamicTreeRebuildRateHint(PxU32 dynamicTreeRebuildRateHint) = 0;
97
105 virtual PxU32 getDynamicTreeRebuildRateHint() const = 0;
106
116 virtual void forceRebuildDynamicTree(PxU32 prunerIndex) = 0;
117
125 virtual void setUpdateMode(PxSceneQueryUpdateMode::Enum updateMode) = 0;
126
135
142 virtual PxU32 getStaticTimestamp() const = 0;
143
157 virtual void flushUpdates() = 0;
158
182 virtual bool raycast(const PxVec3& origin, const PxVec3& unitDir, const PxReal distance,
183 PxRaycastCallback& hitCall, PxHitFlags hitFlags = PxHitFlag::eDEFAULT,
184 const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL,
185 const PxQueryCache* cache = NULL, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT) const = 0;
186
214 virtual bool sweep( const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance,
215 PxSweepCallback& hitCall, PxHitFlags hitFlags = PxHitFlag::eDEFAULT,
216 const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL,
217 const PxQueryCache* cache = NULL, const PxReal inflation = 0.0f, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT) const = 0;
218
242 virtual bool overlap(const PxGeometry& geometry, const PxTransform& pose, PxOverlapCallback& hitCall,
243 const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL,
244 const PxQueryCache* cache = NULL, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT) const = 0;
246 };
247
257 {
258 protected:
259 PxSceneSQSystem() {}
260 virtual ~PxSceneSQSystem() {}
261
262 public:
263
267
276
285
293
300
309 PX_FORCE_INLINE void forceDynamicTreeRebuild(bool rebuildStaticStructure, bool rebuildDynamicStructure)
310 {
311 if(rebuildStaticStructure)
312 forceRebuildDynamicTree(PX_SCENE_PRUNER_STATIC);
313 if(rebuildDynamicStructure)
314 forceRebuildDynamicTree(PX_SCENE_PRUNER_DYNAMIC);
315 }
316
323
330
362 virtual void sceneQueriesUpdate(PxBaseTask* completionTask = NULL, bool controlSimulation = true) = 0;
363
375 virtual bool checkQueries(bool block = false) = 0;
376
385 virtual bool fetchQueries(bool block = false) = 0;
387 };
388
389 typedef PxU32 PxSQCompoundHandle;
390 typedef PxU32 PxSQPrunerHandle;
391 typedef void* PxSQBuildStepHandle;
392
421 {
422 protected:
424 virtual ~PxSceneQuerySystem() {}
425 public:
426
430 virtual void release() = 0;
431
437 virtual void acquireReference() = 0;
438
448 virtual void preallocate(PxU32 prunerIndex, PxU32 nbShapes) = 0;
449
457 virtual void flushMemory() = 0;
458
473 virtual void addSQShape( const PxRigidActor& actor, const PxShape& shape, const PxBounds3& bounds,
474 const PxTransform& transform, const PxSQCompoundHandle* compoundHandle=NULL, bool hasPruningStructure=false) = 0;
475
484 virtual void removeSQShape(const PxRigidActor& actor, const PxShape& shape) = 0;
485
499 virtual void updateSQShape(const PxRigidActor& actor, const PxShape& shape, const PxTransform& transform) = 0;
500
513 virtual PxSQCompoundHandle addSQCompound(const PxRigidActor& actor, const PxShape** shapes, const PxBVH& bvh, const PxTransform* transforms) = 0;
514
520 virtual void removeSQCompound(PxSQCompoundHandle compoundHandle) = 0;
521
530 virtual void updateSQCompound(PxSQCompoundHandle compoundHandle, const PxTransform& compoundTransform) = 0;
531
539 virtual void shiftOrigin(const PxVec3& shift) = 0;
540
550 virtual void visualize(PxU32 prunerIndex, PxRenderOutput& out) const = 0;
551
559 virtual void merge(const PxPruningStructure& pruningStructure) = 0;
560
573 virtual PxSQPrunerHandle getHandle(const PxRigidActor& actor, const PxShape& shape, PxU32& prunerIndex) const = 0;
574
594 virtual void sync(PxU32 prunerIndex, const PxSQPrunerHandle* handles, const PxU32* indices, const PxBounds3* bounds, const PxTransform32* transforms, PxU32 count, const PxBitMap& ignoredIndices) = 0;
595
613 virtual void finalizeUpdates() = 0;
614
634 virtual PxSQBuildStepHandle prepareSceneQueryBuildStep(PxU32 prunerIndex) = 0;
635
648 virtual void sceneQueryBuildStep(PxSQBuildStepHandle handle) = 0;
649 };
650
651#if !PX_DOXYGEN
652} // namespace physx
653#endif
654
656#endif
Class representing a bounding volume hierarchy.
Definition PxBVH.h:63
Base class of all task types.
Definition PxTask.h:45
Definition PxBitMap.h:52
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
A geometry object.
Definition PxGeometry.h:79
A precomputed pruning structure to accelerate scene queries against newly added actors.
Definition PxPruningStructure.h:61
Scene query filtering callbacks.
Definition PxQueryFiltering.h:175
Definition PxRenderOutput.h:50
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
Base class for the scene-query system.
Definition PxSceneQuerySystem.h:78
virtual bool overlap(const PxGeometry &geometry, const PxTransform &pose, PxOverlapCallback &hitCall, const PxQueryFilterData &filterData=PxQueryFilterData(), PxQueryFilterCallback *filterCall=NULL, const PxQueryCache *cache=NULL, PxGeometryQueryFlags queryFlags=PxGeometryQueryFlag::eDEFAULT) const =0
Performs an overlap test of a given geometry against objects in the scene, returns results in a PxOve...
virtual bool sweep(const PxGeometry &geometry, const PxTransform &pose, const PxVec3 &unitDir, const PxReal distance, PxSweepCallback &hitCall, PxHitFlags hitFlags=PxHitFlag::eDEFAULT, const PxQueryFilterData &filterData=PxQueryFilterData(), PxQueryFilterCallback *filterCall=NULL, const PxQueryCache *cache=NULL, const PxReal inflation=0.0f, PxGeometryQueryFlags queryFlags=PxGeometryQueryFlag::eDEFAULT) const =0
Performs a sweep test against objects in the scene, returns results in a PxSweepBuffer object or via ...
virtual void setUpdateMode(PxSceneQueryUpdateMode::Enum updateMode)=0
Sets scene query update mode.
virtual void forceRebuildDynamicTree(PxU32 prunerIndex)=0
Forces dynamic trees to be immediately rebuilt.
virtual bool raycast(const PxVec3 &origin, const PxVec3 &unitDir, const PxReal distance, PxRaycastCallback &hitCall, PxHitFlags hitFlags=PxHitFlag::eDEFAULT, const PxQueryFilterData &filterData=PxQueryFilterData(), PxQueryFilterCallback *filterCall=NULL, const PxQueryCache *cache=NULL, PxGeometryQueryFlags queryFlags=PxGeometryQueryFlag::eDEFAULT) const =0
Performs a raycast against objects in the scene, returns results in a PxRaycastBuffer object or via a...
virtual void setDynamicTreeRebuildRateHint(PxU32 dynamicTreeRebuildRateHint)=0
Sets the rebuild rate of the dynamic tree pruning structures.
virtual PxSceneQueryUpdateMode::Enum getUpdateMode() const =0
Gets scene query update mode.
virtual void flushUpdates()=0
Flushes any changes to the scene query representation.
virtual PxU32 getStaticTimestamp() const =0
Retrieves the system's internal scene query timestamp, increased each time a change to the static sce...
virtual PxU32 getDynamicTreeRebuildRateHint() const =0
Retrieves the rebuild rate of the dynamic tree pruning structures.
Scene-queries external sub-system for PxScene-based objects.
Definition PxSceneQuerySystem.h:421
virtual void merge(const PxPruningStructure &pruningStructure)=0
Merges a pruning structure with the SQ system's internal pruners.
virtual void updateSQShape(const PxRigidActor &actor, const PxShape &shape, const PxTransform &transform)=0
Updates a shape in the SQ system.
virtual void removeSQCompound(PxSQCompoundHandle compoundHandle)=0
Removes a compound from the SQ system.
virtual void shiftOrigin(const PxVec3 &shift)=0
Shift the data structures' origin by the specified vector.
virtual void finalizeUpdates()=0
Finalizes updates made to the SQ system.
virtual void addSQShape(const PxRigidActor &actor, const PxShape &shape, const PxBounds3 &bounds, const PxTransform &transform, const PxSQCompoundHandle *compoundHandle=NULL, bool hasPruningStructure=false)=0
Adds a shape to the SQ system.
virtual PxSQBuildStepHandle prepareSceneQueryBuildStep(PxU32 prunerIndex)=0
Prepares asynchronous build step.
virtual void visualize(PxU32 prunerIndex, PxRenderOutput &out) const =0
Visualizes the system's internal data-structures, for debugging purposes.
virtual PxSQPrunerHandle getHandle(const PxRigidActor &actor, const PxShape &shape, PxU32 &prunerIndex) const =0
Shape to SQ-pruner-handle mapping function.
virtual void removeSQShape(const PxRigidActor &actor, const PxShape &shape)=0
Removes a shape from the SQ system.
virtual void preallocate(PxU32 prunerIndex, PxU32 nbShapes)=0
Preallocates internal arrays to minimize the amount of reallocations.
virtual PxSQCompoundHandle addSQCompound(const PxRigidActor &actor, const PxShape **shapes, const PxBVH &bvh, const PxTransform *transforms)=0
Adds a compound to the SQ system.
virtual void updateSQCompound(PxSQCompoundHandle compoundHandle, const PxTransform &compoundTransform)=0
Updates a compound in the SQ system.
virtual void sceneQueryBuildStep(PxSQBuildStepHandle handle)=0
Executes asynchronous build step.
virtual void flushMemory()=0
Frees internal memory that may not be in-use anymore.
virtual void sync(PxU32 prunerIndex, const PxSQPrunerHandle *handles, const PxU32 *indices, const PxBounds3 *bounds, const PxTransform32 *transforms, PxU32 count, const PxBitMap &ignoredIndices)=0
Synchronizes the scene-query system with another system that references the same objects.
virtual void release()=0
Decrements the reference count of the object and releases it if the new reference count is zero.
virtual void acquireReference()=0
Acquires a counted reference to this object.
Traditional SQ system for PxScene.
Definition PxSceneQuerySystem.h:257
virtual PxPruningStructureType::Enum getDynamicStructure() const =0
Return the value of PxSceneQueryDesc::dynamicStructure that was set when creating the scene with PxPh...
PX_FORCE_INLINE PxSceneQueryUpdateMode::Enum getSceneQueryUpdateMode() const
Gets scene query update mode.
Definition PxSceneQuerySystem.h:284
virtual bool checkQueries(bool block=false)=0
This checks to see if the scene queries update has completed.
PX_FORCE_INLINE void setSceneQueryUpdateMode(PxSceneQueryUpdateMode::Enum updateMode)
Sets scene query update mode.
Definition PxSceneQuerySystem.h:275
PX_FORCE_INLINE void forceDynamicTreeRebuild(bool rebuildStaticStructure, bool rebuildDynamicStructure)
Forces dynamic trees to be immediately rebuilt.
Definition PxSceneQuerySystem.h:309
virtual PxPruningStructureType::Enum getStaticStructure() const =0
Return the value of PxSceneQueryDesc::staticStructure that was set when creating the scene with PxPhy...
virtual bool fetchQueries(bool block=false)=0
PX_FORCE_INLINE void flushQueryUpdates()
Flushes any changes to the scene query representation.
Definition PxSceneQuerySystem.h:299
virtual void sceneQueriesUpdate(PxBaseTask *completionTask=NULL, bool controlSimulation=true)=0
Executes scene queries update tasks.
PX_FORCE_INLINE PxU32 getSceneQueryStaticTimestamp() const
Retrieves the scene's internal scene query timestamp, increased each time a change to the static scen...
Definition PxSceneQuerySystem.h:292
Abstract class for collision shapes.
Definition PxShape.h:146
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
#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
PxScenePrunerIndex
Built-in enum for default PxScene pruners.
Definition PxSceneQuerySystem.h:64
Enum
Definition PxSceneQueryDesc.h:65
single hit cache for scene queries.
Definition PxQueryReport.h:264
Scene query filtering data.
Definition PxQueryFiltering.h:138
Enum
Definition PxSceneQueryDesc.h:134