00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
00319 eSUPPRESS = (1<<1),
00320
00326 eCALLBACK = (1<<2),
00327
00337 eNOTIFY = (1<<3) | eCALLBACK,
00338
00350 eDEFAULT = 0
00351 };
00352 };
00353
00359 typedef PxFlags<PxFilterFlag::Enum, PxU16> PxFilterFlags;
00360 PX_FLAGS_OPERATORS(PxFilterFlag::Enum, PxU16)
00361
00362
00363
00368 struct PxFilterData
00369 {
00370
00371
00372
00373
00374
00375
00376
00377 PX_INLINE PxFilterData(const PxEMPTY)
00378 {
00379 }
00380
00384 PX_INLINE PxFilterData()
00385 {
00386 word0 = word1 = word2 = word3 = 0;
00387 }
00388
00392 PX_INLINE PxFilterData(const PxFilterData& fd) : word0(fd.word0), word1(fd.word1), word2(fd.word2), word3(fd.word3) {}
00393
00397 PX_INLINE PxFilterData(PxU32 w0, PxU32 w1, PxU32 w2, PxU32 w3) : word0(w0), word1(w1), word2(w2), word3(w3) {}
00398
00402 PX_INLINE void setToDefault()
00403 {
00404 *this = PxFilterData();
00405 }
00406
00410 PX_INLINE void operator = (const PxFilterData& fd)
00411 {
00412 word0 = fd.word0;
00413 word1 = fd.word1;
00414 word2 = fd.word2;
00415 word3 = fd.word3;
00416 }
00417
00421 PX_INLINE bool operator == (const PxFilterData& a) const
00422 {
00423 return a.word0 == word0 && a.word1 == word1 && a.word2 == word2 && a.word3 == word3;
00424 }
00425
00429 PX_INLINE bool operator != (const PxFilterData& a) const
00430 {
00431 return !(a == *this);
00432 }
00433
00434 PxU32 word0;
00435 PxU32 word1;
00436 PxU32 word2;
00437 PxU32 word3;
00438 };
00439
00440
00446 struct PxFilterObjectType
00447 {
00448 enum Enum
00449 {
00454 eRIGID_STATIC,
00455
00460 eRIGID_DYNAMIC,
00461
00467 ePARTICLE_SYSTEM PX_DEPRECATED,
00468
00474 ePARTICLE_FLUID PX_DEPRECATED,
00475
00480 eARTICULATION,
00481
00486 eCLOTH,
00487
00488
00489 eMAX_TYPE_COUNT = 16,
00490
00491
00492 eUNDEFINED = eMAX_TYPE_COUNT-1
00493 };
00494 };
00495
00496
00497
00498 struct PxFilterObjectFlag
00499 {
00500 enum Enum
00501 {
00502 eKINEMATIC = (1<<4),
00503 eTRIGGER = (1<<5)
00504 };
00505 };
00506
00507
00513 typedef PxU32 PxFilterObjectAttributes;
00514
00515
00524 PX_INLINE PxFilterObjectType::Enum PxGetFilterObjectType(PxFilterObjectAttributes attr)
00525 {
00526 return static_cast<PxFilterObjectType::Enum>( (attr & (PxFilterObjectType::eMAX_TYPE_COUNT-1)) );
00527 }
00528
00529
00538 PX_INLINE bool PxFilterObjectIsKinematic(PxFilterObjectAttributes attr)
00539 {
00540 return ((attr & PxFilterObjectFlag::eKINEMATIC) != 0);
00541 }
00542
00543
00552 PX_INLINE bool PxFilterObjectIsTrigger(PxFilterObjectAttributes attr)
00553 {
00554 return ((attr & PxFilterObjectFlag::eTRIGGER) != 0);
00555 }
00556
00557
00612 typedef PxFilterFlags (*PxSimulationFilterShader)
00613 (PxFilterObjectAttributes attributes0, PxFilterData filterData0,
00614 PxFilterObjectAttributes attributes1, PxFilterData filterData1,
00615 PxPairFlags& pairFlags, const void* constantBlock, PxU32 constantBlockSize);
00616
00617
00618
00641 class PxSimulationFilterCallback
00642 {
00643 public:
00644
00668 virtual PxFilterFlags pairFound( PxU32 pairID,
00669 PxFilterObjectAttributes attributes0, PxFilterData filterData0, const PxActor* a0, const PxShape* s0,
00670 PxFilterObjectAttributes attributes1, PxFilterData filterData1, const PxActor* a1, const PxShape* s1,
00671 PxPairFlags& pairFlags) = 0;
00672
00688 virtual void pairLost( PxU32 pairID,
00689 PxFilterObjectAttributes attributes0,
00690 PxFilterData filterData0,
00691 PxFilterObjectAttributes attributes1,
00692 PxFilterData filterData1,
00693 bool objectRemoved) = 0;
00694
00717 virtual bool statusChange(PxU32& pairID, PxPairFlags& pairFlags, PxFilterFlags& filterFlags) = 0;
00718
00719 protected:
00720 virtual ~PxSimulationFilterCallback() {}
00721 };
00722
00723
00724 struct PxFilterInfo
00725 {
00726 PX_FORCE_INLINE PxFilterInfo() : filterFlags(0), pairFlags(0), filterPairIndex(INVALID_FILTER_PAIR_INDEX) {}
00727 PX_FORCE_INLINE PxFilterInfo(PxFilterFlags filterFlags_) : filterFlags(filterFlags_), pairFlags(0), filterPairIndex(INVALID_FILTER_PAIR_INDEX) {}
00728
00729 PxFilterFlags filterFlags;
00730 PxPairFlags pairFlags;
00731 PxU32 filterPairIndex;
00732 };
00733
00734 struct PxPairFilteringMode
00735 {
00736 enum Enum
00737 {
00742 eKEEP,
00743
00748 eSUPPRESS,
00749
00753 eKILL,
00754
00758 eDEFAULT
00759 };
00760 };
00761
00762 #if !PX_DOXYGEN
00763 }
00764 #endif
00765
00767 #endif