PxSolverDefs.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 #ifndef PX_SOLVER_DEFS_H
31 #define PX_SOLVER_DEFS_H
32 
33 
34 #include "PxPhysXConfig.h"
35 #include "foundation/PxVec3.h"
36 #include "foundation/PxMat33.h"
37 #include "foundation/PxTransform.h"
38 #include "PxConstraintDesc.h"
40 
41 #if PX_VC
42 #pragma warning(push)
43 #pragma warning(disable : 4324) // structure was padded due to alignment
44 #endif
45 
46 #if !PX_DOXYGEN
47 namespace physx
48 {
49 #endif
50 
51 namespace Dy
52 {
53  //struct FsData;
54  class ArticulationV;
55 }
56 
57 namespace Sc
58 {
59  class ShapeInteraction;
60 }
61 
63 {
64  PX_ALIGN(16, PxVec3) linearVelocity;
67 
69 
71 
72  PxSolverBody() : linearVelocity(0.f), maxSolverNormalProgress(0), maxSolverFrictionProgress(0), angularState(0), solverProgress(0)
73  {
74  }
75 };
76 
78 
80 {
81  PX_ALIGN(16, PxVec3 linearVelocity);
92 
93  PX_FORCE_INLINE PxReal projectVelocity(const PxVec3& lin, const PxVec3& ang) const
94  {
95  return linearVelocity.dot(lin) + angularVelocity.dot(ang);
96  }
97 };
98 
99 //----------------------------------
100 /*
101 * A header that defines the size of a specific batch of constraints (of same type and without dependencies)
102 */
104 {
108 };
109 
110 
112 {
113  static const PxU16 NO_LINK = 0xffff;
114 
116  {
118  eJOINT_CONSTRAINT
119  };
120 
121  union
122  {
124  Dy::ArticulationV* articulationA;
125  };
126 
127  union
128  {
130  Dy::ArticulationV* articulationB;
131  };
134  union
135  {
138  };
139 
140  union
141  {
144  };
145 
148 
150  void* writeBack;
151 };
152 
154 {
156  {
157  eDYNAMIC_BODY = 1 << 0,
158  eSTATIC_BODY = 1 << 1,
159  eKINEMATIC_BODY = 1 << 2,
160  eARTICULATION = 1 << 3
161  };
162 
164 
166 
169 
172 
175 
178 
179 };
180 
182 {
183  PX_ALIGN(16, Px1DConstraint* rows);
185 
186  PxReal linBreakForce, angBreakForce;
188  void* writeback;
193 
195 };
196 
197 
199 {
200 
201  PX_ALIGN(16, Sc::ShapeInteraction* shapeInteraction);
202  Gu::ContactPoint* contacts;
204 
208 
211 
214 
216 
219 
223 
224  PxU8 pad[16 - sizeof(void*)];
225 };
226 
228 {
229 public:
235  virtual PxU8* reserveConstraintData(const PxU32 byteSize) = 0;
242  virtual PxU8* reserveFrictionData(const PxU32 byteSize) = 0;
243 
245 };
246 
247 #if !PX_DOXYGEN
248 }
249 #endif
250 
251 #if PX_VC
252 #pragma warning(pop)
253 #endif
254 
255 #endif
256 
Definition: GuContactBuffer.h:37
PxVec3 angularState
Delta angular velocity state computed by the solver.
Definition: PxSolverDefs.h:68
PxU16 pad
112 pad
Definition: PxSolverDefs.h:91
BodyState bodyState0
In: Defines what kind of actor the first body is.
Definition: PxSolverDefs.h:176
PxU16 mStride
Number of constraints in this batch (range: 1-4)
Definition: PxSolverDefs.h:106
void * writeback
Pointer to constraint writeback structure. Reports back joint breaking. If not required, set to NULL.
Definition: PxSolverDefs.h:188
PxU8 frictionCount
The total number of friction patches in this pair.
Definition: PxSolverDefs.h:213
PxU32 numFrictionPatches
Total number of friction patches in this pair. Set by friction correlation.
Definition: PxSolverDefs.h:218
PxU16 linkIndexB
Link index defining which link in Articulation B this constraint affects. If not an articulation...
Definition: PxSolverDefs.h:133
Definition: PxSolverDefs.h:181
PxU32 bodyBDataIndex
Body B&#39;s index into the SolverBodyData array.
Definition: PxSolverDefs.h:143
Definition: PxSolverDefs.h:79
PxU32 startFrictionPatchIndex
Start index of friction patch in the correlation buffer. Set by friction correlation.
Definition: PxSolverDefs.h:217
bool hasForceThresholds
Defines whether this pair requires force thresholds.
Definition: PxSolverDefs.h:207
BodyState
Definition: PxSolverDefs.h:155
PxU16 linkIndexA
Link index defining which link in Articulation A this constraint affects. If not an articulation...
Definition: PxSolverDefs.h:132
PX_CUDA_CALLABLE PX_FORCE_INLINE float dot(const PxVec3 &v) const
returns the scalar product of this and other.
Definition: PxVec3.h:276
PxReal penBiasClamp
72 the penetration bias clamp
Definition: PxSolverDefs.h:86
#define PX_FORCE_INLINE
Definition: PxPreprocessor.h:364
float PxReal
Definition: PxSimpleTypes.h:78
PxU8 * frictionPtr
InOut: Friction patch correlation data. Set each frame by solver. Can be retained for improved behavi...
Definition: PxSolverDefs.h:212
Definition: PxSolverDefs.h:51
BodyState bodyState1
In: Defines what kind of actor the second body is.
Definition: PxSolverDefs.h:177
PxU16 numContactPatches
Total number of contact patches.
Definition: PxSolverDefs.h:221
PxVec3 body0WorldOffset
Body0 world offset.
Definition: PxSolverDefs.h:194
Defines this pair is a contact constraint.
Definition: PxSolverDefs.h:117
Definition: PxSolverDefs.h:227
A constraint.
Definition: PxConstraintDesc.h:141
PxReal maxContactImpulse
80 the max contact impulse
Definition: PxSolverDefs.h:88
const PxSolverBody * body1
In: The second body. Stores velocity information. Unused unless contact involves articulations.
Definition: PxSolverDefs.h:168
PxSolverBody * bodyA
bodyA pointer
Definition: PxSolverDefs.h:123
bool disableStrongFriction
Defines whether this pair disables strong friction (sticky friction correlation)
Definition: PxSolverDefs.h:206
PxReal invMass
16 inverse mass
Definition: PxSolverDefs.h:82
PxU16 lockFlags
110 lock flags
Definition: PxSolverDefs.h:90
PxU32 numContacts
The total number of contacs this pair references.
Definition: PxSolverDefs.h:203
Definition: PxConstraintDesc.h:189
PxU16 axisConstraintCount
Axis constraint count. Defines how many constraint rows this pair has produced. Useful for statistica...
Definition: PxSolverDefs.h:222
PxSolverBody()
Definition: PxSolverDefs.h:72
bool improvedSlerp
Use improved slerp model.
Definition: PxSolverDefs.h:190
PxU32 startContactPatchIndex
The start index of this pair&#39;s contact patches in the correlation buffer. For internal use only...
Definition: PxSolverDefs.h:220
virtual ~PxConstraintAllocator()
Definition: PxSolverDefs.h:244
PxSolverConstraintDesc * desc
Output: The PxSolverConstraintDesc filled in by contact prep.
Definition: PxSolverDefs.h:165
PxU16 writeBackLengthOver4
writeBackLength/4, max writeback length is 256K, allows PxSolverConstraintDesc to fit in 32 bytes ...
Definition: PxSolverDefs.h:146
Definition: PxSolverDefs.h:57
bool driveLimitsAreForces
Indicates whether drive limits are forces.
Definition: PxSolverDefs.h:191
bool hasMaxImpulse
Defines whether this pairs has maxImpulses clamping enabled.
Definition: PxSolverDefs.h:205
PxTransform bodyFrame0
In: The world-space transform of the first body.
Definition: PxSolverDefs.h:173
PxConstraintInvMassScale mInvMassScales
In: The local mass scaling for this pair.
Definition: PxSolverDefs.h:163
uint8_t PxU8
Definition: PxSimpleTypes.h:75
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
Definition: PxSolverDefs.h:198
ConstraintType
Definition: PxSolverDefs.h:115
Definition: PxSolverDefs.h:153
PxU16 constraintLengthOver16
constraintLength/16, max constraint length is 1MB, allows PxSolverConstraintDesc to fit in 32 bytes ...
Definition: PxSolverDefs.h:147
PxReal linBreakForce
Definition: PxSolverDefs.h:186
3x3 matrix class
Definition: PxMat33.h:90
PxU8 * constraint
Pointer to the constraint rows to be solved.
Definition: PxSolverDefs.h:149
Definition: PxSolverDefs.h:62
PxU32 nodeIndex
76 the node idx of this solverBodyData. Used by solver to reference between solver bodies and island ...
Definition: PxSolverDefs.h:87
PxVec3 angularVelocity
28 Pre-solver angular velocity
Definition: PxSolverDefs.h:83
PX_COMPILE_TIME_ASSERT(sizeof(PxSolverBody)==32)
PxSolverBody * bodyB
BodyB pointer.
Definition: PxSolverDefs.h:129
PxReal restDistance
A distance at which the solver should aim to hold the bodies separated. Default is 0...
Definition: PxSolverDefs.h:209
PxU16 maxSolverFrictionProgress
Progress counter used by constraint batching and parallel island solver.
Definition: PxSolverDefs.h:66
PxTransform bodyFrame1
In: The world-space transform of the second body.
Definition: PxSolverDefs.h:174
PxU32 solverProgress
Progress counter used by constraint batching and parallel island solver.
Definition: PxSolverDefs.h:70
PxU16 mConstraintType
The type of constraint this batch references.
Definition: PxSolverDefs.h:107
const PxSolverBody * body0
In: The first body. Stores velocity information. Unused unless contact involves articulations.
Definition: PxSolverDefs.h:167
#define PX_ALIGN(alignment, decl)
Definition: PxPreprocessor.h:421
bool disablePreprocessing
Disable joint pre-processing. Pre-processing can improve stability but under certain circumstances...
Definition: PxSolverDefs.h:189
PxU32 mStartIndex
Start index for this batch.
Definition: PxSolverDefs.h:105
PxU16 articulationALength
The total length of articulation A in multiples of 16 bytes.
Definition: PxSolverDefs.h:136
bool extendedLimits
Indicates whether we want to use extended limits.
Definition: PxSolverDefs.h:192
PxMat33 sqrtInvInertia
68 inverse inertia in world space
Definition: PxSolverDefs.h:85
PxU16 maxSolverNormalProgress
Progress counter used by constraint batching and parallel island solver.
Definition: PxSolverDefs.h:65
Definition: PxSolverDefs.h:111
Gu::ContactPoint * contacts
The start of the contacts for this pair.
Definition: PxSolverDefs.h:202
const PxSolverBodyData * data1
In: The second PxSolverBodyData. Stores mass and miscellaneous information for the second body...
Definition: PxSolverDefs.h:171
PxTransform body2World
108 the body&#39;s transform
Definition: PxSolverDefs.h:89
PxReal maxCCDSeparation
A distance used to configure speculative CCD behavior. Default is PX_MAX_F32. Set internally in PhysX...
Definition: PxSolverDefs.h:210
uint16_t PxU16
Definition: PxSimpleTypes.h:73
uint32_t PxU32
Definition: Px.h:48
PxReal reportThreshold
32 contact force threshold
Definition: PxSolverDefs.h:84
Dy::ArticulationV * articulationA
Articulation pointer for body A.
Definition: PxSolverDefs.h:124
PxU16 articulationBLength
The total lengh of articulation B in multiples of 16 bytes.
Definition: PxSolverDefs.h:142
PxReal minResponseThreshold
The minimum response threshold.
Definition: PxSolverDefs.h:187
PX_FORCE_INLINE PxReal projectVelocity(const PxVec3 &lin, const PxVec3 &ang) const
Definition: PxSolverDefs.h:93
PxReal * contactForces
Out: A buffer for the solver to write applied contact forces to.
Definition: PxSolverDefs.h:215
const PxSolverBodyData * data0
In: The first PxSolverBodyData. Stores mass and miscellaneous information for the first body...
Definition: PxSolverDefs.h:170
PxU32 bodyADataIndex
Body A&#39;s index into the SolverBodyData array.
Definition: PxSolverDefs.h:137
3 Element vector class.
Definition: PxVec3.h:49
Dy::ArticulationV * articulationB
Articulation pointer for body B.
Definition: PxSolverDefs.h:130
void * writeBack
Pointer to the writeback structure results for this given constraint are to be written to...
Definition: PxSolverDefs.h:150
Definition: PxSolverDefs.h:103
PxU32 numRows
The number of rows.
Definition: PxSolverDefs.h:184