PxConstraint.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_PHYSICS_NX_CONSTRAINT
31 #define PX_PHYSICS_NX_CONSTRAINT
32 
37 #include "PxPhysXConfig.h"
38 #include "PxConstraintDesc.h"
39 #include "common/PxBase.h"
40 
41 #if !PX_DOXYGEN
42 namespace physx
43 {
44 #endif
45 
46 class PxRigidActor;
47 class PxScene;
49 
63 {
64  enum Enum
65  {
66  eBROKEN = 1<<0,
67  ePROJECT_TO_ACTOR0 = 1<<1,
68  ePROJECT_TO_ACTOR1 = 1<<2,
69  ePROJECTION = ePROJECT_TO_ACTOR0 | ePROJECT_TO_ACTOR1,
70  eCOLLISION_ENABLED = 1<<3,
71  eVISUALIZATION = 1<<4,
72  eDRIVE_LIMITS_ARE_FORCES = 1<<5,
73  eIMPROVED_SLERP = 1<<7,
74  eDISABLE_PREPROCESSING = 1<<8,
75  eENABLE_EXTENDED_LIMITS = 1<<9,
76  eGPU_COMPATIBLE = 1<<10
77  };
78 };
79 
86 PX_FLAGS_OPERATORS(PxConstraintFlag::Enum, PxU16)
87 
89 {
90  enum
91  {
92  eMAX_SOLVERPRPEP_DATASIZE=400
93  };
94 
99 };
100 
101 
108 class PxConstraint : public PxBase
109 {
110 public:
111 
119  virtual void release() = 0;
120 
128  virtual PxScene* getScene() const = 0;
129 
138  virtual void getActors(PxRigidActor*& actor0, PxRigidActor*& actor1) const = 0;
139 
148  virtual void setActors(PxRigidActor* actor0, PxRigidActor* actor1) = 0;
149 
153  virtual void markDirty() = 0;
154 
164  virtual void setFlags(PxConstraintFlags flags) = 0;
165 
172  virtual PxConstraintFlags getFlags() const = 0;
173 
182  virtual void setFlag(PxConstraintFlag::Enum flag, bool value) = 0;
183 
190  virtual void getForce(PxVec3& linear, PxVec3& angular) const = 0;
191 
201  virtual bool isValid() const = 0;
202 
211  virtual void setBreakForce(PxReal linear, PxReal angular) = 0;
212 
219  virtual void getBreakForce(PxReal& linear, PxReal& angular) const = 0;
220 
233  virtual void setMinResponseThreshold(PxReal threshold) = 0;
234 
240  virtual PxReal getMinResponseThreshold() const = 0;
241 
252  virtual void* getExternalReference(PxU32& typeID) = 0;
253 
262  virtual void setConstraintFunctions(PxConstraintConnector& connector,
263  const PxConstraintShaderTable& shaders) = 0;
264 
265  virtual const char* getConcreteTypeName() const { return "PxConstraint"; }
266 
267 protected:
268  PX_INLINE PxConstraint(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
269  PX_INLINE PxConstraint(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
270  virtual ~PxConstraint() {}
271  virtual bool isKindOf(const char* name) const { return !::strcmp("PxConstraint", name) || PxBase::isKindOf(name); }
272 
273 };
274 
275 #if !PX_DOXYGEN
276 } // namespace physx
277 #endif
278 
280 #endif
Definition: GuContactBuffer.h:37
A scene is a collection of bodies and constraints which can interact.
Definition: PxScene.h:169
PxConstraintSolverPrep solverPrep
solver constraint generation function
Definition: PxConstraint.h:95
virtual const char * getConcreteTypeName() const
Returns string name of dynamic type.
Definition: PxConstraint.h:265
a table of function pointers for a constraint
Definition: PxConstraint.h:62
PxConstraintProject project
constraint projection function
Definition: PxConstraint.h:96
float PxReal
Definition: PxSimpleTypes.h:78
virtual bool isKindOf(const char *superClass) const
Returns whether a given type name matches with the type of this instance.
Definition: PxBase.h:178
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition: PxConstraint.h:271
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
PX_INLINE PxConstraint(PxType concreteType, PxBaseFlags baseFlags)
Definition: PxConstraint.h:268
PxU16 PxType
Definition: PxBase.h:49
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition: PxRigidActor.h:58
PxFlags< PxConstraintFlag::Enum, PxU16 > PxConstraintFlags
constraint flags
Definition: PxConstraint.h:85
virtual ~PxConstraint()
Definition: PxConstraint.h:270
PxConstraintFlag::Enum flag
gpu constraint
Definition: PxConstraint.h:98
PxU16 flags
a set of Px1DConstraintFlags
Definition: PxConstraintDesc.h:110
A plugin class for implementing constraints.
Definition: PxConstraint.h:108
Enum
Definition: PxConstraint.h:64
void(* PxConstraintProject)(const void *constantBlock, PxTransform &bodyAToWorld, PxTransform &bodyBToWorld, bool projectToA)
Definition: PxConstraintDesc.h:249
void(* PxConstraintVisualize)(PxConstraintVisualizer &visualizer, const void *constantBlock, const PxTransform &body0Transform, const PxTransform &body1Transform, PxU32 flags)
Definition: PxConstraintDesc.h:325
Definition: PxConstraint.h:88
PxConstraintVisualize visualize
constraint visualization function
Definition: PxConstraint.h:97
Container for bitfield flag variables associated with a specific enum type.
Definition: PxFlags.h:73
uint16_t PxU16
Definition: PxSimpleTypes.h:73
uint32_t PxU32
Definition: Px.h:48
PX_INLINE PxConstraint(PxBaseFlags baseFlags)
Definition: PxConstraint.h:269
Base class for objects that can be members of a PxCollection.
Definition: PxBase.h:73
#define PX_INLINE
Definition: PxPreprocessor.h:349
3 Element vector class.
Definition: PxVec3.h:49
This class connects a custom constraint to the SDK.
Definition: PxConstraintDesc.h:352