PxConstraintDesc.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-2021 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_PHYSICS_NX_CONSTRAINTDESC
31 #define PX_PHYSICS_NX_CONSTRAINTDESC
32 
37 #include "PxPhysXConfig.h"
38 #include "foundation/PxFlags.h"
39 #include "foundation/PxVec3.h"
40 #include "common/PxBase.h"
41 
42 #if !PX_DOXYGEN
43 namespace physx { namespace pvdsdk {
44 #endif
45  class PvdDataStream;
46 #if !PX_DOXYGEN
47 }}
48 #endif
49 
50 #if !PX_DOXYGEN
51 namespace physx
52 {
53 #endif
54 
56 class PxRigidActor;
57 class PxScene;
59 class PxRenderBuffer;
60 class PxDeletionListener;
61 
68 {
70 
71  enum Type
72  {
73  eSPRING = 1<<0,
74  eACCELERATION_SPRING = 1<<1,
75  eRESTITUTION = 1<<2,
76  eKEEPBIAS = 1<<3,
77  eOUTPUT_FORCE = 1<<4,
78  eHAS_DRIVE_LIMIT = 1<<5,
79  eANGULAR_CONSTRAINT = 1 << 6,
80  eDRIVE_ROW = 1 << 7
81  };
82 };
83 
85 PX_FLAGS_OPERATORS(Px1DConstraintFlag::Type, PxU16)
86 
87 
91 {
92  enum Enum
93  {
94  eNONE = 0,
95  eACCELERATION1 = 256,
96  eSLERP_SPRING = 258,
97  eACCELERATION2 = 512,
98  eACCELERATION3 = 768,
99  eROTATIONAL_EQUALITY = 1024,
100  eROTATIONAL_INEQUALITY = 1025,
101  eEQUALITY = 2048,
102  eINEQUALITY = 2049
103  };
104 };
140 PX_ALIGN_PREFIX(16)
142 {
147 
152 
153  union
154  {
155  struct SpringModifiers
156  {
159  } spring;
160  struct RestitutionModifiers
161  {
164  } bounce;
165  } mods;
166 
170 }
171 PX_ALIGN_SUFFIX(16);
172 
173 
180 {
181  enum Enum
182  {
183  eLOCAL_FRAMES = 1,
184  eLIMITS = 2
185  };
186 };
187 
188 PX_ALIGN_PREFIX(16)
190 {
191 //= ATTENTION! =====================================================================================
192 // Changing the data layout of this class breaks the binary serialization format. See comments for
193 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
194 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
195 // accordingly.
196 //==================================================================================================
197 
202 
205 }
206 PX_ALIGN_SUFFIX(16);
207 
229  PxVec3& bodyAWorldOffset,
230  PxU32 maxConstraints,
231  PxConstraintInvMassScale& invMassScale,
232  const void* constantBlock,
233  const PxTransform& bodyAToWorld,
234  const PxTransform& bodyBToWorld,
235  bool useExtendedLimits,
236  PxVec3& cAtW,
237  PxVec3& cBtW);
238 
249 typedef void (*PxConstraintProject)(const void* constantBlock,
250  PxTransform& bodyAToWorld,
251  PxTransform& bodyBToWorld,
252  bool projectToA);
253 
258 {
259 protected:
261 public:
267  virtual void visualizeJointFrames(const PxTransform& parent, const PxTransform& child) = 0;
268 
276  virtual void visualizeLinearLimit(const PxTransform& t0, const PxTransform& t1, PxReal value, bool active) = 0;
277 
285  virtual void visualizeAngularLimit(const PxTransform& t0, PxReal lower, PxReal upper, bool active) = 0;
286 
294  virtual void visualizeLimitCone(const PxTransform& t, PxReal tanQSwingY, PxReal tanQSwingZ, bool active) = 0;
295 
302  virtual void visualizeDoubleCone(const PxTransform& t, PxReal angle, bool active) = 0;
303 
310  virtual void visualizeLine(const PxVec3& p0, const PxVec3& p1, PxU32 color) = 0;
311 };
312 
325 typedef void (*PxConstraintVisualize)(PxConstraintVisualizer& visualizer,
326  const void* constantBlock,
327  const PxTransform& body0Transform,
328  const PxTransform& body1Transform,
329  PxU32 flags);
330 
331 
333 {
334  enum Enum
335  {
339  UPDATE_SIM_PROPERTIES
340  };
341 };
342 
353 {
354 public:
359  virtual void* prepareData() = 0;
360 
364  virtual bool updatePvdProperties(physx::pvdsdk::PvdDataStream& pvdConnection,
365  const PxConstraint* c,
366  PxPvdUpdateType::Enum updateType) const = 0;
367 
378  virtual void onConstraintRelease() = 0;
379 
386  virtual void onComShift(PxU32 actor) = 0;
387 
399  virtual void onOriginShift(const PxVec3& shift) = 0;
400 
413  virtual void* getExternalReference(PxU32& typeID) = 0;
414 
420  virtual PxBase* getSerializable() = 0;
421 
425  virtual PxConstraintSolverPrep getPrep() const = 0;
426 
430  virtual const void* getConstantBlock() const = 0;
431 
436 };
437 
438 #if !PX_DOXYGEN
439 } // namespace physx
440 #endif
441 
443 #endif
Definition: GuContactBuffer.h:37
A scene is a collection of bodies and constraints which can interact.
Definition: PxScene.h:169
PxReal damping
damping parameter, for spring constraints
Definition: PxConstraintDesc.h:158
PxVec3 linear0
linear component of velocity jacobian in world space
Definition: PxConstraintDesc.h:143
PxReal minImpulse
minimum impulse the solver may apply to enforce this constraint
Definition: PxConstraintDesc.h:149
Definition: PxConstraintDesc.h:257
Definition: PxConstraintDesc.h:336
PxReal stiffness
spring parameter, for spring constraints
Definition: PxConstraintDesc.h:157
PxVec3 linear0
linear component of velocity jacobian in world space
Definition: PxConstraintDesc.h:85
PxVec3 angular0
angular component of velocity jacobian in world space
Definition: PxConstraintDesc.h:87
PxVec3 linear1
linear component of velocity jacobian in world space
Definition: PxConstraintDesc.h:148
constraint row flags
Definition: PxConstraintDesc.h:67
#define PX_FORCE_INLINE
Definition: PxPreprocessor.h:351
float PxReal
Definition: PxSimpleTypes.h:78
struct @6::SpringModifiers spring
uint32_t PxU32
Definition: PxSimpleTypes.h:71
PxReal linear0
multiplier for inverse mass of body0
Definition: PxConstraintDesc.h:198
PxReal angular1
multiplier for inverse MoI of body1
Definition: PxConstraintDesc.h:201
PxU32(* PxConstraintSolverPrep)(Px1DConstraint *constraints, PxVec3 &bodyAWorldOffset, PxU32 maxConstraints, PxConstraintInvMassScale &invMassScale, const void *constantBlock, const PxTransform &bodyAToWorld, const PxTransform &bodyBToWorld, bool useExtendedLimits, PxVec3 &cAtW, PxVec3 &cBtW)
Definition: PxConstraintDesc.h:228
A constraint.
Definition: PxConstraintDesc.h:141
Flags for determining which components of the constraint should be visualized.
Definition: PxConstraintDesc.h:179
PxReal forInternalUse
for internal use only
Definition: PxConstraintDesc.h:167
PxVec3 linear1
linear component of velocity jacobian in world space
Definition: PxConstraintDesc.h:90
PxReal velocityTarget
velocity target for the constraint along this axis
Definition: PxConstraintDesc.h:146
struct @6::RestitutionModifiers bounce
PxReal restitution
restitution parameter for determining additional "bounce"
Definition: PxConstraintDesc.h:162
virtual ~PxConstraintVisualizer()
Definition: PxConstraintDesc.h:260
PxReal maxImpulse
maximum impulse the solver may apply to enforce this constraint
Definition: PxConstraintDesc.h:151
PxVec3 angular1
angular component of velocity jacobian in world space
Definition: PxConstraintDesc.h:92
Definition: PxConstraintDesc.h:189
PxReal geometricError
geometric error of the constraint along this axis
Definition: PxConstraintDesc.h:144
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition: PxRigidActor.h:58
Type
Definition: PxConstraintDesc.h:71
PxVec3 angular0
angular component of velocity jacobian in world space
Definition: PxConstraintDesc.h:145
constraint type hints which the solver uses to optimize constraint handling
Definition: PxConstraintDesc.h:90
PxU16 flags
a set of Px1DConstraintFlags
Definition: PxConstraintDesc.h:110
#define PX_ALIGN_PREFIX(alignment)
Definition: PxPreprocessor.h:409
Definition: PxConstraintDesc.h:332
PxFlags< Px1DConstraintFlag::Type, PxU16 > Px1DConstraintFlags
Definition: PxConstraintDesc.h:84
Interface for points, lines, triangles, and text buffer.
Definition: PxRenderBuffer.h:131
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
A plugin class for implementing constraints.
Definition: PxConstraint.h:108
PX_CUDA_CALLABLE PX_FORCE_INLINE PxConstraintInvMassScale(PxReal lin0, PxReal ang0, PxReal lin1, PxReal ang1)
Definition: PxConstraintDesc.h:204
void(* PxConstraintProject)(const void *constantBlock, PxTransform &bodyAToWorld, PxTransform &bodyBToWorld, bool projectToA)
Definition: PxConstraintDesc.h:249
interface to get notification on object deletion
Definition: PxDeletionListener.h:73
PX_CUDA_CALLABLE PX_FORCE_INLINE PxConstraintInvMassScale()
Definition: PxConstraintDesc.h:203
PxReal angular0
multiplier for inverse MoI of body0
Definition: PxConstraintDesc.h:199
union @6 mods
PxU16 flags
a set of Px1DConstraintFlags
Definition: PxConstraintDesc.h:168
void(* PxConstraintVisualize)(PxConstraintVisualizer &visualizer, const void *constantBlock, const PxTransform &body0Transform, const PxTransform &body1Transform, PxU32 flags)
Definition: PxConstraintDesc.h:325
Enum
Definition: PxConstraintDesc.h:334
Definition: PxConstraintDesc.h:338
Container for bitfield flag variables associated with a specific enum type.
Definition: PxFlags.h:73
PxU16 solveHint
constraint optimization hint, should be an element of PxConstraintSolveHint
Definition: PxConstraintDesc.h:169
Definition: PxConstraintDesc.h:337
uint16_t PxU16
Definition: PxSimpleTypes.h:73
Enum
Definition: PxConstraintDesc.h:181
uint32_t PxU32
Definition: Px.h:48
Base class for objects that can be members of a PxCollection.
Definition: PxBase.h:73
PxReal velocityThreshold
minimum impact velocity for bounce
Definition: PxConstraintDesc.h:163
#define PX_CUDA_CALLABLE
Definition: PxPreprocessor.h:460
struct PxConstraintVisualizationFlag PX_ALIGN_SUFFIX
3 Element vector class.
Definition: PxVec3.h:49
virtual ~PxConstraintConnector()
virtual destructor
Definition: PxConstraintDesc.h:435
PxReal linear1
multiplier for inverse mass of body1
Definition: PxConstraintDesc.h:200
PX_CUDA_CALLABLE Px1DConstraintFlag()
Definition: PxConstraintDesc.h:69
This class connects a custom constraint to the SDK.
Definition: PxConstraintDesc.h:352
PxVec3 angular1
angular component of velocity jacobian in world space
Definition: PxConstraintDesc.h:150