RavEngine
Loading...
Searching...
No Matches
PxConstraintDesc.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_CONSTRAINT_DESC_H
30#define PX_CONSTRAINT_DESC_H
31
36#include "PxPhysXConfig.h"
37#include "foundation/PxFlags.h"
38#include "foundation/PxVec3.h"
39#include "common/PxBase.h"
40
41#if !PX_DOXYGEN
42namespace physx { namespace pvdsdk {
43#endif
44 class PvdDataStream;
45#if !PX_DOXYGEN
46}}
47#endif
48
49#if !PX_DOXYGEN
50namespace physx
51{
52#endif
53
60{
61 PX_CUDA_CALLABLE Px1DConstraintFlag(){}
62
74};
75
76typedef PxFlags<Px1DConstraintFlag::Type, PxU16> Px1DConstraintFlags;
77PX_FLAGS_OPERATORS(Px1DConstraintFlag::Type, PxU16)
78
79
83{
84 enum Enum
85 {
86 eNONE = 0,
87 eACCELERATION1 = 256,
88 eSLERP_SPRING = 258,
89 eACCELERATION2 = 512,
90 eACCELERATION3 = 768,
91 eROTATIONAL_EQUALITY = 1024,
92 eROTATIONAL_INEQUALITY = 1025,
93 eEQUALITY = 2048,
94 eINEQUALITY = 2049
95 };
96};
97
132PX_ALIGN_PREFIX(16)
134{
139
141 PxReal minImpulse;
143 PxReal maxImpulse;
144
145 union
146 {
147 struct SpringModifiers
148 {
149 PxReal stiffness;
150 PxReal damping;
151 } spring;
152 struct RestitutionModifiers
153 {
154 PxReal restitution;
156 } bounce;
157 } mods;
158
160 PxU16 flags;
161 PxU16 solveHint;
162}
163PX_ALIGN_SUFFIX(16);
164
171{
172 enum Enum
173 {
175 eLIMITS = 2
176 };
177};
178
182PX_ALIGN_PREFIX(16)
184{
185//= ATTENTION! =====================================================================================
186// Changing the data layout of this class breaks the binary serialization format. See comments for
187// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
188// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
189// accordingly.
190//==================================================================================================
191
192 PxReal linear0;
193 PxReal angular0;
194 PxReal linear1;
195 PxReal angular1;
196
197 PX_CUDA_CALLABLE PX_FORCE_INLINE PxConstraintInvMassScale(){}
198 PX_CUDA_CALLABLE PX_FORCE_INLINE PxConstraintInvMassScale(PxReal lin0, PxReal ang0, PxReal lin1, PxReal ang1) : linear0(lin0), angular0(ang0), linear1(lin1), angular1(ang1){}
199}
200PX_ALIGN_SUFFIX(16);
201
223typedef PxU32 (*PxConstraintSolverPrep)(Px1DConstraint* constraints,
224 PxVec3p& bodyAWorldOffset,
225 PxU32 maxConstraints,
226 PxConstraintInvMassScale& invMassScale,
227 const void* constantBlock,
228 const PxTransform& bodyAToWorld,
229 const PxTransform& bodyBToWorld,
230 bool useExtendedLimits,
231 PxVec3p& cAtW,
232 PxVec3p& cBtW);
233
247typedef PX_DEPRECATED void (*PxConstraintProject)(const void* constantBlock,
248 PxTransform& bodyAToWorld,
249 PxTransform& bodyBToWorld,
250 bool projectToA);
251
256{
257protected:
258 virtual ~PxConstraintVisualizer(){}
259public:
265 virtual void visualizeJointFrames(const PxTransform& parent, const PxTransform& child) = 0;
266
274 virtual void visualizeLinearLimit(const PxTransform& t0, const PxTransform& t1, PxReal value, bool active) = 0;
275
283 virtual void visualizeAngularLimit(const PxTransform& t0, PxReal lower, PxReal upper, bool active) = 0;
284
292 virtual void visualizeLimitCone(const PxTransform& t, PxReal tanQSwingY, PxReal tanQSwingZ, bool active) = 0;
293
300 virtual void visualizeDoubleCone(const PxTransform& t, PxReal angle, bool active) = 0;
301
308 virtual void visualizeLine(const PxVec3& p0, const PxVec3& p1, PxU32 color) = 0;
309};
310
324 const void* constantBlock,
325 const PxTransform& body0Transform,
326 const PxTransform& body1Transform,
327 PxU32 flags);
328
344
354{
355public:
360 virtual void* prepareData() = 0;
361
366 const PxConstraint* c,
367 PxPvdUpdateType::Enum updateType) const = 0;
368
372 virtual void updateOmniPvdProperties() const = 0;
373
385 virtual void onConstraintRelease() = 0;
386
395 virtual void onComShift(PxU32 actor) = 0;
396
410 virtual void onOriginShift(const PxVec3& shift) = 0;
411
424 virtual void* getExternalReference(PxU32& typeID) = 0;
425
431 virtual PxBase* getSerializable() = 0;
432
436 virtual PxConstraintSolverPrep getPrep() const = 0;
437
441 virtual const void* getConstantBlock() const = 0;
442
447
452};
453
454#if !PX_DOXYGEN
455} // namespace physx
456#endif
457
459#endif
Base class for objects that can be members of a PxCollection.
Definition PxBase.h:73
This class connects a custom constraint to the SDK.
Definition PxConstraintDesc.h:354
virtual PxBase * getSerializable()=0
Obtain a reference to a PxBase interface if the constraint has one.
virtual void onComShift(PxU32 actor)=0
Center-of-mass shift callback.
virtual void updateOmniPvdProperties() const =0
this function is called by the SDK to update OmniPVD's view of it
virtual const void * getConstantBlock() const =0
Obtain the pointer to the constraint's constant data.
virtual ~PxConstraintConnector()
virtual destructor
Definition PxConstraintDesc.h:451
virtual void connectToConstraint(PxConstraint *)
Let the connector know it has been connected to a constraint.
Definition PxConstraintDesc.h:446
virtual void * getExternalReference(PxU32 &typeID)=0
Fetches external data for a constraint.
virtual void * prepareData()=0
Pre-simulation data preparation when the constraint is marked dirty, this function is called at the s...
virtual bool updatePvdProperties(physx::pvdsdk::PvdDataStream &pvdConnection, const PxConstraint *c, PxPvdUpdateType::Enum updateType) const =0
this function is called by the SDK to update PVD's view of it
virtual PxConstraintSolverPrep getPrep() const =0
Obtain the shader function pointer used to prep rows for this constraint.
virtual void onOriginShift(const PxVec3 &shift)=0
Origin shift callback.
virtual void onConstraintRelease()=0
Constraint release callback.
API used to visualize details about a constraint.
Definition PxConstraintDesc.h:256
virtual void visualizeAngularLimit(const PxTransform &t0, PxReal lower, PxReal upper, bool active)=0
Visualize joint angular limit.
virtual void visualizeLine(const PxVec3 &p0, const PxVec3 &p1, PxU32 color)=0
Visualize line.
virtual void visualizeLimitCone(const PxTransform &t, PxReal tanQSwingY, PxReal tanQSwingZ, bool active)=0
Visualize limit cone.
virtual void visualizeLinearLimit(const PxTransform &t0, const PxTransform &t1, PxReal value, bool active)=0
Visualize joint linear limit.
virtual void visualizeJointFrames(const PxTransform &parent, const PxTransform &child)=0
Visualize joint frames.
virtual void visualizeDoubleCone(const PxTransform &t, PxReal angle, bool active)=0
Visualize joint double cone.
A plugin class for implementing constraints.
Definition PxConstraint.h:100
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
A padded version of PxVec3, to safely load its data using SIMD.
Definition PxVec3.h:392
3 Element vector class.
Definition PxVec3.h:50
Definition PxPvdDataStream.h:241
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_DEPRECATED
Definition PxPreprocessor.h:418
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxU32(* PxConstraintSolverPrep)(Px1DConstraint *constraints, PxVec3p &bodyAWorldOffset, PxU32 maxConstraints, PxConstraintInvMassScale &invMassScale, const void *constantBlock, const PxTransform &bodyAToWorld, const PxTransform &bodyBToWorld, bool useExtendedLimits, PxVec3p &cAtW, PxVec3p &cBtW)
Solver constraint generation shader.
Definition PxConstraintDesc.h:223
void(* PxConstraintVisualize)(PxConstraintVisualizer &visualizer, const void *constantBlock, const PxTransform &body0Transform, const PxTransform &body1Transform, PxU32 flags)
Solver constraint visualization function.
Definition PxConstraintDesc.h:323
PX_DEPRECATED void(* PxConstraintProject)(const void *constantBlock, PxTransform &bodyAToWorld, PxTransform &bodyBToWorld, bool projectToA)
Solver constraint projection shader.
Definition PxConstraintDesc.h:247
Constraint row flags.
Definition PxConstraintDesc.h:60
Type
Definition PxConstraintDesc.h:64
@ eOUTPUT_FORCE
whether to accumulate the force value from this constraint in the force total that is reported for th...
Definition PxConstraintDesc.h:69
@ eANGULAR_CONSTRAINT
whether this is an angular or linear constraint
Definition PxConstraintDesc.h:71
@ eRESTITUTION
whether the restitution model should be applied to generate the target velocity. Mutually exclusive w...
Definition PxConstraintDesc.h:67
@ eKEEPBIAS
whether to keep the error term when solving for velocity. Ignored if restitution generates bounce,...
Definition PxConstraintDesc.h:68
@ eACCELERATION_SPRING
whether the constraint is a force or acceleration spring. Only valid if eSPRING is set.
Definition PxConstraintDesc.h:66
@ eSPRING
whether the constraint is a spring. Mutually exclusive with eRESTITUTION. If set, eKEEPBIAS is ignore...
Definition PxConstraintDesc.h:65
@ eDRIVE_ROW
whether the constraint's geometric error should drive the target velocity
Definition PxConstraintDesc.h:72
@ eHAS_DRIVE_LIMIT
whether the constraint has a drive force limit (which will be scaled by dt unless PxConstraintFlag::e...
Definition PxConstraintDesc.h:70
A one-dimensional constraint.
Definition PxConstraintDesc.h:134
PxReal maxImpulse
maximum impulse the solver may apply to enforce this constraint
Definition PxConstraintDesc.h:143
PxVec3 angular0
angular component of velocity jacobian in world space
Definition PxConstraintDesc.h:137
PxReal minImpulse
minimum impulse the solver may apply to enforce this constraint
Definition PxConstraintDesc.h:141
PxVec3 angular1
angular component of velocity jacobian in world space
Definition PxConstraintDesc.h:142
PxReal forInternalUse
for internal use only
Definition PxConstraintDesc.h:159
PxU16 flags
a set of Px1DConstraintFlags
Definition PxConstraintDesc.h:160
PxReal velocityTarget
velocity target for the constraint along this axis
Definition PxConstraintDesc.h:138
PxReal damping
damping parameter, for spring constraints
Definition PxConstraintDesc.h:150
PxReal stiffness
spring parameter, for spring constraints
Definition PxConstraintDesc.h:149
PxReal geometricError
geometric error of the constraint along this axis
Definition PxConstraintDesc.h:136
PxReal restitution
restitution parameter for determining additional "bounce"
Definition PxConstraintDesc.h:154
PxReal velocityThreshold
minimum impact velocity for bounce
Definition PxConstraintDesc.h:155
PxU16 solveHint
constraint optimization hint, should be an element of PxConstraintSolveHint
Definition PxConstraintDesc.h:161
PxVec3 linear0
linear component of velocity jacobian in world space
Definition PxConstraintDesc.h:135
PxVec3 linear1
linear component of velocity jacobian in world space
Definition PxConstraintDesc.h:140
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
Constraint type hints which the solver uses to optimize constraint handling.
Definition PxConstraintDesc.h:83
Enum
Definition PxConstraintDesc.h:85
Flags for determining which components of the constraint should be visualized.
Definition PxConstraintDesc.h:171
Enum
Definition PxConstraintDesc.h:173
@ eLIMITS
visualize constraint limits
Definition PxConstraintDesc.h:175
@ eLOCAL_FRAMES
visualize constraint frames
Definition PxConstraintDesc.h:174
Flags for determining how PVD should serialize a constraint update.
Definition PxConstraintDesc.h:335
Enum
Definition PxConstraintDesc.h:337
@ RELEASE_INSTANCE
triggers releasePvdInstance call, releases an instance of a constraint
Definition PxConstraintDesc.h:339
@ UPDATE_ALL_PROPERTIES
triggers updatePvdProperties call, updates all properties of a constraint
Definition PxConstraintDesc.h:340
@ CREATE_INSTANCE
triggers createPvdInstance call, creates an instance of a constraint
Definition PxConstraintDesc.h:338
@ UPDATE_SIM_PROPERTIES
triggers simUpdate call, updates all simulation properties of a constraint
Definition PxConstraintDesc.h:341