RavEngine
Loading...
Searching...
No Matches
PxFiltering.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_FILTERING_H
30#define PX_FILTERING_H
35#include "PxPhysXConfig.h"
36#include "foundation/PxFlags.h"
37
38#if !PX_DOXYGEN
39namespace physx
40{
41#endif
42
43class PxActor;
44class PxShape;
45
46static const PxU32 INVALID_FILTER_PAIR_INDEX = 0xffffffff;
47
271
278PX_FLAGS_OPERATORS(PxPairFlag::Enum, PxU16)
279
280
281
282
288{
289 enum Enum
290 {
302 eKILL = (1<<0),
303
315 eSUPPRESS = (1<<1),
316
322 eCALLBACK = (1<<2),
323
333 eNOTIFY = (1<<3) | eCALLBACK,
334
346 eDEFAULT = 0
347 };
348};
349
356PX_FLAGS_OPERATORS(PxFilterFlag::Enum, PxU16)
357
358
359
365{
366//= ATTENTION! =====================================================================================
367// Changing the data layout of this class breaks the binary serialization format. See comments for
368// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
369// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
370// accordingly.
371//==================================================================================================
372
374 {
375 }
376
381 {
382 word0 = word1 = word2 = word3 = 0;
383 }
384
388 PX_INLINE PxFilterData(const PxFilterData& fd) : word0(fd.word0), word1(fd.word1), word2(fd.word2), word3(fd.word3) {}
389
393 PX_INLINE PxFilterData(PxU32 w0, PxU32 w1, PxU32 w2, PxU32 w3) : word0(w0), word1(w1), word2(w2), word3(w3) {}
394
399 {
400 *this = PxFilterData();
401 }
402
406 PX_INLINE void operator = (const PxFilterData& fd)
407 {
408 word0 = fd.word0;
409 word1 = fd.word1;
410 word2 = fd.word2;
411 word3 = fd.word3;
412 }
413
417 PX_INLINE bool operator == (const PxFilterData& a) const
418 {
419 return a.word0 == word0 && a.word1 == word1 && a.word2 == word2 && a.word3 == word3;
420 }
421
425 PX_INLINE bool operator != (const PxFilterData& a) const
426 {
427 return !(a == *this);
428 }
429
430 PxU32 word0;
431 PxU32 word1;
432 PxU32 word2;
433 PxU32 word3;
434};
435
436
497
498
499// For internal use only
501{
502 enum Enum
503 {
504 eKINEMATIC = (1<<4),
505 eTRIGGER = (1<<5)
506 };
507};
508
509
516
517
530
531
541{
542 return (attr & PxFilterObjectFlag::eKINEMATIC) != 0;
543}
544
545
555{
556 return (attr & PxFilterObjectFlag::eTRIGGER) != 0;
557}
558
604 (PxFilterObjectAttributes attributes0, PxFilterData filterData0,
605 PxFilterObjectAttributes attributes1, PxFilterData filterData1,
606 PxPairFlags& pairFlags, const void* constantBlock, PxU32 constantBlockSize);
607
608
609
633{
634public:
635
659 virtual PxFilterFlags pairFound( PxU32 pairID,
660 PxFilterObjectAttributes attributes0, PxFilterData filterData0, const PxActor* a0, const PxShape* s0,
661 PxFilterObjectAttributes attributes1, PxFilterData filterData1, const PxActor* a1, const PxShape* s1,
662 PxPairFlags& pairFlags) = 0;
663
679 virtual void pairLost( PxU32 pairID,
680 PxFilterObjectAttributes attributes0,
681 PxFilterData filterData0,
682 PxFilterObjectAttributes attributes1,
683 PxFilterData filterData1,
684 bool objectRemoved) = 0;
685
708 virtual bool statusChange(PxU32& pairID, PxPairFlags& pairFlags, PxFilterFlags& filterFlags) = 0;
709
710protected:
711 virtual ~PxSimulationFilterCallback() {}
712};
713
715{
716 enum Enum
717 {
729
734
739
744 };
745};
746
751{
752 PxU64 mID0;
753 PxU64 mID1;
754
755 PX_CUDA_CALLABLE bool operator<(const PxParticleRigidFilterPair& other) const
756 {
757 if(mID0 < other.mID0)
758 return true;
759 if(mID0 == other.mID0 && mID1 < other.mID1)
760 return true;
761 return false;
762 }
763
764 PX_CUDA_CALLABLE bool operator>(const PxParticleRigidFilterPair& other) const
765 {
766 if(mID0 > other.mID0)
767 return true;
768 if(mID0 == other.mID0 && mID1 > other.mID1)
769 return true;
770 return false;
771 }
772
773 PX_CUDA_CALLABLE bool operator==(const PxParticleRigidFilterPair& other) const
774 {
775 return (mID0 == other.mID0 && mID1 == other.mID1);
776 }
777};
778
779
780#if !PX_DOXYGEN
781} // namespace physx
782#endif
783
785#endif
PxActor is the base class for the main simulation objects in the physics SDK.
Definition PxActor.h:201
Container for bitfield flag variables associated with a specific enum type.
Definition PxFlags.h:73
Abstract class for collision shapes.
Definition PxShape.h:146
Filter callback to specify handling of collision pairs.
Definition PxFiltering.h:633
virtual void pairLost(PxU32 pairID, PxFilterObjectAttributes attributes0, PxFilterData filterData0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, bool objectRemoved)=0
Callback to inform that a tracked collision pair is gone.
virtual bool statusChange(PxU32 &pairID, PxPairFlags &pairFlags, PxFilterFlags &filterFlags)=0
Callback to give the opportunity to change the filter state of a tracked collision pair.
virtual PxFilterFlags pairFound(PxU32 pairID, PxFilterObjectAttributes attributes0, PxFilterData filterData0, const PxActor *a0, const PxShape *s0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, const PxActor *a1, const PxShape *s1, PxPairFlags &pairFlags)=0
Filter method to specify how a pair of potentially colliding objects should be processed.
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxU32 PxFilterObjectAttributes
Structure which gets passed into the collision filtering shader and/or callback providing additional ...
Definition PxFiltering.h:515
PX_INLINE bool PxFilterObjectIsKinematic(PxFilterObjectAttributes attr)
Specifies whether the collision object belongs to a kinematic rigid body.
Definition PxFiltering.h:540
PX_INLINE PxFilterObjectType::Enum PxGetFilterObjectType(PxFilterObjectAttributes attr)
Extract filter object type from the filter attributes of a collision pair object.
Definition PxFiltering.h:526
PxFilterFlags(* PxSimulationFilterShader)(PxFilterObjectAttributes attributes0, PxFilterData filterData0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, PxPairFlags &pairFlags, const void *constantBlock, PxU32 constantBlockSize)
Filter method to specify how a pair of potentially colliding objects should be processed.
Definition PxFiltering.h:604
PxFlags< PxFilterFlag::Enum, PxU16 > PxFilterFlags
Bitfield that contains a set of raised flags defined in PxFilterFlag.
Definition PxFiltering.h:355
PxFlags< PxPairFlag::Enum, PxU16 > PxPairFlags
Bitfield that contains a set of raised flags defined in PxPairFlag.
Definition PxFiltering.h:277
PX_INLINE bool PxFilterObjectIsTrigger(PxFilterObjectAttributes attr)
Specifies whether the collision object is a trigger shape.
Definition PxFiltering.h:554
PxEMPTY
Definition Px.h:87
PxFilterData is user-definable data which gets passed into the collision filtering shader and/or call...
Definition PxFiltering.h:365
PX_INLINE PxFilterData(PxU32 w0, PxU32 w1, PxU32 w2, PxU32 w3)
Constructor to set filter data initially.
Definition PxFiltering.h:393
PX_INLINE void setToDefault()
(re)sets the structure to the default.
Definition PxFiltering.h:398
PX_INLINE PxFilterData()
Default constructor.
Definition PxFiltering.h:380
PX_INLINE PxFilterData(const PxFilterData &fd)
Copy constructor.
Definition PxFiltering.h:388
Collection of flags describing the filter actions to take for a collision pair.
Definition PxFiltering.h:288
Enum
Definition PxFiltering.h:290
Definition PxFiltering.h:501
Identifies each type of filter object.
Definition PxFiltering.h:443
Enum
Definition PxFiltering.h:445
@ eSOFTBODY
A FEM-based soft body.
Definition PxFiltering.h:474
@ eARTICULATION
An articulation.
Definition PxFiltering.h:462
@ eMAX_TYPE_COUNT
internal use only!
Definition PxFiltering.h:491
@ ePARTICLESYSTEM
A particle system.
Definition PxFiltering.h:468
@ eFEMCLOTH
A FEM-based cloth.
Definition PxFiltering.h:481
@ eRIGID_DYNAMIC
A dynamic rigid body.
Definition PxFiltering.h:456
@ eRIGID_STATIC
A static rigid body.
Definition PxFiltering.h:450
@ eHAIRSYSTEM
A hair system.
Definition PxFiltering.h:488
@ eUNDEFINED
internal use only!
Definition PxFiltering.h:494
Definition PxFiltering.h:715
Enum
Definition PxFiltering.h:717
@ eDEFAULT
Default is eSUPPRESS for compatibility with previous PhysX versions.
Definition PxFiltering.h:743
@ eKILL
Don't output pair from BP. Cannot be later switched to regular interaction, needs "resetFiltering" ca...
Definition PxFiltering.h:738
@ eSUPPRESS
Output pair from BP, create interaction marker. Can be later switched to regular interaction.
Definition PxFiltering.h:733
@ eKEEP
Output pair from BP, potentially send to user callbacks, create regular interaction object.
Definition PxFiltering.h:728
Collection of flags describing the actions to take for a collision pair.
Definition PxFiltering.h:54
Enum
Definition PxFiltering.h:56
@ eDETECT_CCD_CONTACT
This flag is used to indicate whether this pair generates CCD contacts.
Definition PxFiltering.h:216
@ eNEXT_FREE
For internal use only.
Definition PxFiltering.h:258
@ ePOST_SOLVER_VELOCITY
Provide post solver velocities in contact reports for this collision pair.
Definition PxFiltering.h:240
@ eCONTACT_EVENT_POSE
Provide rigid body poses in contact reports for this collision pair.
Definition PxFiltering.h:256
@ ePRE_SOLVER_VELOCITY
Provide pre solver velocities in contact reports for this collision pair.
Definition PxFiltering.h:230
@ eCONTACT_DEFAULT
Provided default flag to do simple contact processing for this collision pair.
Definition PxFiltering.h:263
@ eTRIGGER_DEFAULT
Provided default flag to get commonly used trigger behavior for this collision pair.
Definition PxFiltering.h:268
@ eNOTIFY_TOUCH_CCD
Call contact report callback when this collision pair is in contact during CCD passes.
Definition PxFiltering.h:145
@ eNOTIFY_CONTACT_POINTS
Provide contact points in contact reports for this collision pair.
Definition PxFiltering.h:195
@ eNOTIFY_THRESHOLD_FORCE_LOST
Call contact report callback when the contact force between the actors of this collision pair falls b...
Definition PxFiltering.h:184
@ eNOTIFY_TOUCH_LOST
Call contact report callback or trigger callback when this collision pair stops to be in contact.
Definition PxFiltering.h:125
@ eMODIFY_CONTACTS
Call contact modification callback for this collision pair.
Definition PxFiltering.h:71
@ eNOTIFY_THRESHOLD_FORCE_FOUND
Call contact report callback when the contact force between the actors of this collision pair exceeds...
Definition PxFiltering.h:156
@ eNOTIFY_TOUCH_FOUND
Call contact report callback or trigger callback when this collision pair starts to be in contact.
Definition PxFiltering.h:87
@ eNOTIFY_TOUCH_PERSISTS
Call contact report callback while this collision pair is in contact.
Definition PxFiltering.h:107
@ eSOLVE_CONTACT
Process the contacts of this collision pair in the dynamics solver.
Definition PxFiltering.h:62
@ eNOTIFY_THRESHOLD_FORCE_PERSISTS
Call contact report callback when the contact force between the actors of this collision pair continu...
Definition PxFiltering.h:170
@ eDETECT_DISCRETE_CONTACT
This flag is used to indicate whether this pair generates discrete collision detection contacts.
Definition PxFiltering.h:202
Struct for storing a particle/vertex - rigid filter pair with comparison operators.
Definition PxFiltering.h:751
PxU64 mID1
Particle/vertex id.
Definition PxFiltering.h:753
PxU64 mID0
Rigid node index.
Definition PxFiltering.h:752