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_SOLVER_DEFS_H
00031 #define PX_SOLVER_DEFS_H
00032
00033
00034 #include "PxPhysXConfig.h"
00035 #include "foundation/PxVec3.h"
00036 #include "foundation/PxMat33.h"
00037 #include "foundation/PxTransform.h"
00038 #include "PxConstraintDesc.h"
00039 #include "geomutils/GuContactPoint.h"
00040
00041 #if PX_VC
00042 #pragma warning(push)
00043 #pragma warning(disable : 4324) // structure was padded due to alignment
00044 #endif
00045
00046 #if !PX_DOXYGEN
00047 namespace physx
00048 {
00049 #endif
00050
00051 namespace Dy
00052 {
00053
00054 class ArticulationV;
00055 }
00056
00057 namespace Sc
00058 {
00059 class ShapeInteraction;
00060 }
00061
00062 struct PxSolverBody
00063 {
00064 PX_ALIGN(16, PxVec3) linearVelocity;
00065 PxU16 maxSolverNormalProgress;
00066 PxU16 maxSolverFrictionProgress;
00067
00068 PxVec3 angularState;
00069
00070 PxU32 solverProgress;
00071
00072 PxSolverBody() : linearVelocity(0.f), maxSolverNormalProgress(0), maxSolverFrictionProgress(0), angularState(0), solverProgress(0)
00073 {
00074 }
00075 };
00076
00077 PX_COMPILE_TIME_ASSERT(sizeof(PxSolverBody) == 32);
00078
00079 struct PxSolverBodyData
00080 {
00081 PX_ALIGN(16, PxVec3 linearVelocity);
00082 PxReal invMass;
00083 PxVec3 angularVelocity;
00084 PxReal reportThreshold;
00085 PxMat33 sqrtInvInertia;
00086 PxReal penBiasClamp;
00087 PxU32 nodeIndex;
00088 PxReal maxContactImpulse;
00089 PxTransform body2World;
00090 PxU16 lockFlags;
00091 PxU16 hasSurfaceVelocity;
00092
00093 PX_FORCE_INLINE PxReal projectVelocity(const PxVec3& lin, const PxVec3& ang) const
00094 {
00095 return linearVelocity.dot(lin) + angularVelocity.dot(ang);
00096 }
00097 };
00098
00099
00100
00101
00102
00103 struct PxConstraintBatchHeader
00104 {
00105 PxU32 mStartIndex;
00106 PxU16 mStride;
00107 PxU16 mConstraintType;
00108 };
00109
00110
00111 struct PxSolverConstraintDesc
00112 {
00113 static const PxU16 NO_LINK = 0xffff;
00114
00115 enum ConstraintType
00116 {
00117 eCONTACT_CONSTRAINT,
00118 eJOINT_CONSTRAINT
00119 };
00120
00121 union
00122 {
00123 PxSolverBody* bodyA;
00124 Dy::ArticulationV* articulationA;
00125 };
00126
00127 union
00128 {
00129 PxSolverBody* bodyB;
00130 Dy::ArticulationV* articulationB;
00131 };
00132 PxU16 linkIndexA;
00133 PxU16 linkIndexB;
00134 union
00135 {
00136 PxU16 articulationALength;
00137 PxU32 bodyADataIndex;
00138 };
00139
00140 union
00141 {
00142 PxU16 articulationBLength;
00143 PxU32 bodyBDataIndex;
00144 };
00145
00146 PxU16 writeBackLengthOver4;
00147 PxU16 constraintLengthOver16;
00148
00149 PxU8* constraint;
00150 void* writeBack;
00151 };
00152
00153 struct PxSolverConstraintPrepDescBase
00154 {
00155 enum BodyState
00156 {
00157 eDYNAMIC_BODY = 1 << 0,
00158 eSTATIC_BODY = 1 << 1,
00159 eKINEMATIC_BODY = 1 << 2,
00160 eARTICULATION = 1 << 3
00161 };
00162
00163 PxConstraintInvMassScale mInvMassScales;
00164
00165 PxSolverConstraintDesc* desc;
00166
00167 const PxSolverBody* body0;
00168 const PxSolverBody* body1;
00169
00170 const PxSolverBodyData* data0;
00171 const PxSolverBodyData* data1;
00172
00173 PxTransform bodyFrame0;
00174 PxTransform bodyFrame1;
00175
00176 BodyState bodyState0;
00177 BodyState bodyState1;
00178
00179 };
00180
00181 struct PxSolverConstraintPrepDesc : public PxSolverConstraintPrepDescBase
00182 {
00183 PX_ALIGN(16, Px1DConstraint* rows);
00184 PxU32 numRows;
00185
00186 PxReal linBreakForce, angBreakForce;
00187 PxReal minResponseThreshold;
00188 void* writeback;
00189 bool disablePreprocessing;
00190 bool improvedSlerp;
00191 bool driveLimitsAreForces;
00192 bool extendedLimits;
00193
00194 PxVec3 body0WorldOffset;
00195 };
00196
00197
00198 struct PxSolverContactDesc : public PxSolverConstraintPrepDescBase
00199 {
00200
00201 PX_ALIGN(16, Sc::ShapeInteraction* shapeInteraction);
00202 Gu::ContactPoint* contacts;
00203 PxU32 numContacts;
00204
00205 bool hasMaxImpulse;
00206 bool disableStrongFriction;
00207 bool hasForceThresholds;
00208
00209 PxReal restDistance;
00210 PxReal maxCCDSeparation;
00211
00212 PxU8* frictionPtr;
00213 PxU8 frictionCount;
00214
00215 PxReal* contactForces;
00216
00217 PxU32 startFrictionPatchIndex;
00218 PxU32 numFrictionPatches;
00219
00220 PxU32 startContactPatchIndex;
00221 PxU16 numContactPatches;
00222 PxU16 axisConstraintCount;
00223
00224 PxU8 pad[16 - sizeof(void*)];
00225 };
00226
00227 class PxConstraintAllocator
00228 {
00229 public:
00235 virtual PxU8* reserveConstraintData(const PxU32 byteSize) = 0;
00242 virtual PxU8* reserveFrictionData(const PxU32 byteSize) = 0;
00243
00244 virtual ~PxConstraintAllocator() {}
00245 };
00246
00247 #if !PX_DOXYGEN
00248 }
00249 #endif
00250
00251 #if PX_VC
00252 #pragma warning(pop)
00253 #endif
00254
00255 #endif
00256