PxBatchQueryDesc.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
27 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29 
30 
31 #ifndef PX_PHYSICS_NX_SCENEQUERYDESC
32 #define PX_PHYSICS_NX_SCENEQUERYDESC
33 
36 #include "PxPhysXConfig.h"
37 #include "PxClient.h"
38 #include "PxFiltering.h"
39 #include "PxQueryFiltering.h"
40 #include "foundation/PxAssert.h"
41 
42 #if !PX_DOXYGEN
43 namespace physx
44 {
45 #endif
46 
47 struct PxSweepHit;
48 struct PxRaycastHit;
49 
56 {
57  enum Enum
58  {
62  ePENDING = 0,
63 
68 
72  eOVERFLOW
73  };
74 };
75 
81 template<typename HitType>
83 {
84  HitType block;
85  HitType* touches;
86  PxU32 nbTouches;
88  void* userData;
90  bool hasBlock;
92 
94  PX_INLINE PxU32 getNbAnyHits() const { return nbTouches + (hasBlock ? 1 : 0); }
95 
97  PX_INLINE const HitType& getAnyHit(const PxU32 index) const { PX_ASSERT(index < nbTouches + (hasBlock ? 1 : 0));
98  return index < nbTouches ? touches[index] : block; }
99 };
100 
103 
106 
109 
118  {
127 
135 
144 
152 
161 
169 
172 
175 
178 
180  PX_FORCE_INLINE PxU32 getMaxRaycastsPerExecute() const { return raycastResultBufferSize; }
181 
183  PX_FORCE_INLINE PxU32 getMaxSweepsPerExecute() const { return sweepResultBufferSize; }
184 
186  PX_FORCE_INLINE PxU32 getMaxOverlapsPerExecute() const { return overlapResultBufferSize; }
187 
188  PxBatchQueryMemory(PxU32 raycastResultBufferSize_, PxU32 sweepResultBufferSize_, PxU32 overlapResultBufferSize_) :
189  userRaycastResultBuffer (NULL),
190  userRaycastTouchBuffer (NULL),
191  userSweepResultBuffer (NULL),
192  userSweepTouchBuffer (NULL),
193  userOverlapResultBuffer (NULL),
194  userOverlapTouchBuffer (NULL),
195  raycastTouchBufferSize (0),
196  sweepTouchBufferSize (0),
197  overlapTouchBufferSize (0),
198  raycastResultBufferSize (raycastResultBufferSize_),
199  sweepResultBufferSize (sweepResultBufferSize_),
200  overlapResultBufferSize (overlapResultBufferSize_)
201  {
202  }
203 
204 protected:
208 };
209 
218 {
219 public:
220 
231 
240 
247 
254 
261 
274  PX_INLINE PxBatchQueryDesc(PxU32 maxRaycastsPerExecute, PxU32 maxSweepsPerExecute, PxU32 maxOverlapsPerExecute);
275  PX_INLINE bool isValid() const;
276 };
277 
278 
279 PX_INLINE PxBatchQueryDesc::PxBatchQueryDesc(PxU32 maxRaycastsPerExecute, PxU32 maxSweepsPerExecute, PxU32 maxOverlapsPerExecute) :
280  filterShaderData (NULL),
281  filterShaderDataSize (0),
282  preFilterShader (NULL),
283  postFilterShader (NULL),
284  queryMemory (maxRaycastsPerExecute, maxSweepsPerExecute, maxOverlapsPerExecute)
285 {
286 }
287 
288 
290 {
291  if ( ((filterShaderDataSize == 0) && (filterShaderData != NULL)) ||
292  ((filterShaderDataSize > 0) && (filterShaderData == NULL)) )
293  return false;
294 
295  return true;
296 }
297 
298 #if !PX_DOXYGEN
299 } // namespace physx
300 #endif
301 
303 #endif
Definition: GuContactBuffer.h:37
PX_DEPRECATED PxBatchQueryResult< PxSweepHit > PxSweepQueryResult
Convenience typedef for the result of a batched sweep query.
Definition: PxBatchQueryDesc.h:105
void * filterShaderData
Shared global filter data which will get passed into the filter shader.
Definition: PxBatchQueryDesc.h:230
PX_DEPRECATED PxQueryHitType::Enum(* PxBatchQueryPreFilterShader)(PxFilterData queryFilterData, PxFilterData objectFilterData, const void *constantBlock, PxU32 constantBlockSize, PxHitFlags &hitFlags)
Batched query pre-filter shader.
Definition: PxQueryFiltering.h:233
PxSweepQueryResult * userSweepResultBuffer
The pointer to the user-allocated buffer for results of sweep queries in corresponding order of issue...
Definition: PxBatchQueryDesc.h:143
Struct for PxBatchQuery memory pointers.
Definition: PxBatchQueryDesc.h:117
void * userData
Copy of the userData pointer specified in the corresponding query.
Definition: PxBatchQueryDesc.h:88
PxU16 pad
pads the struct to 16 bytes.
Definition: PxBatchQueryDesc.h:91
#define PX_FORCE_INLINE
Definition: PxPreprocessor.h:364
The query is finished; results have been written into the result and hit buffers. ...
Definition: PxBatchQueryDesc.h:67
PxU32 overlapResultBufferSize
Definition: PxBatchQueryDesc.h:207
PxU32 overlapTouchBufferSize
Capacity of the user-allocated userOverlapTouchBuffer in elements.
Definition: PxBatchQueryDesc.h:177
PxBatchQueryPostFilterShader postFilterShader
The custom postFilter shader to use for filtering.
Definition: PxBatchQueryDesc.h:253
PX_DEPRECATED PxBatchQueryResult< PxRaycastHit > PxRaycastQueryResult
Convenience typedef for the result of a batched raycast query.
Definition: PxBatchQueryDesc.h:102
PX_INLINE PxU32 getNbAnyHits() const
Computes the number of any hits in this result, blocking or touching.
Definition: PxBatchQueryDesc.h:94
PX_INLINE bool isValid() const
Definition: PxBatchQueryDesc.h:289
HitType * touches
Definition: PxBatchQueryDesc.h:85
PxOverlapHit * userOverlapTouchBuffer
The pointer to the user-allocated buffer for overlap hits.
Definition: PxBatchQueryDesc.h:168
PX_FORCE_INLINE PxU32 getMaxOverlapsPerExecute() const
Definition: PxBatchQueryDesc.h:186
#define PX_DEPRECATED
Definition: PxPreprocessor.h:437
Descriptor class for PxBatchQuery.
Definition: PxBatchQueryDesc.h:217
bool hasBlock
True if there was a blocking hit.
Definition: PxBatchQueryDesc.h:90
PX_INLINE PxBatchQueryDesc(PxU32 maxRaycastsPerExecute, PxU32 maxSweepsPerExecute, PxU32 maxOverlapsPerExecute)
Construct a batch query with specified maximum number of queries per batch.
Definition: PxBatchQueryDesc.h:279
PxU32 sweepTouchBufferSize
Capacity of the user-allocated userSweepTouchBuffer in elements.
Definition: PxBatchQueryDesc.h:174
Enum
Definition: PxBatchQueryDesc.h:57
PxU32 raycastResultBufferSize
Definition: PxBatchQueryDesc.h:205
PxBatchQueryPreFilterShader preFilterShader
The custom preFilter shader to use for filtering.
Definition: PxBatchQueryDesc.h:246
PxU32 filterShaderDataSize
Size (in bytes) of the shared global filter data filterShaderData.
Definition: PxBatchQueryDesc.h:239
PxBatchQueryMemory queryMemory
User memory buffers for the query.
Definition: PxBatchQueryDesc.h:260
uint8_t PxU8
Definition: PxSimpleTypes.h:75
PxU8 queryStatus
Takes on values from PxBatchQueryStatus::Enum.
Definition: PxBatchQueryDesc.h:89
Generic struct for receiving results of single query in a batch. Gets templated on hit type PxRaycast...
Definition: PxBatchQueryDesc.h:82
PX_DEPRECATED PxBatchQueryResult< PxOverlapHit > PxOverlapQueryResult
Convenience typedef for the result of a batched overlap query.
Definition: PxBatchQueryDesc.h:108
PxU32 raycastTouchBufferSize
Capacity of the user-allocated userRaycastTouchBuffer in elements.
Definition: PxBatchQueryDesc.h:171
HitType block
Holds the closest blocking hit for a single query in a batch. Only valid if hasBlock is true...
Definition: PxBatchQueryDesc.h:84
PX_FORCE_INLINE PxU32 getMaxSweepsPerExecute() const
Definition: PxBatchQueryDesc.h:183
PxSweepHit * userSweepTouchBuffer
The pointer to the user-allocated buffer for sweep hits.
Definition: PxBatchQueryDesc.h:151
PxBatchQueryMemory(PxU32 raycastResultBufferSize_, PxU32 sweepResultBufferSize_, PxU32 overlapResultBufferSize_)
Definition: PxBatchQueryDesc.h:188
PX_INLINE const HitType & getAnyHit(const PxU32 index) const
Convenience iterator used to access any hits in this result, blocking or touching.
Definition: PxBatchQueryDesc.h:97
Stores results of overlap queries.
Definition: PxQueryReport.h:191
PxOverlapQueryResult * userOverlapResultBuffer
The pointer to the user-allocated buffer for results of overlap queries in corresponding order of iss...
Definition: PxBatchQueryDesc.h:160
PxU32 sweepResultBufferSize
Definition: PxBatchQueryDesc.h:206
PX_DEPRECATED PxQueryHitType::Enum(* PxBatchQueryPostFilterShader)(PxFilterData queryFilterData, PxFilterData objectFilterData, const void *constantBlock, PxU32 constantBlockSize, const PxQueryHit &hit)
Batched query post-filter shader.
Definition: PxQueryFiltering.h:266
#define PX_ASSERT(exp)
Definition: PxAssert.h:61
Stores results of sweep queries.
Definition: PxQueryReport.h:199
PxRaycastHit * userRaycastTouchBuffer
The pointer to the user-allocated buffer for raycast touch hits.
Definition: PxBatchQueryDesc.h:134
Stores results of raycast queries.
Definition: PxQueryReport.h:173
uint16_t PxU16
Definition: PxSimpleTypes.h:73
uint32_t PxU32
Definition: Px.h:48
Batched query status.
Definition: PxBatchQueryDesc.h:55
PxRaycastQueryResult * userRaycastResultBuffer
The pointer to the user-allocated buffer for results of raycast queries in corresponding order of iss...
Definition: PxBatchQueryDesc.h:126
#define PX_INLINE
Definition: PxPreprocessor.h:349
PX_FORCE_INLINE PxU32 getMaxRaycastsPerExecute() const
Definition: PxBatchQueryDesc.h:180