RavEngine
Loading...
Searching...
No Matches
PxsContactManager.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 PXS_CONTACT_MANAGER_H
30#define PXS_CONTACT_MANAGER_H
31
32#include "PxvConfig.h"
33#include "PxcNpWorkUnit.h"
34
35namespace physx
36{
37class PxsContext;
38class PxsRigidBody;
39
40namespace Dy
41{
42 class DynamicsContext;
43}
44
45namespace Sc
46{
47 class ShapeInteraction;
48}
49
54{
62 PxU16 contactStreamSize; //6 //10
69 PxU16 isFromPreviousPass; //8 //12
70
71 PxU8 pad[12 - sizeof(PxsCCDContactHeader*)]; //16
72};
73
75
77{
78public:
81
82 PX_FORCE_INLINE void setDisableStrongFriction(PxU32 d) { (!d) ? mNpUnit.flags &= ~PxcNpWorkUnitFlag::eDISABLE_STRONG_FRICTION
83 : mNpUnit.flags |= PxcNpWorkUnitFlag::eDISABLE_STRONG_FRICTION; }
84
85 PX_FORCE_INLINE PxReal getRestDistance() const { return mNpUnit.restDistance; }
86 PX_FORCE_INLINE void setRestDistance(PxReal v) { mNpUnit.restDistance = v; }
87
88 PX_FORCE_INLINE PxU8 getDominance0() const { return mNpUnit.dominance0; }
89 PX_FORCE_INLINE void setDominance0(PxU8 v) { mNpUnit.dominance0 = v; }
90
91 PX_FORCE_INLINE PxU8 getDominance1() const { return mNpUnit.dominance1; }
92 PX_FORCE_INLINE void setDominance1(PxU8 v) { mNpUnit.dominance1 = v; }
93
94 PX_FORCE_INLINE PxU16 getTouchStatus() const { return PxU16(mNpUnit.statusFlags & PxcNpWorkUnitStatusFlag::eHAS_TOUCH); }
95 PX_FORCE_INLINE PxU16 touchStatusKnown() const { return PxU16(mNpUnit.statusFlags & PxcNpWorkUnitStatusFlag::eTOUCH_KNOWN); }
96 PX_FORCE_INLINE PxI32 getTouchIdx() const { return (mNpUnit.statusFlags& PxcNpWorkUnitStatusFlag::eHAS_TOUCH) ? 1 : (mNpUnit.statusFlags& PxcNpWorkUnitStatusFlag::eHAS_NO_TOUCH ? -1 : 0); }
97
98 PX_FORCE_INLINE PxU32 getIndex() const { return mNpUnit.index; }
99
100 PX_FORCE_INLINE PxU16 getHasCCDRetouch() const { return PxU16(mNpUnit.statusFlags & PxcNpWorkUnitStatusFlag::eHAS_CCD_RETOUCH); }
101 PX_FORCE_INLINE void clearCCDRetouch() { mNpUnit.statusFlags &= ~PxcNpWorkUnitStatusFlag::eHAS_CCD_RETOUCH; }
102 PX_FORCE_INLINE void raiseCCDRetouch() { mNpUnit.statusFlags |= PxcNpWorkUnitStatusFlag::eHAS_CCD_RETOUCH; }
103
104 // flags stuff - needs to be refactored
105
106 PX_FORCE_INLINE PxIntBool isChangeable() const { return PxIntBool(mFlags & PXS_CM_CHANGEABLE); }
107 PX_FORCE_INLINE PxIntBool getCCD() const { return PxIntBool((mFlags & PXS_CM_CCD_LINEAR) && (mNpUnit.flags & PxcNpWorkUnitFlag::eDETECT_CCD_CONTACTS)); }
108 PX_FORCE_INLINE PxIntBool getHadCCDContact() const { return PxIntBool(mFlags & PXS_CM_CCD_CONTACT); }
109 PX_FORCE_INLINE void setHadCCDContact() { mFlags |= PXS_CM_CCD_CONTACT; }
110 void setCCD(bool enable);
111 PX_FORCE_INLINE void clearCCDContactInfo() { mFlags &= ~PXS_CM_CCD_CONTACT; mNpUnit.ccdContacts = NULL; }
112
113 PX_FORCE_INLINE PxcNpWorkUnit& getWorkUnit() { return mNpUnit; }
114 PX_FORCE_INLINE const PxcNpWorkUnit& getWorkUnit() const { return mNpUnit; }
115
116 PX_FORCE_INLINE Sc::ShapeInteraction* getShapeInteraction() const { return mShapeInteraction; }
117
118 // Setup solver-constraints
119 PX_FORCE_INLINE void resetCachedState()
120 {
121 // happens when the body transform or shape relative transform changes.
122 mNpUnit.clearCachedState();
123 }
124private:
125 //KS - moving this up - we want to get at flags
126
127 PxsRigidBody* mRigidBody0; //4 //8
128 PxsRigidBody* mRigidBody1; //8 //16
129 PxU32 mFlags; //20 //36
130 Sc::ShapeInteraction* mShapeInteraction; //16 //32
131
132 friend class PxsContext;
133 // everything required for narrow phase to run
134 PxcNpWorkUnit mNpUnit;
135 enum
136 {
137 PXS_CM_CHANGEABLE = (1<<0),
138 PXS_CM_CCD_LINEAR = (1<<1),
139 PXS_CM_CCD_CONTACT = (1 << 2)
140 };
141
142 friend class Dy::DynamicsContext;
143 friend struct PxsCCDPair;
144 friend class PxsIslandManager;
145 friend class PxsCCDContext;
146 friend class Sc::ShapeInteraction;
147 //friend class Sc::SoftBodyShapeInteraction;
148};
149
150}
151
152#endif
Definition base.h:1940
Encapsules the data used by the constraint solver.
Definition DyDynamics.h:149
CCD context object.
Definition PxsCCD.h:423
Definition PxsContactManager.h:77
Definition PxsContext.h:92
Definition PxsRigidBody.h:43
Definition ScShapeInteraction.h:54
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_COMPILE_TIME_ASSERT(exp)
Definition PxPreprocessor.h:428
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition PxcNpWorkUnit.h:63
Definition PxcNpWorkUnit.h:81
Additional header structure for CCD contact data stream.
Definition PxsContactManager.h:54
PxU16 contactStreamSize
Size (in bytes) of the CCD contact stream (not including force buffer)
Definition PxsContactManager.h:62
PxU16 isFromPreviousPass
Defines whether the stream is from a previous pass.
Definition PxsContactManager.h:69
PxsCCDContactHeader * nextStream
Stream for next collision. The same pair can collide multiple times during multiple CCD passes.
Definition PxsContactManager.h:58
A structure to represent a potential CCD interaction between a pair of shapes.
Definition PxsCCD.h:332