PxQueryReport.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12 
13 
14 #ifndef PX_PHYSICS_NX_SCENEQUERYREPORT
15 #define PX_PHYSICS_NX_SCENEQUERYREPORT
16 
19 #include "PxPhysXConfig.h"
20 #include "foundation/PxVec3.h"
21 #include "foundation/PxFlags.h"
22 
23 #ifndef PX_DOXYGEN
24 namespace physx
25 {
26 #endif
27 
28 class PxShape;
29 class PxRigidActor;
30 
44 struct PxHitFlag
45 {
46  enum Enum
47  {
48  ePOSITION = (1<<0),
49  eIMPACT = ePOSITION,
50  eNORMAL = (1<<1),
51  eDISTANCE = (1<<2),
52  eUV = (1<<3),
53  eASSUME_NO_INITIAL_OVERLAP = (1<<4),
54 
55  eMESH_MULTIPLE = (1<<5),
56 
57  eMESH_ANY = (1<<6),
58 
59  eMESH_BOTH_SIDES = (1<<7),
60 
61 
62  ePRECISE_SWEEP = (1<<8),
63 
64  eMTD = (1<<9),
65  eDIRECT_SWEEP = ePRECISE_SWEEP,
66 
67  eDEFAULT = ePOSITION|eNORMAL|eDISTANCE,
68 
70  eMODIFIABLE_FLAGS = eMESH_MULTIPLE|eMESH_BOTH_SIDES|eASSUME_NO_INITIAL_OVERLAP|ePRECISE_SWEEP
71  };
72 };
73 
74 
81 
82 
83 #define PxSceneQueryFlag PxHitFlag // PX_DEPRECATED
84 
85 #define PxSceneQueryFlags PxHitFlags // PX_DEPRECATED
86 
95 {
96  PX_INLINE PxActorShape() : actor(NULL), shape(NULL) {}
97  PX_INLINE PxActorShape(PxRigidActor* a, PxShape* s) : actor(a), shape(s) {}
98 
101 };
102 
103 
108 {
109  PX_INLINE PxQueryHit() : faceIndex(0xFFFFffff) {}
110 
120 };
121 
123 #define PxSceneQueryHit PxQueryHit
124 
131 struct PxLocationHit : public PxQueryHit
132 {
133  PX_INLINE PxLocationHit() : flags(0), position(PxVec3(0)), normal(PxVec3(0)), distance(PX_MAX_REAL) {}
134 
141  PX_INLINE bool hadInitialOverlap() const { return (distance <= 0.0f); }
142 
143  // the following fields are set in accordance with the #PxHitFlags
144  PxHitFlags flags;
145  PxVec3 position;
146 
148 
154 };
155 
156 
169 {
170  PX_INLINE PxRaycastHit() : u(0.0f), v(0.0f) {}
171 
172  // the following fields are set in accordance with the #PxHitFlags
173 
174  PxReal u, v;
175 #if !defined(PX_P64)
176  PxU32 padTo16Bytes[3];
177 #endif
178 };
179 
180 
187 
188 
194 struct PxSweepHit : public PxLocationHit
195 {
197 
199 };
200 
201 
210 typedef bool PxAgain;
211 
212 
226 template<typename HitType>
228 {
229  HitType block; //<! Holds the closest blocking hit result for the query. Invalid if hasBlock is false.
230  bool hasBlock; //<! Set to true if there was a blocking hit during query.
231 
232  HitType* touches; //<! User specified buffer for touching hits.
233 
239 
244 
256  PxHitCallback(HitType* aTouches, PxU32 aMaxNbTouches)
257  : hasBlock(false), touches(aTouches), maxNbTouches(aMaxNbTouches), nbTouches(0)
258  {}
259 
280  virtual PxAgain processTouches(const HitType* buffer, PxU32 nbHits) = 0;
281 
282  virtual void finalizeQuery() {} //<! Query finalization callback, called after the last processTouches callback.
283 
284  virtual ~PxHitCallback() {}
285 
287  PX_FORCE_INLINE bool hasAnyHits() { return (hasBlock || (nbTouches > 0)); }
288 };
289 
290 
304 template<typename HitType>
305 struct PxHitBuffer : public PxHitCallback<HitType>
306 {
317  PxHitBuffer(HitType* aTouches = NULL, PxU32 aMaxNbTouches = 0) : PxHitCallback<HitType>(aTouches, aMaxNbTouches) {}
318 
320  PX_INLINE PxU32 getNbAnyHits() const { return getNbTouches() + PxU32(this->hasBlock); }
322  PX_INLINE const HitType& getAnyHit(const PxU32 index) const { PX_ASSERT(index < getNbTouches() + PxU32(this->hasBlock));
323  return index < getNbTouches() ? getTouches()[index] : this->block; }
324 
325  PX_INLINE PxU32 getNbTouches() const { return this->nbTouches; }
326  PX_INLINE const HitType* getTouches() const { return this->touches; }
327  PX_INLINE const HitType& getTouch(const PxU32 index) const { PX_ASSERT(index < getNbTouches()); return getTouches()[index]; }
328  PX_INLINE PxU32 getMaxNbTouches() const { return this->maxNbTouches; }
329 
330  virtual ~PxHitBuffer() {}
331 
332 protected:
333  // stops after the first callback
334  virtual PxAgain processTouches(const HitType* buffer, PxU32 nbHits) { PX_UNUSED(buffer); PX_UNUSED(nbHits); return false; }
335 };
336 
337 
340 
343 
346 
349 
352 
355 
357 template <int N>
358 struct PxRaycastBufferN : PxHitBuffer<PxRaycastHit>
359 {
360  PxRaycastHit hits[N];
362 };
363 
365 template <int N>
366 struct PxOverlapBufferN : PxHitBuffer<PxOverlapHit>
367 {
368  PxOverlapHit hits[N];
370 };
371 
373 template <int N>
374 struct PxSweepBufferN : PxHitBuffer<PxSweepHit>
375 {
376  PxSweepHit hits[N];
378 };
379 
380 #ifndef PX_DOXYGEN
381 } // namespace physx
382 #endif
383 
385 #endif


Copyright © 2008-2015 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com