00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _ODE_COMMON_H_
00024 #define _ODE_COMMON_H_
00025 #include <ode/config.h>
00026 #include <ode/error.h>
00027 #include <math.h>
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #define EFFICIENT_ALIGNMENT 16
00046
00047
00048
00049
00050
00051
00052
00053
00054 #ifndef M_PI
00055 #define M_PI REAL(3.1415926535897932384626433832795029)
00056 #endif
00057 #ifndef M_SQRT1_2
00058 #define M_SQRT1_2 REAL(0.7071067811865475244008443621048490)
00059 #endif
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #ifndef dNODEBUG
00073 #ifdef __GNUC__
00074 #define dIASSERT(a) if (!(a)) dDebug (d_ERR_IASSERT, \
00075 "assertion \"" #a "\" failed in %s() [%s]",__FUNCTION__,__FILE__);
00076 #define dUASSERT(a,msg) if (!(a)) dDebug (d_ERR_UASSERT, \
00077 msg " in %s()", __FUNCTION__);
00078 #define dDEBUGMSG(msg) dMessage (d_ERR_UASSERT, \
00079 msg " in %s() File %s Line %d", __FUNCTION__, __FILE__,__LINE__);
00080 #else
00081 #define dIASSERT(a) if (!(a)) dDebug (d_ERR_IASSERT, \
00082 "assertion \"" #a "\" failed in %s:%d",__FILE__,__LINE__);
00083 #define dUASSERT(a,msg) if (!(a)) dDebug (d_ERR_UASSERT, \
00084 msg " (%s:%d)", __FILE__,__LINE__);
00085 #define dDEBUGMSG(msg) dMessage (d_ERR_UASSERT, \
00086 msg " (%s:%d)", __FILE__,__LINE__);
00087 #endif
00088 #else
00089 #define dIASSERT(a) ;
00090 #define dUASSERT(a,msg) ;
00091 #define dDEBUGMSG(msg) ;
00092 #endif
00093 #define dAASSERT(a) dUASSERT(a,"Bad argument(s)")
00094
00095
00096 #define dVARIABLEUSED(a) ((void)a)
00097
00098
00099
00100 #if defined(dSINGLE)
00101 typedef float dReal;
00102 #ifdef dDOUBLE
00103 #error You can only #define dSINGLE or dDOUBLE, not both.
00104 #endif // dDOUBLE
00105 #elif defined(dDOUBLE)
00106 typedef double dReal;
00107 #else
00108 #error You must #define dSINGLE or dDOUBLE
00109 #endif
00110
00111
00112 #if dTRIMESH_ENABLED
00113 #if dTRIMESH_OPCODE && dTRIMESH_GIMPACT
00114 #error You can only #define dTRIMESH_OPCODE or dTRIMESH_GIMPACT, not both.
00115 #endif
00116 #endif // dTRIMESH_ENABLED
00117
00118
00119
00120
00121 #define dPAD(a) (((a) > 1) ? ((((a)-1)|3)+1) : (a))
00122
00123
00124 typedef dReal dVector3[4];
00125 typedef dReal dVector4[4];
00126 typedef dReal dMatrix3[4*3];
00127 typedef dReal dMatrix4[4*4];
00128 typedef dReal dMatrix6[8*6];
00129 typedef dReal dQuaternion[4];
00130
00131
00132
00133
00134 #if defined(dSINGLE)
00135
00136 #define REAL(x) (x ## f)
00137 #define dRecip(x) ((1.0f/(x)))
00138 #define dSqrt(x) (sqrtf(x))
00139 #define dRecipSqrt(x) ((1.0f/sqrtf(x)))
00140 #define dSin(x) (sinf(x))
00141 #define dCos(x) (cosf(x))
00142 #define dFabs(x) (fabsf(x))
00143 #define dAtan2(y,x) (atan2f(y,x))
00144 #define dFMod(a,b) (fmodf(a,b))
00145 #define dFloor(x) floorf(x)
00146
00147 #ifdef HAVE___ISNANF
00148 #define dIsNan(x) (__isnanf(x))
00149 #elif defined(HAVE__ISNANF)
00150 #define dIsNan(x) (_isnanf(x))
00151 #elif defined(HAVE_ISNANF)
00152 #define dIsNan(x) (isnanf(x))
00153 #else
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 #define dIsNan(x) (_isnan(x))
00164 #endif
00165
00166 #define dCopySign(a,b) ((dReal)copysignf(a,b))
00167
00168 #elif defined(dDOUBLE)
00169
00170 #define REAL(x) (x)
00171 #define dRecip(x) (1.0/(x))
00172 #define dSqrt(x) sqrt(x)
00173 #define dRecipSqrt(x) (1.0/sqrt(x))
00174 #define dSin(x) sin(x)
00175 #define dCos(x) cos(x)
00176 #define dFabs(x) fabs(x)
00177 #define dAtan2(y,x) atan2((y),(x))
00178 #define dFMod(a,b) (fmod((a),(b)))
00179 #define dFloor(x) floor(x)
00180
00181 #ifdef HAVE___ISNAN
00182 #define dIsNan(x) (__isnan(x))
00183 #elif defined(HAVE__ISNAN)
00184 #define dIsNan(x) (_isnan(x))
00185 #elif defined(HAVE_ISNAN)
00186 #define dIsNan(x) (isnan(x))
00187 #else
00188 #define dIsNan(x) (_isnan(x))
00189 #endif
00190
00191 #define dCopySign(a,b) (copysign((a),(b)))
00192
00193 #else
00194 #error You must #define dSINGLE or dDOUBLE
00195 #endif
00196
00197
00198
00199
00200
00201
00202
00203 #define dEFFICIENT_SIZE(x) ((((x)-1)|(EFFICIENT_ALIGNMENT-1))+1)
00204
00205
00206
00207
00208
00209
00210 #define dALLOCA16(n) \
00211 ((char*)dEFFICIENT_SIZE(((size_t)(alloca((n)+(EFFICIENT_ALIGNMENT-1))))))
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221 #ifdef dUSE_MALLOC_FOR_ALLOCA
00222 enum {
00223 d_MEMORY_OK = 0,
00224 d_MEMORY_OUT_OF_MEMORY
00225 };
00226
00227 #endif
00228
00229
00230
00231
00232
00233 struct dxWorld;
00234 struct dxSpace;
00235 struct dxBody;
00236 struct dxGeom;
00237 struct dxJoint;
00238 struct dxJointNode;
00239 struct dxJointGroup;
00240
00241 typedef struct dxWorld *dWorldID;
00242 typedef struct dxSpace *dSpaceID;
00243 typedef struct dxBody *dBodyID;
00244 typedef struct dxGeom *dGeomID;
00245 typedef struct dxJoint *dJointID;
00246 typedef struct dxJointGroup *dJointGroupID;
00247
00248
00249
00250
00251 enum {
00252 d_ERR_UNKNOWN = 0,
00253 d_ERR_IASSERT,
00254 d_ERR_UASSERT,
00255 d_ERR_LCP
00256 };
00257
00258
00259
00260
00261 enum {
00262 dJointTypeNone = 0,
00263 dJointTypeBall,
00264 dJointTypeHinge,
00265 dJointTypeSlider,
00266 dJointTypeContact,
00267 dJointTypeUniversal,
00268 dJointTypeHinge2,
00269 dJointTypeFixed,
00270 dJointTypeNull,
00271 dJointTypeAMotor,
00272 dJointTypeLMotor,
00273 dJointTypePlane2D,
00274 dJointTypePR
00275 };
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311 #define D_ALL_PARAM_NAMES(start) \
00312 \
00313 dParamLoStop = start, \
00314 dParamHiStop, \
00315 dParamVel, \
00316 dParamFMax, \
00317 dParamFudgeFactor, \
00318 dParamBounce, \
00319 dParamCFM, \
00320 dParamStopERP, \
00321 dParamStopCFM, \
00322 \
00323 dParamSuspensionERP, \
00324 dParamSuspensionCFM, \
00325 dParamERP, \
00326
00327 #define D_ALL_PARAM_NAMES_X(start,x) \
00328 \
00329 dParamLoStop ## x = start, \
00330 dParamHiStop ## x, \
00331 dParamVel ## x, \
00332 dParamFMax ## x, \
00333 dParamFudgeFactor ## x, \
00334 dParamBounce ## x, \
00335 dParamCFM ## x, \
00336 dParamStopERP ## x, \
00337 dParamStopCFM ## x, \
00338 \
00339 dParamSuspensionERP ## x, \
00340 dParamSuspensionCFM ## x, \
00341 dParamERP ## x,
00342
00343 enum {
00344 D_ALL_PARAM_NAMES(0)
00345 D_ALL_PARAM_NAMES_X(0x100,2)
00346 D_ALL_PARAM_NAMES_X(0x200,3)
00347
00348
00349
00350
00351 dParamGroup=0x100
00352 };
00353
00354
00355
00356
00357 enum{
00358 dAMotorUser = 0,
00359 dAMotorEuler = 1
00360 };
00361
00362
00363
00364
00365 typedef struct dJointFeedback {
00366 dVector3 f1;
00367 dVector3 t1;
00368 dVector3 f2;
00369 dVector3 t2;
00370 } dJointFeedback;
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380 void dGeomMoved (dGeomID);
00381 dGeomID dGeomGetBodyNext (dGeomID);
00382
00383
00384 #ifdef __cplusplus
00385 }
00386 #endif
00387
00388 #endif