PxFiltering.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-2018 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_FILTERING
00032 #define PX_PHYSICS_NX_FILTERING
00033 
00037 #include "PxPhysXConfig.h"
00038 #include "foundation/PxFlags.h"
00039 
00040 #if !PX_DOXYGEN
00041 namespace physx
00042 {
00043 #endif
00044 
00045 class PxActor;
00046 class PxShape;
00047 
00048 static const PxU32 INVALID_FILTER_PAIR_INDEX = 0xffffffff;
00049 
00055 struct PxPairFlag
00056 {
00057     enum Enum
00058     {
00064         eSOLVE_CONTACT                      = (1<<0),
00065 
00073         eMODIFY_CONTACTS                    = (1<<1),
00074 
00089         eNOTIFY_TOUCH_FOUND                 = (1<<2),
00090 
00109         eNOTIFY_TOUCH_PERSISTS              = (1<<3),
00110 
00127         eNOTIFY_TOUCH_LOST                  = (1<<4),
00128 
00147         eNOTIFY_TOUCH_CCD                   = (1<<5),
00148 
00158         eNOTIFY_THRESHOLD_FORCE_FOUND       = (1<<6),
00159 
00172         eNOTIFY_THRESHOLD_FORCE_PERSISTS    = (1<<7),
00173 
00186         eNOTIFY_THRESHOLD_FORCE_LOST        = (1<<8),
00187 
00197         eNOTIFY_CONTACT_POINTS              = (1<<9),
00198 
00204         eDETECT_DISCRETE_CONTACT            = (1<<10),
00205         
00218         eDETECT_CCD_CONTACT                 = (1<<11),
00219 
00232         ePRE_SOLVER_VELOCITY                = (1<<12),
00233         
00242         ePOST_SOLVER_VELOCITY               = (1<<13),
00243         
00258         eCONTACT_EVENT_POSE                 = (1<<14),
00259 
00260         eNEXT_FREE                          = (1<<15),        
00261 
00265         eCONTACT_DEFAULT                    = eSOLVE_CONTACT | eDETECT_DISCRETE_CONTACT,
00266 
00270         eTRIGGER_DEFAULT                    = eNOTIFY_TOUCH_FOUND | eNOTIFY_TOUCH_LOST | eDETECT_DISCRETE_CONTACT
00271     };
00272 };
00273 
00279 typedef PxFlags<PxPairFlag::Enum, PxU16> PxPairFlags;
00280 PX_FLAGS_OPERATORS(PxPairFlag::Enum, PxU16)
00281 
00282 
00283 
00284 
00289 struct PxFilterFlag
00290 {
00291     enum Enum
00292     {
00304         eKILL               = (1<<0),
00305 
00317         eSUPPRESS           = (1<<1),
00318 
00324         eCALLBACK           = (1<<2),
00325 
00335         eNOTIFY             = (1<<3) | eCALLBACK,
00336 
00348         eDEFAULT = 0
00349     };
00350 };
00351 
00357 typedef PxFlags<PxFilterFlag::Enum, PxU16> PxFilterFlags;
00358 PX_FLAGS_OPERATORS(PxFilterFlag::Enum, PxU16)
00359 
00360 
00361 
00366 struct PxFilterData
00367 {
00368 //= ATTENTION! =====================================================================================
00369 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00370 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00371 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00372 // accordingly.
00373 //==================================================================================================
00374 
00375     PX_INLINE PxFilterData(const PxEMPTY)
00376     {
00377     }
00378 
00382     PX_INLINE PxFilterData() 
00383     {
00384         word0 = word1 = word2 = word3 = 0;
00385     }
00386 
00390     PX_INLINE PxFilterData(const PxFilterData& fd) : word0(fd.word0), word1(fd.word1), word2(fd.word2), word3(fd.word3) {}
00391 
00395     PX_INLINE PxFilterData(PxU32 w0, PxU32 w1, PxU32 w2, PxU32 w3) : word0(w0), word1(w1), word2(w2), word3(w3) {}
00396 
00400     PX_INLINE void setToDefault()
00401     {
00402         *this = PxFilterData();
00403     }
00404 
00408     PX_INLINE void operator = (const PxFilterData& fd)
00409     {
00410         word0 = fd.word0;
00411         word1 = fd.word1;
00412         word2 = fd.word2;
00413         word3 = fd.word3;
00414     }
00415 
00419     PX_INLINE bool operator == (const PxFilterData& a) const
00420     {
00421         return a.word0 == word0 && a.word1 == word1 && a.word2 == word2 && a.word3 == word3;
00422     }
00423 
00427     PX_INLINE bool operator != (const PxFilterData& a) const
00428     {
00429         return !(a == *this);
00430     }
00431 
00432     PxU32 word0;
00433     PxU32 word1;
00434     PxU32 word2;
00435     PxU32 word3;
00436 };
00437 
00438 
00444 struct PxFilterObjectType
00445 {
00446     enum Enum
00447     {
00452         eRIGID_STATIC,
00453 
00458         eRIGID_DYNAMIC,
00459 
00464         eARTICULATION,
00465 
00466         //brief internal use only!
00467         eMAX_TYPE_COUNT = 16,
00468 
00469         //brief internal use only!
00470         eUNDEFINED = eMAX_TYPE_COUNT-1
00471     };
00472 };
00473 
00474 
00475 // For internal use only
00476 struct PxFilterObjectFlag
00477 {
00478     enum Enum
00479     {
00480         eKINEMATIC      = (1<<4),
00481         eTRIGGER        = (1<<5)
00482     };
00483 };
00484 
00485 
00491 typedef PxU32 PxFilterObjectAttributes;
00492 
00493 
00502 PX_INLINE PxFilterObjectType::Enum PxGetFilterObjectType(PxFilterObjectAttributes attr)
00503 {
00504     return PxFilterObjectType::Enum(attr & (PxFilterObjectType::eMAX_TYPE_COUNT-1));
00505 }
00506 
00507 
00516 PX_INLINE bool PxFilterObjectIsKinematic(PxFilterObjectAttributes attr)
00517 {
00518     return (attr & PxFilterObjectFlag::eKINEMATIC) != 0;
00519 }
00520 
00521 
00530 PX_INLINE bool PxFilterObjectIsTrigger(PxFilterObjectAttributes attr)
00531 {
00532     return (attr & PxFilterObjectFlag::eTRIGGER) != 0;
00533 }
00534 
00535 
00588 typedef PxFilterFlags (*PxSimulationFilterShader)
00589     (PxFilterObjectAttributes attributes0, PxFilterData filterData0, 
00590      PxFilterObjectAttributes attributes1, PxFilterData filterData1,
00591      PxPairFlags& pairFlags, const void* constantBlock, PxU32 constantBlockSize);
00592 
00593 
00594 
00617 class PxSimulationFilterCallback
00618 {
00619 public:
00620 
00644     virtual     PxFilterFlags   pairFound(  PxU32 pairID,
00645         PxFilterObjectAttributes attributes0, PxFilterData filterData0, const PxActor* a0, const PxShape* s0,
00646         PxFilterObjectAttributes attributes1, PxFilterData filterData1, const PxActor* a1, const PxShape* s1,
00647         PxPairFlags& pairFlags) = 0;
00648 
00664     virtual     void            pairLost(   PxU32 pairID,
00665         PxFilterObjectAttributes attributes0,
00666         PxFilterData filterData0,
00667         PxFilterObjectAttributes attributes1,
00668         PxFilterData filterData1,
00669         bool objectRemoved) = 0;
00670 
00693     virtual     bool            statusChange(PxU32& pairID, PxPairFlags& pairFlags, PxFilterFlags& filterFlags) = 0;
00694 
00695 protected:
00696     virtual                     ~PxSimulationFilterCallback() {}
00697 };
00698 
00699 struct PxPairFilteringMode
00700 {
00701     enum Enum
00702     {
00707         eKEEP,
00708 
00713         eSUPPRESS,
00714 
00718         eKILL,
00719 
00723         eDEFAULT
00724     };
00725 };
00726 
00727 
00728 #if !PX_DOXYGEN
00729 } // namespace physx
00730 #endif
00731 
00733 #endif


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