PxFiltering.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
27 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29 
30 
31 #ifndef PX_PHYSICS_NX_FILTERING
32 #define PX_PHYSICS_NX_FILTERING
33 
37 #include "PxPhysXConfig.h"
38 #include "foundation/PxFlags.h"
39 
40 #if !PX_DOXYGEN
41 namespace physx
42 {
43 #endif
44 
45 class PxActor;
46 class PxShape;
47 
48 static const PxU32 INVALID_FILTER_PAIR_INDEX = 0xffffffff;
49 
55 struct PxPairFlag
56 {
57  enum Enum
58  {
64  eSOLVE_CONTACT = (1<<0),
65 
73  eMODIFY_CONTACTS = (1<<1),
74 
89  eNOTIFY_TOUCH_FOUND = (1<<2),
90 
109  eNOTIFY_TOUCH_PERSISTS = (1<<3),
110 
127  eNOTIFY_TOUCH_LOST = (1<<4),
128 
147  eNOTIFY_TOUCH_CCD = (1<<5),
148 
158  eNOTIFY_THRESHOLD_FORCE_FOUND = (1<<6),
159 
172  eNOTIFY_THRESHOLD_FORCE_PERSISTS = (1<<7),
173 
186  eNOTIFY_THRESHOLD_FORCE_LOST = (1<<8),
187 
197  eNOTIFY_CONTACT_POINTS = (1<<9),
198 
204  eDETECT_DISCRETE_CONTACT = (1<<10),
205 
218  eDETECT_CCD_CONTACT = (1<<11),
219 
232  ePRE_SOLVER_VELOCITY = (1<<12),
233 
242  ePOST_SOLVER_VELOCITY = (1<<13),
243 
258  eCONTACT_EVENT_POSE = (1<<14),
259 
260  eNEXT_FREE = (1<<15),
261 
265  eCONTACT_DEFAULT = eSOLVE_CONTACT | eDETECT_DISCRETE_CONTACT,
266 
270  eTRIGGER_DEFAULT = eNOTIFY_TOUCH_FOUND | eNOTIFY_TOUCH_LOST | eDETECT_DISCRETE_CONTACT
271  };
272 };
273 
280 PX_FLAGS_OPERATORS(PxPairFlag::Enum, PxU16)
281 
282 
283 
284 
290 {
291  enum Enum
292  {
304  eKILL = (1<<0),
305 
317  eSUPPRESS = (1<<1),
318 
324  eCALLBACK = (1<<2),
325 
335  eNOTIFY = (1<<3) | eCALLBACK,
336 
348  eDEFAULT = 0
349  };
350 };
351 
358 PX_FLAGS_OPERATORS(PxFilterFlag::Enum, PxU16)
359 
360 
361 
367 {
368 //= ATTENTION! =====================================================================================
369 // Changing the data layout of this class breaks the binary serialization format. See comments for
370 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
371 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
372 // accordingly.
373 //==================================================================================================
374 
376  {
377  }
378 
383  {
384  word0 = word1 = word2 = word3 = 0;
385  }
386 
390  PX_INLINE PxFilterData(const PxFilterData& fd) : word0(fd.word0), word1(fd.word1), word2(fd.word2), word3(fd.word3) {}
391 
395  PX_INLINE PxFilterData(PxU32 w0, PxU32 w1, PxU32 w2, PxU32 w3) : word0(w0), word1(w1), word2(w2), word3(w3) {}
396 
401  {
402  *this = PxFilterData();
403  }
404 
408  PX_INLINE void operator = (const PxFilterData& fd)
409  {
410  word0 = fd.word0;
411  word1 = fd.word1;
412  word2 = fd.word2;
413  word3 = fd.word3;
414  }
415 
419  PX_INLINE bool operator == (const PxFilterData& a) const
420  {
421  return a.word0 == word0 && a.word1 == word1 && a.word2 == word2 && a.word3 == word3;
422  }
423 
427  PX_INLINE bool operator != (const PxFilterData& a) const
428  {
429  return !(a == *this);
430  }
431 
436 };
437 
438 
445 {
446  enum Enum
447  {
453 
459 
465 
466  //brief internal use only!
467  eMAX_TYPE_COUNT = 16,
468 
469  //brief internal use only!
470  eUNDEFINED = eMAX_TYPE_COUNT-1
471  };
472 };
473 
474 
475 // For internal use only
477 {
478  enum Enum
479  {
480  eKINEMATIC = (1<<4),
481  eTRIGGER = (1<<5)
482  };
483 };
484 
485 
492 
493 
503 {
505 }
506 
507 
517 {
518  return (attr & PxFilterObjectFlag::eKINEMATIC) != 0;
519 }
520 
521 
531 {
532  return (attr & PxFilterObjectFlag::eTRIGGER) != 0;
533 }
534 
535 
589  (PxFilterObjectAttributes attributes0, PxFilterData filterData0,
590  PxFilterObjectAttributes attributes1, PxFilterData filterData1,
591  PxPairFlags& pairFlags, const void* constantBlock, PxU32 constantBlockSize);
592 
593 
594 
618 {
619 public:
620 
644  virtual PxFilterFlags pairFound( PxU32 pairID,
645  PxFilterObjectAttributes attributes0, PxFilterData filterData0, const PxActor* a0, const PxShape* s0,
646  PxFilterObjectAttributes attributes1, PxFilterData filterData1, const PxActor* a1, const PxShape* s1,
647  PxPairFlags& pairFlags) = 0;
648 
664  virtual void pairLost( PxU32 pairID,
665  PxFilterObjectAttributes attributes0,
666  PxFilterData filterData0,
667  PxFilterObjectAttributes attributes1,
668  PxFilterData filterData1,
669  bool objectRemoved) = 0;
670 
693  virtual bool statusChange(PxU32& pairID, PxPairFlags& pairFlags, PxFilterFlags& filterFlags) = 0;
694 
695 protected:
697 };
698 
700 {
701  enum Enum
702  {
708 
714 
719 
723  eDEFAULT
724  };
725 };
726 
727 
728 #if !PX_DOXYGEN
729 } // namespace physx
730 #endif
731 
733 #endif
Definition: GuContactBuffer.h:37
Definition: PxFiltering.h:480
Definition: PxFiltering.h:718
Definition: PxFiltering.h:467
PxFilterData is user-definable data which gets passed into the collision filtering shader and/or call...
Definition: PxFiltering.h:366
PxActor is the base class for the main simulation objects in the physics SDK.
Definition: PxActor.h:154
Enum
Definition: PxFiltering.h:57
Enum
Definition: PxFiltering.h:446
Abstract class for collision shapes.
Definition: PxShape.h:142
A static rigid body.
Definition: PxFiltering.h:452
PxFilterFlags(* PxSimulationFilterShader)(PxFilterObjectAttributes attributes0, PxFilterData filterData0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, PxPairFlags &pairFlags, const void *constantBlock, PxU32 constantBlockSize)
Filter shader to specify handling of collision pairs.
Definition: PxFiltering.h:589
A dynamic rigid body.
Definition: PxFiltering.h:458
PX_INLINE void setToDefault()
(re)sets the structure to the default.
Definition: PxFiltering.h:400
Collection of flags describing the actions to take for a collision pair.
Definition: PxFiltering.h:55
Enum
Definition: PxFiltering.h:478
Definition: PxFiltering.h:707
static const PxU32 INVALID_FILTER_PAIR_INDEX
Definition: PxFiltering.h:48
PxU32 word1
Definition: PxFiltering.h:433
PxU32 PxFilterObjectAttributes
Structure which gets passed into the collision filtering shader and/or callback providing additional ...
Definition: PxFiltering.h:491
Identifies each type of filter object.
Definition: PxFiltering.h:444
PxU32 word2
Definition: PxFiltering.h:434
PX_INLINE PxFilterData(const PxEMPTY)
Definition: PxFiltering.h:375
Enum
Definition: PxFiltering.h:291
Definition: PxFiltering.h:699
Definition: PxFiltering.h:713
PX_INLINE PxFilterData()
Default constructor.
Definition: PxFiltering.h:382
PxU32 word0
Definition: PxFiltering.h:432
An articulation.
Definition: PxFiltering.h:464
Definition: PxFiltering.h:481
PxU32 word3
Definition: PxFiltering.h:435
PxFlags< PxPairFlag::Enum, PxU16 > PxPairFlags
Bitfield that contains a set of raised flags defined in PxPairFlag.
Definition: PxFiltering.h:279
Collection of flags describing the filter actions to take for a collision pair.
Definition: PxFiltering.h:289
Filter callback to specify handling of collision pairs.
Definition: PxFiltering.h:617
PX_INLINE PxFilterData(const PxFilterData &fd)
Copy constructor.
Definition: PxFiltering.h:390
PxFlags< PxFilterFlag::Enum, PxU16 > PxFilterFlags
Bitfield that contains a set of raised flags defined in PxFilterFlag.
Definition: PxFiltering.h:357
PxEMPTY
Definition: Px.h:70
virtual ~PxSimulationFilterCallback()
Definition: PxFiltering.h:696
PX_INLINE PxFilterObjectType::Enum PxGetFilterObjectType(PxFilterObjectAttributes attr)
Extract filter object type from the filter attributes of a collision pair object. ...
Definition: PxFiltering.h:502
Definition: PxFiltering.h:476
PX_INLINE bool PxFilterObjectIsKinematic(PxFilterObjectAttributes attr)
Specifies whether the collision object belongs to a kinematic rigid body.
Definition: PxFiltering.h:516
PX_INLINE bool PxFilterObjectIsTrigger(PxFilterObjectAttributes attr)
Specifies whether the collision object is a trigger shape.
Definition: PxFiltering.h:530
uint16_t PxU16
Definition: PxSimpleTypes.h:73
uint32_t PxU32
Definition: Px.h:48
#define PX_INLINE
Definition: PxPreprocessor.h:349
Enum
Definition: PxFiltering.h:701
PX_INLINE PxFilterData(PxU32 w0, PxU32 w1, PxU32 w2, PxU32 w3)
Constructor to set filter data initially.
Definition: PxFiltering.h:395