00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef PX_PHYSICS_NX_CONSTRAINTDESC
00031 #define PX_PHYSICS_NX_CONSTRAINTDESC
00032
00037 #include "PxPhysXConfig.h"
00038 #include "foundation/PxFlags.h"
00039 #include "foundation/PxVec3.h"
00040 #include "common/PxBase.h"
00041
00042 #if !PX_DOXYGEN
00043 namespace physx { namespace pvdsdk {
00044 #endif
00045 class PvdDataStream;
00046 #if !PX_DOXYGEN
00047 }}
00048 #endif
00049
00050 #if !PX_DOXYGEN
00051 namespace physx
00052 {
00053 #endif
00054
00055 class PxConstraintConnector;
00056 class PxRigidActor;
00057 class PxScene;
00058 class PxConstraintConnector;
00059 class PxRenderBuffer;
00060 class PxDeletionListener;
00061
00067 struct Px1DConstraintFlag
00068 {
00069 PX_CUDA_CALLABLE Px1DConstraintFlag(){}
00070
00071 enum Type
00072 {
00073 eSPRING = 1<<0,
00074 eACCELERATION_SPRING = 1<<1,
00075 eRESTITUTION = 1<<2,
00076 eKEEPBIAS = 1<<3,
00077 eOUTPUT_FORCE = 1<<4,
00078 eHAS_DRIVE_LIMIT = 1<<5,
00079 eANGULAR_CONSTRAINT = 1 << 6,
00080 eDRIVE_ROW = 1 << 7
00081 };
00082 };
00083
00084 typedef PxFlags<Px1DConstraintFlag::Type, PxU16> Px1DConstraintFlags;
00085 PX_FLAGS_OPERATORS(Px1DConstraintFlag::Type, PxU16)
00086
00087
00090 struct PxConstraintSolveHint
00091 {
00092 enum Enum
00093 {
00094 eNONE = 0,
00095 eACCELERATION1 = 256,
00096 eSLERP_SPRING = 258,
00097 eACCELERATION2 = 512,
00098 eACCELERATION3 = 768,
00099 eROTATIONAL_EQUALITY = 1024,
00100 eROTATIONAL_INEQUALITY = 1025,
00101 eEQUALITY = 2048,
00102 eINEQUALITY = 2049
00103 };
00104 };
00105
00140 PX_ALIGN_PREFIX(16)
00141 struct Px1DConstraint
00142 {
00143 PxVec3 linear0;
00144 PxReal geometricError;
00145 PxVec3 angular0;
00146 PxReal velocityTarget;
00147
00148 PxVec3 linear1;
00149 PxReal minImpulse;
00150 PxVec3 angular1;
00151 PxReal maxImpulse;
00152
00153 union
00154 {
00155 struct SpringModifiers
00156 {
00157 PxReal stiffness;
00158 PxReal damping;
00159 } spring;
00160 struct RestitutionModifiers
00161 {
00162 PxReal restitution;
00163 PxReal velocityThreshold;
00164 } bounce;
00165 } mods;
00166
00167 PxReal forInternalUse;
00168 PxU16 flags;
00169 PxU16 solveHint;
00170 }
00171 PX_ALIGN_SUFFIX(16);
00172
00173
00179 struct PxConstraintVisualizationFlag
00180 {
00181 enum Enum
00182 {
00183 eLOCAL_FRAMES = 1,
00184 eLIMITS = 2
00185 };
00186 };
00187
00188 PX_ALIGN_PREFIX(16)
00189 struct PxConstraintInvMassScale
00190 {
00191
00192
00193
00194
00195
00196
00197
00198 PxReal linear0;
00199 PxReal angular0;
00200 PxReal linear1;
00201 PxReal angular1;
00202
00203 PX_CUDA_CALLABLE PX_FORCE_INLINE PxConstraintInvMassScale(){}
00204 PX_CUDA_CALLABLE PX_FORCE_INLINE PxConstraintInvMassScale(PxReal lin0, PxReal ang0, PxReal lin1, PxReal ang1) : linear0(lin0), angular0(ang0), linear1(lin1), angular1(ang1){}
00205 }
00206 PX_ALIGN_SUFFIX(16);
00207
00227 typedef PxU32 (*PxConstraintSolverPrep)(Px1DConstraint* constraints,
00228 PxVec3& bodyAWorldOffset,
00229 PxU32 maxConstraints,
00230 PxConstraintInvMassScale& invMassScale,
00231 const void* constantBlock,
00232 const PxTransform& bodyAToWorld,
00233 const PxTransform& bodyBToWorld,
00234 bool useExtendedLimits,
00235 PxVec3& cAtW,
00236 PxVec3& cBtW);
00237
00248 typedef void (*PxConstraintProject)(const void* constantBlock,
00249 PxTransform& bodyAToWorld,
00250 PxTransform& bodyBToWorld,
00251 bool projectToA);
00252
00256 class PxConstraintVisualizer
00257 {
00258 protected:
00259 virtual ~PxConstraintVisualizer(){}
00260 public:
00266 virtual void visualizeJointFrames(const PxTransform& parent, const PxTransform& child) = 0;
00267
00275 virtual void visualizeLinearLimit(const PxTransform& t0, const PxTransform& t1, PxReal value, bool active) = 0;
00276
00284 virtual void visualizeAngularLimit(const PxTransform& t0, PxReal lower, PxReal upper, bool active) = 0;
00285
00293 virtual void visualizeLimitCone(const PxTransform& t, PxReal tanQSwingY, PxReal tanQSwingZ, bool active) = 0;
00294
00301 virtual void visualizeDoubleCone(const PxTransform& t, PxReal angle, bool active) = 0;
00302
00309 virtual void visualizeLine(const PxVec3& p0, const PxVec3& p1, PxU32 color) = 0;
00310 };
00311
00324 typedef void (*PxConstraintVisualize)(PxConstraintVisualizer& visualizer,
00325 const void* constantBlock,
00326 const PxTransform& body0Transform,
00327 const PxTransform& body1Transform,
00328 PxU32 flags);
00329
00330
00331 struct PxPvdUpdateType
00332 {
00333 enum Enum
00334 {
00335 CREATE_INSTANCE,
00336 RELEASE_INSTANCE,
00337 UPDATE_ALL_PROPERTIES,
00338 UPDATE_SIM_PROPERTIES
00339 };
00340 };
00341
00351 class PxConstraintConnector
00352 {
00353 public:
00358 virtual void* prepareData() = 0;
00359
00363 virtual bool updatePvdProperties(physx::pvdsdk::PvdDataStream& pvdConnection,
00364 const PxConstraint* c,
00365 PxPvdUpdateType::Enum updateType) const = 0;
00366
00377 virtual void onConstraintRelease() = 0;
00378
00385 virtual void onComShift(PxU32 actor) = 0;
00386
00398 virtual void onOriginShift(const PxVec3& shift) = 0;
00399
00412 virtual void* getExternalReference(PxU32& typeID) = 0;
00413
00419 virtual PxBase* getSerializable() = 0;
00420
00424 virtual PxConstraintSolverPrep getPrep() const = 0;
00425
00429 virtual const void* getConstantBlock() const = 0;
00430
00434 virtual ~PxConstraintConnector() {}
00435 };
00436
00437 #if !PX_DOXYGEN
00438 }
00439 #endif
00440
00442 #endif