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/odeconfig.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 #ifndef M_PI
00043 #define M_PI REAL(3.1415926535897932384626433832795029)
00044 #endif
00045 #ifndef M_SQRT1_2
00046 #define M_SQRT1_2 REAL(0.7071067811865475244008443621048490)
00047 #endif
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #ifndef dNODEBUG
00061 #ifdef __GNUC__
00062 #define dIASSERT(a) if (!(a)) dDebug (d_ERR_IASSERT, \
00063 "assertion \"" #a "\" failed in %s() [%s]",__FUNCTION__,__FILE__);
00064 #define dUASSERT(a,msg) if (!(a)) dDebug (d_ERR_UASSERT, \
00065 msg " in %s()", __FUNCTION__);
00066 #define dDEBUGMSG(msg) dMessage (d_ERR_UASSERT, \
00067 msg " in %s() File %s Line %d", __FUNCTION__, __FILE__,__LINE__);
00068 #else
00069 #define dIASSERT(a) if (!(a)) dDebug (d_ERR_IASSERT, \
00070 "assertion \"" #a "\" failed in %s:%d",__FILE__,__LINE__);
00071 #define dUASSERT(a,msg) if (!(a)) dDebug (d_ERR_UASSERT, \
00072 msg " (%s:%d)", __FILE__,__LINE__);
00073 #define dDEBUGMSG(msg) dMessage (d_ERR_UASSERT, \
00074 msg " (%s:%d)", __FILE__,__LINE__);
00075 #endif
00076 #else
00077 #define dIASSERT(a) ;
00078 #define dUASSERT(a,msg) ;
00079 #define dDEBUGMSG(msg) ;
00080 #endif
00081 #define dAASSERT(a) dUASSERT(a,"Bad argument(s)")
00082
00083
00084 #define dVARIABLEUSED(a) ((void)a)
00085
00086
00087
00088 #if defined(dSINGLE)
00089 typedef float dReal;
00090 #ifdef dDOUBLE
00091 #error You can only #define dSINGLE or dDOUBLE, not both.
00092 #endif // dDOUBLE
00093 #elif defined(dDOUBLE)
00094 typedef double dReal;
00095 #else
00096 #error You must #define dSINGLE or dDOUBLE
00097 #endif
00098
00099
00100 #if dTRIMESH_ENABLED
00101 #if dTRIMESH_OPCODE && dTRIMESH_GIMPACT
00102 #error You can only #define dTRIMESH_OPCODE or dTRIMESH_GIMPACT, not both.
00103 #endif
00104 #endif // dTRIMESH_ENABLED
00105
00106
00107
00108 #if dTRIMESH_16BIT_INDICES
00109 #if dTRIMESH_GIMPACT
00110 typedef uint32 dTriIndex;
00111 #else // dTRIMESH_GIMPACT
00112 typedef uint16 dTriIndex;
00113 #endif // dTRIMESH_GIMPACT
00114 #else // dTRIMESH_16BIT_INDICES
00115 typedef uint32 dTriIndex;
00116 #endif // dTRIMESH_16BIT_INDICES
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 struct dxWorld;
00200 struct dxSpace;
00201 struct dxBody;
00202 struct dxGeom;
00203 struct dxJoint;
00204 struct dxJointNode;
00205 struct dxJointGroup;
00206
00207 typedef struct dxWorld *dWorldID;
00208 typedef struct dxSpace *dSpaceID;
00209 typedef struct dxBody *dBodyID;
00210 typedef struct dxGeom *dGeomID;
00211 typedef struct dxJoint *dJointID;
00212 typedef struct dxJointGroup *dJointGroupID;
00213
00214
00215
00216
00217 enum {
00218 d_ERR_UNKNOWN = 0,
00219 d_ERR_IASSERT,
00220 d_ERR_UASSERT,
00221 d_ERR_LCP
00222 };
00223
00224
00225
00226
00227 typedef enum {
00228 dJointTypeNone = 0,
00229 dJointTypeBall,
00230 dJointTypeHinge,
00231 dJointTypeSlider,
00232 dJointTypeContact,
00233 dJointTypeUniversal,
00234 dJointTypeHinge2,
00235 dJointTypeFixed,
00236 dJointTypeNull,
00237 dJointTypeAMotor,
00238 dJointTypeLMotor,
00239 dJointTypePlane2D,
00240 dJointTypePR,
00241 dJointTypePU,
00242 dJointTypePiston
00243 } dJointType;
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279 #define D_ALL_PARAM_NAMES(start) \
00280 \
00281 dParamLoStop = start, \
00282 dParamHiStop, \
00283 dParamVel, \
00284 dParamFMax, \
00285 dParamFudgeFactor, \
00286 dParamBounce, \
00287 dParamCFM, \
00288 dParamStopERP, \
00289 dParamStopCFM, \
00290 \
00291 dParamSuspensionERP, \
00292 dParamSuspensionCFM, \
00293 dParamERP, \
00294
00303 #define D_ALL_PARAM_NAMES_X(start,x) \
00304 dParamGroup ## x = start, \
00305 \
00306 dParamLoStop ## x = start, \
00307 dParamHiStop ## x, \
00308 dParamVel ## x, \
00309 dParamFMax ## x, \
00310 dParamFudgeFactor ## x, \
00311 dParamBounce ## x, \
00312 dParamCFM ## x, \
00313 dParamStopERP ## x, \
00314 dParamStopCFM ## x, \
00315 \
00316 dParamSuspensionERP ## x, \
00317 dParamSuspensionCFM ## x, \
00318 dParamERP ## x,
00319
00320 enum {
00321 D_ALL_PARAM_NAMES(0)
00322 dParamsInGroup,
00323 D_ALL_PARAM_NAMES_X(0x000,1)
00324 D_ALL_PARAM_NAMES_X(0x100,2)
00325 D_ALL_PARAM_NAMES_X(0x200,3)
00326
00327
00328
00329
00330 dParamGroup=0x100
00331 };
00332
00333
00334
00335
00336 enum {
00337 dAMotorUser = 0,
00338 dAMotorEuler = 1
00339 };
00340
00341
00342
00343
00344 typedef struct dJointFeedback {
00345 dVector3 f1;
00346 dVector3 t1;
00347 dVector3 f2;
00348 dVector3 t2;
00349 } dJointFeedback;
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359 void dGeomMoved (dGeomID);
00360 dGeomID dGeomGetBodyNext (dGeomID);
00361
00380 ODE_API const char* dGetConfiguration (void);
00381
00390 ODE_API int dCheckConfiguration( const char* token );
00391
00392 #ifdef __cplusplus
00393 }
00394 #endif
00395
00396 #endif