RavEngine
Loading...
Searching...
No Matches
DySolverConstraint1DStep.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 DY_SOLVER_CONSTRAINT_1D_STEP_H
30#define DY_SOLVER_CONSTRAINT_1D_STEP_H
31
32#include "foundation/PxVec3.h"
33#include "PxvConfig.h"
34#include "DyArticulationUtils.h"
35#include "DySolverConstraintTypes.h"
36#include "DySolverBody.h"
37#include "PxConstraintDesc.h"
38#include "DySolverConstraintDesc.h"
39
40
41namespace physx
42{
43 namespace Dy
44 {
46 {
47 enum DySolverContactFlags
48 {
49 eHAS_FORCE_THRESHOLDS = 0x1
50 };
51
52 PxU8 type; //Note: mType should be first as the solver expects a type in the first byte.
53 PxU8 flags;
54 PxU8 numNormalConstr;
55 PxU8 numFrictionConstr; //4
56
57 PxReal angDom0; //8
58 PxReal angDom1; //12
59 PxReal invMass0; //16
60
61 Vec4V staticFrictionX_dynamicFrictionY_dominance0Z_dominance1W; //32
62 PxVec3 normal; //48
63
64 PxReal maxPenBias; //52
65 PxReal invMass1; //56
66 PxReal minNormalForce; //60
67 PxU32 broken; //64
68 PxU8* frictionBrokenWritebackByte; //68 72
69 Sc::ShapeInteraction* shapeInteraction; //72 80
70#if !PX_P64_FAMILY
71 PxU32 pad[2]; //80
72#endif
73
74 PX_FORCE_INLINE FloatV getStaticFriction() const { return V4GetX(staticFrictionX_dynamicFrictionY_dominance0Z_dominance1W); }
75 PX_FORCE_INLINE FloatV getDynamicFriction() const { return V4GetY(staticFrictionX_dynamicFrictionY_dominance0Z_dominance1W); }
76 PX_FORCE_INLINE FloatV getDominance0() const { return V4GetZ(staticFrictionX_dynamicFrictionY_dominance0Z_dominance1W); }
77 PX_FORCE_INLINE FloatV getDominance1() const { return V4GetW(staticFrictionX_dynamicFrictionY_dominance0Z_dominance1W); }
78 };
79
81 {
82 PxVec3 raXnI;
83 PxF32 separation;
84 PxVec3 rbXnI;
85 PxF32 velMultiplier;
86 PxF32 targetVelocity;
87 PxF32 biasCoefficient;
88 PxF32 recipResponse;
89 PxF32 maxImpulse;
90 };
91
93 {
94 Vec3V linDeltaVA;
95 Vec3V linDeltaVB;
96 Vec3V angDeltaVA;
97 Vec3V angDeltaVB;
98 };
99
101 {
102 Vec4V normalXYZ_ErrorW; //16
103 Vec4V raXnI_targetVelW;
104 Vec4V rbXnI_velMultiplierW;
105 PxReal biasScale;
106 PxReal appliedForce;
107 PxReal frictionScale;
108 PxU32 pad[1];
109
110 PX_FORCE_INLINE void setAppliedForce(const FloatV f) { FStore(f, &appliedForce); }
111 };
112
114 {
115 Vec3V linDeltaVA;
116 Vec3V linDeltaVB;
117 Vec3V angDeltaVA;
118 Vec3V angDeltaVB;
119 };
120
122 {
123 PxU8 type; // enum SolverConstraintType - must be first byte
124 PxU8 count; // count of following 1D constraints
125 PxU8 dominance;
126 PxU8 breakable; // indicate whether this constraint is breakable or not
127 PxReal linBreakImpulse;
128 PxReal angBreakImpulse;
129 PxReal invMass0D0;
130
131 PxVec3 body0WorldOffset;
132 PxReal invMass1D1;
133
134 PxVec3 rAWorld;
135 PxReal linearInvMassScale0; // only used by articulations
136
137 PxVec3 rBWorld;
138 PxReal angularInvMassScale0;
139
140 PxReal linearInvMassScale1; // only used by articulations
141 PxReal angularInvMassScale1;
142 PxU32 pad[2];
143
144 //Ortho axes for body 0, recipResponse in W component
145 PxVec4 angOrthoAxis0_recipResponseW[3];
146 //Ortho axes for body 1, error of body in W component
147 PxVec4 angOrthoAxis1_Error[3];
148 };
149
150
152 PxU8 count,
153 bool isExtended,
154 const PxConstraintInvMassScale& ims)
155 {
156 h.type = PxU8(isExtended ? DY_SC_TYPE_EXT_1D : DY_SC_TYPE_RB_1D);
157 h.count = count;
158 h.dominance = 0;
159 h.linearInvMassScale0 = ims.linear0;
160 h.angularInvMassScale0 = ims.angular0;
161 h.linearInvMassScale1 = -ims.linear1;
162 h.angularInvMassScale1 = -ims.angular1;
163 }
164
165
166 PX_ALIGN_PREFIX(16)
168 {
169 public:
171 PxReal error;
172
174 PxReal biasScale;
175
178
180 PxReal velTarget;
181
182 PxReal minImpulse;
183 PxReal maxImpulse;
185 PxReal maxBias;
186
187 PxU32 flags;
188 PxReal recipResponse; //Constant. Only used for articulations;
189 PxReal angularErrorScale; //Constant
190 PxU32 pad;
191 } PX_ALIGN_SUFFIX(16);
192
194 {
195 public:
196 Cm::SpatialVectorV deltaVA;
197 Cm::SpatialVectorV deltaVB;
198 };
199
201 const PxVec3& _linear0, const PxVec3& _linear1,
202 const PxVec3& _angular0, const PxVec3& _angular1,
203 PxReal _minImpulse, PxReal _maxImpulse)
204 {
205 PX_ASSERT(_linear0.isFinite());
206 PX_ASSERT(_linear1.isFinite());
207 c.lin0 = _linear0;
208 c.lin1 = _linear1;
209 c.ang0 = _angular0;
210 c.ang1 = _angular1;
211 c.minImpulse = _minImpulse;
212 c.maxImpulse = _maxImpulse;
213 c.flags = 0;
214 c.appliedForce = 0;
215 c.angularErrorScale = 1.f;
216 }
217
218 }//namespace Dy
219}
220
221#endif
3 Element vector class.
Definition PxVec3.h:50
PX_CUDA_CALLABLE PX_INLINE bool isFinite() const
returns true if all 3 elems of the vector are finite (not NAN or INF, etc.)
Definition PxVec3.h:156
Definition PxVec4.h:50
Definition ScShapeInteraction.h:54
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition CmSpatialVector.h:483
Definition DySolverConstraint1DStep.h:194
Definition DySolverConstraint1DStep.h:122
Definition DySolverConstraint1DStep.h:168
PxVec3 lin1
linear velocity projection (body 1)
Definition DySolverConstraint1DStep.h:173
PxReal maxImpulse
Upper bound on impulse magnitude.
Definition DySolverConstraint1DStep.h:183
PxVec3 ang0
angular velocity projection (body 0)
Definition DySolverConstraint1DStep.h:176
PxReal appliedForce
applied force to correct velocity+bias
Definition DySolverConstraint1DStep.h:184
PxReal velMultiplier
constraint velocity multiplier
Definition DySolverConstraint1DStep.h:177
PxVec3 lin0
linear velocity projection (body 0)
Definition DySolverConstraint1DStep.h:170
PxReal error
constraint error term - must be scaled by biasScale. Can be adjusted at run-time
Definition DySolverConstraint1DStep.h:171
PxReal biasScale
constraint constant bias scale. Constant
Definition DySolverConstraint1DStep.h:174
PxReal minImpulse
Lower bound on impulse magnitude
Definition DySolverConstraint1DStep.h:182
PxReal velTarget
Scaled target velocity of the constraint drive.
Definition DySolverConstraint1DStep.h:180
PxVec3 ang1
angular velocity projection (body 1)
Definition DySolverConstraint1DStep.h:179
Definition DySolverConstraint1DStep.h:114
Definition DySolverConstraint1DStep.h:101
Definition DySolverConstraint1DStep.h:46
Definition DySolverConstraint1DStep.h:93
Definition DySolverConstraint1DStep.h:81
Struct for specifying mass scaling for a pair of rigids.
Definition PxConstraintDesc.h:184
PxReal angular1
multiplier for inverse MoI of body1
Definition PxConstraintDesc.h:195
PxReal linear0
multiplier for inverse mass of body0
Definition PxConstraintDesc.h:192
PxReal angular0
multiplier for inverse MoI of body0
Definition PxConstraintDesc.h:193
PxReal linear1
multiplier for inverse mass of body1
Definition PxConstraintDesc.h:194
Definition PxVecMathAoSScalar.h:52
Definition PxVecMathAoSScalar.h:77
Definition PxVecMathAoSScalar.h:65