PxFiltering.h

Go to the documentation of this file.
00001 //
00002 // Redistribution and use in source and binary forms, with or without
00003 // modification, are permitted provided that the following conditions
00004 // are met:
00005 //  * Redistributions of source code must retain the above copyright
00006 //    notice, this list of conditions and the following disclaimer.
00007 //  * Redistributions in binary form must reproduce the above copyright
00008 //    notice, this list of conditions and the following disclaimer in the
00009 //    documentation and/or other materials provided with the distribution.
00010 //  * Neither the name of NVIDIA CORPORATION nor the names of its
00011 //    contributors may be used to endorse or promote products derived
00012 //    from this software without specific prior written permission.
00013 //
00014 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
00015 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017 // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00018 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 
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 //= ATTENTION! =====================================================================================
00371 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00372 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00373 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00374 // accordingly.
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         //brief internal use only!
00489         eMAX_TYPE_COUNT = 16,
00490 
00491         //brief internal use only!
00492         eUNDEFINED = eMAX_TYPE_COUNT-1
00493     };
00494 };
00495 
00496 
00497 // For internal use only
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 } // namespace physx
00764 #endif
00765 
00767 #endif


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