RavEngine
Loading...
Searching...
No Matches
PxConstraint.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_H
30#define PX_CONSTRAINT_H
31
36#include "PxPhysXConfig.h"
37#include "PxConstraintDesc.h"
38#include "common/PxBase.h"
39
40#if !PX_DOXYGEN
41namespace physx
42{
43#endif
44
45class PxRigidActor;
46class PxScene;
47class PxConstraintConnector;
48
73
79PX_FLAGS_OPERATORS(PxConstraintFlag::Enum, PxU16)
80
81
93
99class PxConstraint : public PxBase
100{
101public:
102
110 virtual void release() = 0;
111
119 virtual PxScene* getScene() const = 0;
120
129 virtual void getActors(PxRigidActor*& actor0, PxRigidActor*& actor1) const = 0;
130
139 virtual void setActors(PxRigidActor* actor0, PxRigidActor* actor1) = 0;
140
144 virtual void markDirty() = 0;
145
152 virtual PxConstraintFlags getFlags() const = 0;
153
163 virtual void setFlags(PxConstraintFlags flags) = 0;
164
173 virtual void setFlag(PxConstraintFlag::Enum flag, bool value) = 0;
174
184 virtual void getForce(PxVec3& linear, PxVec3& angular) const = 0;
185
195 virtual bool isValid() const = 0;
196
205 virtual void setBreakForce(PxReal linear, PxReal angular) = 0;
206
213 virtual void getBreakForce(PxReal& linear, PxReal& angular) const = 0;
214
227 virtual void setMinResponseThreshold(PxReal threshold) = 0;
228
234 virtual PxReal getMinResponseThreshold() const = 0;
235
246 virtual void* getExternalReference(PxU32& typeID) = 0;
247
256 virtual void setConstraintFunctions(PxConstraintConnector& connector, const PxConstraintShaderTable& shaders) = 0;
257
258 virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxConstraint"; }
259
260 void* userData;
261
262protected:
263 PX_INLINE PxConstraint(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags), userData(NULL) {}
264 PX_INLINE PxConstraint(PxBaseFlags baseFlags) : PxBase(baseFlags), userData(NULL) {}
265 virtual ~PxConstraint() {}
266 virtual bool isKindOf(const char* name) const PX_OVERRIDE { return !::strcmp("PxConstraint", name) || PxBase::isKindOf(name); }
267};
268
269#if !PX_DOXYGEN
270} // namespace physx
271#endif
272
274#endif
Base class for objects that can be members of a PxCollection.
Definition PxBase.h:73
virtual bool isKindOf(const char *superClass) const
Returns whether a given type name matches with the type of this instance.
Definition PxBase.h:179
This class connects a custom constraint to the SDK.
Definition PxConstraintDesc.h:354
A plugin class for implementing constraints.
Definition PxConstraint.h:100
virtual void getBreakForce(PxReal &linear, PxReal &angular) const =0
Retrieve the constraint break force and torque thresholds.
virtual bool isValid() const =0
whether the constraint is valid.
virtual void setFlag(PxConstraintFlag::Enum flag, bool value)=0
Set a flag for this constraint.
virtual void setFlags(PxConstraintFlags flags)=0
Set the flags for this constraint.
void * userData
user can assign this to whatever, usually to create a 1:1 relationship with a user object.
Definition PxConstraint.h:260
virtual PxConstraintFlags getFlags() const =0
Retrieve the flags for this constraint.
virtual void setActors(PxRigidActor *actor0, PxRigidActor *actor1)=0
Sets the actors for this constraint.
virtual const char * getConcreteTypeName() const PX_OVERRIDE
Returns string name of dynamic type.
Definition PxConstraint.h:258
virtual void * getExternalReference(PxU32 &typeID)=0
Fetch external owner of the constraint.
virtual PxScene * getScene() const =0
Retrieves the scene which this constraint belongs to.
virtual void release()=0
Releases a PxConstraint instance.
virtual void setConstraintFunctions(PxConstraintConnector &connector, const PxConstraintShaderTable &shaders)=0
Set the constraint functions for this constraint.
virtual void setBreakForce(PxReal linear, PxReal angular)=0
Set the break force and torque thresholds for this constraint.
virtual void setMinResponseThreshold(PxReal threshold)=0
Set the minimum response threshold for a constraint row.
virtual void getForce(PxVec3 &linear, PxVec3 &angular) const =0
Retrieve the constraint force most recently applied to maintain this constraint.
virtual void markDirty()=0
Notify the scene that the constraint shader data has been updated by the application.
virtual PxReal getMinResponseThreshold() const =0
Retrieve the constraint break force and torque thresholds.
virtual bool isKindOf(const char *name) const PX_OVERRIDE
Returns whether a given type name matches with the type of this instance.
Definition PxConstraint.h:266
virtual void getActors(PxRigidActor *&actor0, PxRigidActor *&actor1) const =0
Retrieves the actors for this constraint.
Container for bitfield flag variables associated with a specific enum type.
Definition PxFlags.h:73
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
A scene is a collection of bodies and constraints which can interact.
Definition PxScene.h:178
3 Element vector class.
Definition PxVec3.h:50
#define PX_OVERRIDE
Definition PxPreprocessor.h:375
#define PX_INLINE
Definition PxPreprocessor.h:320
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
PxFlags< PxConstraintFlag::Enum, PxU16 > PxConstraintFlags
constraint flags
Definition PxConstraint.h:78
constraint flags
Definition PxConstraint.h:55
Enum
Definition PxConstraint.h:57
@ ePROJECTION
Definition PxConstraint.h:61
@ ePROJECT_TO_ACTOR1
Definition PxConstraint.h:60
@ eIMPROVED_SLERP
perform preprocessing for improved accuracy on D6 Slerp Drive (this flag will be removed in a future ...
Definition PxConstraint.h:65
@ eALWAYS_UPDATE
updates the constraint each frame
Definition PxConstraint.h:69
@ eENABLE_EXTENDED_LIMITS
enables extended limit ranges for angular limits (e.g., limit values > PxPi or < -PxPi)
Definition PxConstraint.h:67
@ eGPU_COMPATIBLE
the constraint type is supported by gpu dynamics
Definition PxConstraint.h:68
@ ePROJECT_TO_ACTOR0
Definition PxConstraint.h:59
@ eDISABLE_PREPROCESSING
suppress constraint preprocessing, intended for use with rowResponseThreshold. May result in worse so...
Definition PxConstraint.h:66
@ eVISUALIZATION
whether this constraint should be visualized, if constraint visualization is turned on
Definition PxConstraint.h:63
@ eBROKEN
whether the constraint is broken
Definition PxConstraint.h:58
@ eDISABLE_CONSTRAINT
disables the constraint. SolverPrep functions won't be called for this constraint.
Definition PxConstraint.h:70
@ eCOLLISION_ENABLED
whether contacts should be generated between the objects this constraint constrains
Definition PxConstraint.h:62
@ eDRIVE_LIMITS_ARE_FORCES
limits for drive strength are forces rather than impulses
Definition PxConstraint.h:64
a table of function pointers for a constraint
Definition PxConstraint.h:87
PxConstraintSolverPrep solverPrep
solver constraint generation function
Definition PxConstraint.h:88
PxConstraintProject project
Definition PxConstraint.h:89
PxConstraintFlag::Enum flag
constraint flags
Definition PxConstraint.h:91
PxConstraintVisualize visualize
constraint visualization function
Definition PxConstraint.h:90