NVIDIA(R) PhysX(R) SDK 3.4 API Reference: PxQueryReport.h Source File

NVIDIA PhysX SDK 3.4 API

PxQueryReport.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.  
00029 
00030 
00031 #ifndef PX_PHYSICS_NX_SCENEQUERYREPORT
00032 #define PX_PHYSICS_NX_SCENEQUERYREPORT
00033 
00036 #include "PxPhysXConfig.h"
00037 #include "foundation/PxVec3.h"
00038 #include "foundation/PxFlags.h"
00039 
00040 #if !PX_DOXYGEN
00041 namespace physx
00042 {
00043 #endif
00044 
00045 class PxShape;
00046 class PxRigidActor;
00047 
00061 struct PxHitFlag
00062 {
00063     enum Enum
00064     {
00065         ePOSITION                   = (1<<0),   
00066         eNORMAL                     = (1<<1),   
00067         PX_DEPRECATED eDISTANCE     = (1<<2),   
00068         eUV                         = (1<<3),   
00069         eASSUME_NO_INITIAL_OVERLAP  = (1<<4),   
00070 
00071         eMESH_MULTIPLE              = (1<<5),   
00072         eMESH_ANY                   = (1<<6),   
00073 
00074         eMESH_BOTH_SIDES            = (1<<7),   
00075 
00076 
00077         ePRECISE_SWEEP              = (1<<8),   
00078 
00079         eMTD                        = (1<<9),   
00080         eFACE_INDEX                 = (1<<10),  
00081 
00082         eDEFAULT                    = ePOSITION|eNORMAL|eDISTANCE|eFACE_INDEX,
00083 
00085         eMODIFIABLE_FLAGS           = eMESH_MULTIPLE|eMESH_BOTH_SIDES|eASSUME_NO_INITIAL_OVERLAP|ePRECISE_SWEEP
00086     };
00087 };
00088 
00089 
00095 PX_FLAGS_TYPEDEF(PxHitFlag, PxU16)
00096 
00097 
00104 struct PxActorShape
00105 {
00106     PX_INLINE PxActorShape() : actor(NULL), shape(NULL) {}
00107     PX_INLINE PxActorShape(PxRigidActor* a, PxShape* s) : actor(a), shape(s) {}
00108 
00109     PxRigidActor*   actor;
00110     PxShape*        shape;
00111 };
00112 
00113 
00117 struct PxQueryHit : public PxActorShape
00118 {
00119     PX_INLINE           PxQueryHit() : faceIndex(0xFFFFffff) {}
00120 
00129     PxU32               faceIndex;
00130 };
00131 
00138 struct PxLocationHit : public PxQueryHit
00139 {
00140     PX_INLINE           PxLocationHit() : flags(0), position(PxVec3(0)), normal(PxVec3(0)), distance(PX_MAX_REAL)   {}
00141 
00148     PX_INLINE bool      hadInitialOverlap() const { return (distance <= 0.0f); }
00149 
00150     // the following fields are set in accordance with the #PxHitFlags
00151     PxHitFlags          flags;      
00152     PxVec3              position;   
00153 
00154     PxVec3              normal;     
00155 
00160     PxF32               distance;
00161 };
00162 
00163 
00175 struct PxRaycastHit : public PxLocationHit
00176 {
00177     PX_INLINE           PxRaycastHit() : u(0.0f), v(0.0f)   {}
00178 
00179     // the following fields are set in accordance with the #PxHitFlags
00180 
00181     PxReal  u, v;           
00182 #if !PX_P64_FAMILY
00183     PxU32   padTo16Bytes[3];
00184 #endif
00185 };
00186 
00187 
00193 struct PxOverlapHit: public PxQueryHit { PxU32 padTo16Bytes; };
00194 
00195 
00201 struct PxSweepHit : public PxLocationHit
00202 {
00203     PX_INLINE           PxSweepHit() {}
00204 
00205     PxU32               padTo16Bytes;
00206 };
00207 
00208 
00217 typedef bool PxAgain;
00218 
00219 
00233 template<typename HitType>
00234 struct PxHitCallback
00235 {
00236     HitType     block;          
00237     bool        hasBlock;       
00238 
00239     HitType*    touches;        
00240 
00245     PxU32       maxNbTouches;
00246 
00250     PxU32       nbTouches;
00251 
00263     PxHitCallback(HitType* aTouches, PxU32 aMaxNbTouches)
00264         : hasBlock(false), touches(aTouches), maxNbTouches(aMaxNbTouches), nbTouches(0)
00265     {}
00266 
00287     virtual PxAgain processTouches(const HitType* buffer, PxU32 nbHits) = 0;
00288 
00289     virtual void finalizeQuery() {} 
00290 
00291     virtual ~PxHitCallback() {}
00292 
00294     PX_FORCE_INLINE bool hasAnyHits() { return (hasBlock || (nbTouches > 0)); }
00295 };
00296 
00297 
00311 template<typename HitType>
00312 struct PxHitBuffer : public PxHitCallback<HitType>
00313 {
00324     PxHitBuffer(HitType* aTouches = NULL, PxU32 aMaxNbTouches = 0) : PxHitCallback<HitType>(aTouches, aMaxNbTouches) {}
00325 
00327     PX_INLINE PxU32             getNbAnyHits() const                { return getNbTouches() + PxU32(this->hasBlock); }
00329     PX_INLINE const HitType&    getAnyHit(const PxU32 index) const  { PX_ASSERT(index < getNbTouches() + PxU32(this->hasBlock));
00330                                                                         return index < getNbTouches() ? getTouches()[index] : this->block; }
00331 
00332     PX_INLINE PxU32             getNbTouches() const                { return this->nbTouches; }
00333     PX_INLINE const HitType*    getTouches() const                  { return this->touches; }
00334     PX_INLINE const HitType&    getTouch(const PxU32 index) const   { PX_ASSERT(index < getNbTouches()); return getTouches()[index]; }
00335     PX_INLINE PxU32             getMaxNbTouches() const             { return this->maxNbTouches; }
00336 
00337     virtual ~PxHitBuffer() {}
00338 
00339 protected:
00340     // stops after the first callback
00341     virtual PxAgain processTouches(const HitType* buffer, PxU32 nbHits) { PX_UNUSED(buffer); PX_UNUSED(nbHits); return false; }
00342 };
00343 
00344 
00346 typedef PxHitCallback<PxRaycastHit> PxRaycastCallback;
00347 
00349 typedef PxHitCallback<PxOverlapHit> PxOverlapCallback;
00350 
00352 typedef PxHitCallback<PxSweepHit> PxSweepCallback;
00353 
00355 typedef PxHitBuffer<PxRaycastHit> PxRaycastBuffer;
00356 
00358 typedef PxHitBuffer<PxOverlapHit> PxOverlapBuffer;
00359 
00361 typedef PxHitBuffer<PxSweepHit> PxSweepBuffer;
00362 
00364 template <int N>
00365 struct PxRaycastBufferN : public PxHitBuffer<PxRaycastHit>
00366 {
00367     PxRaycastHit hits[N];
00368     PxRaycastBufferN() : PxHitBuffer<PxRaycastHit>(hits, N) {}
00369 };
00370 
00372 template <int N>
00373 struct PxOverlapBufferN : public PxHitBuffer<PxOverlapHit>
00374 {
00375     PxOverlapHit hits[N];
00376     PxOverlapBufferN() : PxHitBuffer<PxOverlapHit>(hits, N) {}
00377 };
00378 
00380 template <int N>
00381 struct PxSweepBufferN : public PxHitBuffer<PxSweepHit>
00382 {
00383     PxSweepHit hits[N];
00384     PxSweepBufferN() : PxHitBuffer<PxSweepHit>(hits, N) {}
00385 };
00386 
00387 #if !PX_DOXYGEN
00388 } // namespace physx
00389 #endif
00390 
00392 #endif


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