collision.h   collision.h 
skipping to change at line 386 skipping to change at line 386
* the enabled state. * the enabled state.
* *
* @param geom the geom to query * @param geom the geom to query
* @returns Non-zero if the geom is enabled, zero otherwise. * @returns Non-zero if the geom is enabled, zero otherwise.
* @sa dGeomDisable * @sa dGeomDisable
* @sa dGeomIsEnabled * @sa dGeomIsEnabled
* @ingroup collide * @ingroup collide
*/ */
ODE_API int dGeomIsEnabled (dGeomID geom); ODE_API int dGeomIsEnabled (dGeomID geom);
enum
{
dGeomCommonControlClass = 0,
dGeomColliderControlClass = 1
};
enum
{
dGeomCommonAnyControlCode = 0,
dGeomColliderSetMergeSphereContactsControlCode = 1,
dGeomColliderGetMergeSphereContactsControlCode = 2
};
enum
{
dGeomColliderMergeContactsValue__Default = 0, // Used with Set... to
restore default value
dGeomColliderMergeContactsValue_None = 1,
dGeomColliderMergeContactsValue_Normals = 2,
dGeomColliderMergeContactsValue_Full = 3
};
/**
* @brief Execute low level control operation for geometry.
*
* The variable the dataSize points to must be initialized before the call.
* If the size does not match the one expected for the control class/code f
unction
* changes it to the size expected and returns failure. This implies the fu
nction
* can be called with NULL data and zero size to test if control class/code
is supported
* and obtain required data size for it.
*
* dGeomCommonAnyControlCode applies to any control class and returns succe
ss if
* at least one control code is available for the given class with given ge
om.
*
* Currently there are the folliwing control classes supported:
* @li dGeomColliderControlClass
*
* For dGeomColliderControlClass there are the following codes available:
* @li dGeomColliderSetMergeSphereContactsControlCode (arg of type int, dG
eomColliderMergeContactsValue_*)
* @li dGeomColliderGetMergeSphereContactsControlCode (arg of type int, dG
eomColliderMergeContactsValue_*)
*
* @param geom the geom to control
* @param controlClass the control class
* @param controlCode the control code for the class
* @param dataValue the control argument pointer
* @param dataSize the control argument size provided or expected
* @returns Boolean execution status
* @ingroup collide
*/
ODE_API int dGeomLowLevelControl (dGeomID geom, int controlClass, int contr
olCode, void *dataValue, int *dataSize);
/**
* @brief Get world position of a relative point on geom.
*
* Calling this function on a non-placeable geom results in the same point
being
* returned.
*
* @ingroup collide
* @param result will contain the result.
*/
ODE_API void dGeomGetRelPointPos
(
dGeomID geom, dReal px, dReal py, dReal pz,
dVector3 result
);
/**
* @brief takes a point in global coordinates and returns
* the point's position in geom-relative coordinates.
*
* Calling this function on a non-placeable geom results in the same point
being
* returned.
*
* @remarks
* This is the inverse of dGeomGetRelPointPos()
* @ingroup collide
* @param result will contain the result.
*/
ODE_API void dGeomGetPosRelPoint
(
dGeomID geom, dReal px, dReal py, dReal pz,
dVector3 result
);
/**
* @brief Convert from geom-local to world coordinates.
*
* Calling this function on a non-placeable geom results in the same vector
being
* returned.
*
* @ingroup collide
* @param result will contain the result.
*/
ODE_API void dGeomVectorToWorld
(
dGeomID geom, dReal px, dReal py, dReal pz,
dVector3 result
);
/**
* @brief Convert from world to geom-local coordinates.
*
* Calling this function on a non-placeable geom results in the same vector
being
* returned.
*
* @ingroup collide
* @param result will contain the result.
*/
ODE_API void dGeomVectorFromWorld
(
dGeomID geom, dReal px, dReal py, dReal pz,
dVector3 result
);
/* ************************************************************************ */ /* ************************************************************************ */
/* geom offset from body */ /* geom offset from body */
/** /**
* @brief Set the local offset position of a geom from its body. * @brief Set the local offset position of a geom from its body.
* *
* Sets the geom's positional offset in local coordinates. * Sets the geom's positional offset in local coordinates.
* After this call, the geom will be at a new position determined from the * After this call, the geom will be at a new position determined from the
* body's position and the offset. * body's position and the offset.
* The geom must be attached to a body. * The geom must be attached to a body.
 End of changes. 1 change blocks. 
0 lines changed or deleted 127 lines changed or added


 common.h   common.h 
skipping to change at line 33 skipping to change at line 33
#ifndef _ODE_COMMON_H_ #ifndef _ODE_COMMON_H_
#define _ODE_COMMON_H_ #define _ODE_COMMON_H_
#include <ode/odeconfig.h> #include <ode/odeconfig.h>
#include <ode/error.h> #include <ode/error.h>
#include <math.h> #include <math.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define PURE_INLINE static __inline
/* configuration stuff */ /* configuration stuff */
/* constants */ /* constants */
/* pi and 1/sqrt(2) are defined here if necessary because they don't get /* pi and 1/sqrt(2) are defined here if necessary because they don't get
* defined in <math.h> on some platforms (like MS-Windows) * defined in <math.h> on some platforms (like MS-Windows)
*/ */
#ifndef M_PI #ifndef M_PI
#define M_PI REAL(3.1415926535897932384626433832795029) #define M_PI REAL(3.1415926535897932384626433832795029)
skipping to change at line 58 skipping to change at line 60
/* debugging: /* debugging:
* IASSERT is an internal assertion, i.e. a consistency check. if it fai ls * IASSERT is an internal assertion, i.e. a consistency check. if it fai ls
* we want to know where. * we want to know where.
* UASSERT is a user assertion, i.e. if it fails a nice error message * UASSERT is a user assertion, i.e. if it fails a nice error message
* should be printed for the user. * should be printed for the user.
* AASSERT is an arguments assertion, i.e. if it fails "bad argument(s)" * AASSERT is an arguments assertion, i.e. if it fails "bad argument(s)"
* is printed. * is printed.
* DEBUGMSG just prints out a message * DEBUGMSG just prints out a message
*/ */
#ifndef dNODEBUG
# if defined(__STDC__) && __STDC_VERSION__ >= 199901L # if defined(__STDC__) && __STDC_VERSION__ >= 199901L
# define __FUNCTION__ __func__ # define __FUNCTION__ __func__
# endif # endif
#ifndef dNODEBUG
# ifdef __GNUC__ # ifdef __GNUC__
# define dIASSERT(a) if (!(a)) dDebug (d_ERR_IASSERT, \ # define dIASSERT(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \
"assertion \"" #a "\" failed in %s() [%s]",__FUNCTION__,__FILE__); "assertion \"" #a "\" failed in %s() [%s:%u]",__FUNCTION__,__FILE__,_
# define dUASSERT(a,msg) if (!(a)) dDebug (d_ERR_UASSERT, \ _LINE__); } }
msg " in %s()", __FUNCTION__); # define dUASSERT(a,msg) { if (!(a)) { dDebug (d_ERR_UASSERT, \
# define dDEBUGMSG(msg) dMessage (d_ERR_UASSERT, msg " in %s()", __FUNCTION__); } }
\ # define dDEBUGMSG(msg) { dMessage (d_ERR_UASSERT,
msg " in %s() File %s Line %d", __FUNCTION__, __FILE__,__LINE__); \
msg " in %s() [%s:%u]", __FUNCTION__,__FILE__,__LINE__); }
# else // not __GNUC__ # else // not __GNUC__
# define dIASSERT(a) if (!(a)) dDebug (d_ERR_IASSERT, \ # define dIASSERT(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \
"assertion \"" #a "\" failed in %s:%d",__FILE__,__LINE__); "assertion \"" #a "\" failed in %s:%u",__FILE__,__LINE__); } }
# define dUASSERT(a,msg) if (!(a)) dDebug (d_ERR_UASSERT, \ # define dUASSERT(a,msg) { if (!(a)) { dDebug (d_ERR_UASSERT, \
msg " (%s:%d)", __FILE__,__LINE__); msg " (%s:%u)", __FILE__,__LINE__); } }
# define dDEBUGMSG(msg) dMessage (d_ERR_UASSERT, \ # define dDEBUGMSG(msg) { dMessage (d_ERR_UASSERT, \
msg " (%s:%d)", __FILE__,__LINE__); msg " (%s:%u)", __FILE__,__LINE__); }
# endif # endif
# define dIVERIFY(a) dIASSERT(a)
#else #else
# define dIASSERT(a) ; # define dIASSERT(a) ((void)0)
# define dUASSERT(a,msg) ; # define dUASSERT(a,msg) ((void)0)
# define dDEBUGMSG(msg) ; # define dDEBUGMSG(msg) ((void)0)
# define dIVERIFY(a) ((void)(a))
#endif #endif
#define dAASSERT(a) dUASSERT(a,"Bad argument(s)")
// Macro used to suppress unused variable warning # ifdef __GNUC__
#define dVARIABLEUSED(a) ((void)a) # define dICHECK(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \
"assertion \"" #a "\" failed in %s() [%s:%u]",__FUNCTION__,__FILE__,_
_LINE__); *(int *)0 = 0; } }
# else // not __GNUC__
# define dICHECK(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \
"assertion \"" #a "\" failed in %s:%u",__FILE__,__LINE__); *(int *)0
= 0; } }
# endif
// Argument assert is a special case of user assert
#define dAASSERT(a) dUASSERT(a,"Bad argument(s)")
/* floating point data type, vector, matrix and quaternion types */ /* floating point data type, vector, matrix and quaternion types */
#if defined(dSINGLE) #if defined(dSINGLE)
typedef float dReal; typedef float dReal;
#ifdef dDOUBLE #ifdef dDOUBLE
#error You can only #define dSINGLE or dDOUBLE, not both. #error You can only #define dSINGLE or dDOUBLE, not both.
#endif // dDOUBLE #endif // dDOUBLE
#elif defined(dDOUBLE) #elif defined(dDOUBLE)
typedef double dReal; typedef double dReal;
skipping to change at line 146 skipping to change at line 157
#define REAL(x) (x ## f) /* form a co nstant */ #define REAL(x) (x ## f) /* form a co nstant */
#define dRecip(x) ((1.0f/(x))) /* reciprocal */ #define dRecip(x) ((1.0f/(x))) /* reciprocal */
#define dSqrt(x) (sqrtf(x)) /* square root */ #define dSqrt(x) (sqrtf(x)) /* square root */
#define dRecipSqrt(x) ((1.0f/sqrtf(x))) /* reciprocal square root */ #define dRecipSqrt(x) ((1.0f/sqrtf(x))) /* reciprocal square root */
#define dSin(x) (sinf(x)) /* sine */ #define dSin(x) (sinf(x)) /* sine */
#define dCos(x) (cosf(x)) /* cosine */ #define dCos(x) (cosf(x)) /* cosine */
#define dFabs(x) (fabsf(x)) /* absolute value */ #define dFabs(x) (fabsf(x)) /* absolute value */
#define dAtan2(y,x) (atan2f(y,x)) /* arc tangent with 2 args * / #define dAtan2(y,x) (atan2f(y,x)) /* arc tangent with 2 args * /
#define dFMod(a,b) (fmodf(a,b)) /* modulo */ #define dFMod(a,b) (fmodf(a,b)) /* modulo */
#define dFloor(x) floorf(x) /* floor */ #define dFloor(x) floorf(x) /* floor */
#define dCeil(x) ceilf(x) /* floor */
#define dCopySign(a,b) ((dReal)copysignf(a,b)) /* copy value sign */
#define dNextAfter(x, y) nextafterf(x, y) /* next value after */
#if defined(_ODE__NEXTAFTERF_REQUIRED)
float _nextafterf(float x, float y);
#endif
#ifdef HAVE___ISNANF #ifdef HAVE___ISNANF
#define dIsNan(x) (__isnanf(x)) #define dIsNan(x) (__isnanf(x))
#elif defined(HAVE__ISNANF) #elif defined(HAVE__ISNANF)
#define dIsNan(x) (_isnanf(x)) #define dIsNan(x) (_isnanf(x))
#elif defined(HAVE_ISNANF) #elif defined(HAVE_ISNANF)
#define dIsNan(x) (isnanf(x)) #define dIsNan(x) (isnanf(x))
#else #else
/* /*
fall back to _isnan which is the VC way, fall back to _isnan which is the VC way,
this may seem redundant since we already checked this may seem redundant since we already checked
for _isnan before, but if isnan is detected by for _isnan before, but if isnan is detected by
configure but is not found during compilation configure but is not found during compilation
we should always make sure we check for __isnanf, we should always make sure we check for __isnanf,
_isnanf and isnanf in that order before falling _isnanf and isnanf in that order before falling
back to a default back to a default
*/ */
#define dIsNan(x) (_isnan(x)) #define dIsNan(x) (_isnan(x))
#endif #endif
#define dCopySign(a,b) ((dReal)copysignf(a,b))
#elif defined(dDOUBLE) #elif defined(dDOUBLE)
#define REAL(x) (x) #define REAL(x) (x)
#define dRecip(x) (1.0/(x)) #define dRecip(x) (1.0/(x))
#define dSqrt(x) sqrt(x) #define dSqrt(x) sqrt(x)
#define dRecipSqrt(x) (1.0/sqrt(x)) #define dRecipSqrt(x) (1.0/sqrt(x))
#define dSin(x) sin(x) #define dSin(x) sin(x)
#define dCos(x) cos(x) #define dCos(x) cos(x)
#define dFabs(x) fabs(x) #define dFabs(x) fabs(x)
#define dAtan2(y,x) atan2((y),(x)) #define dAtan2(y,x) atan2((y),(x))
#define dFMod(a,b) (fmod((a),(b))) #define dFMod(a,b) (fmod((a),(b)))
#define dFloor(x) floor(x) #define dFloor(x) floor(x)
#define dCeil(x) ceil(x)
#define dCopySign(a,b) (copysign((a),(b)))
#define dNextAfter(x, y) nextafter(x, y)
#undef _ODE__NEXTAFTERF_REQUIRED
#ifdef HAVE___ISNAN #ifdef HAVE___ISNAN
#define dIsNan(x) (__isnan(x)) #define dIsNan(x) (__isnan(x))
#elif defined(HAVE__ISNAN) #elif defined(HAVE__ISNAN)
#define dIsNan(x) (_isnan(x)) #define dIsNan(x) (_isnan(x))
#elif defined(HAVE_ISNAN) #elif defined(HAVE_ISNAN)
#define dIsNan(x) (isnan(x)) #define dIsNan(x) (isnan(x))
#else #else
#define dIsNan(x) (_isnan(x)) #define dIsNan(x) (_isnan(x))
#endif #endif
#define dCopySign(a,b) (copysign((a),(b)))
#else #else
#error You must #define dSINGLE or dDOUBLE #error You must #define dSINGLE or dDOUBLE
#endif #endif
/* internal object types (all prefixed with `dx') */ /* internal object types (all prefixed with `dx') */
struct dxWorld; /* dynamics world */ struct dxWorld; /* dynamics world */
struct dxSpace; /* collision space */ struct dxSpace; /* collision space */
struct dxBody; /* rigid body (dynamics object) */ struct dxBody; /* rigid body (dynamics object) */
struct dxGeom; /* geometry (collision object) */ struct dxGeom; /* geometry (collision object) */
struct dxJoint; struct dxJoint;
struct dxJointNode; struct dxJointNode;
struct dxJointGroup; struct dxJointGroup;
struct dxWorldProcessThreadingManager;
typedef struct dxWorld *dWorldID; typedef struct dxWorld *dWorldID;
typedef struct dxSpace *dSpaceID; typedef struct dxSpace *dSpaceID;
typedef struct dxBody *dBodyID; typedef struct dxBody *dBodyID;
typedef struct dxGeom *dGeomID; typedef struct dxGeom *dGeomID;
typedef struct dxJoint *dJointID; typedef struct dxJoint *dJointID;
typedef struct dxJointGroup *dJointGroupID; typedef struct dxJointGroup *dJointGroupID;
typedef struct dxWorldProcessThreadingManager *dWorldStepThreadingManagerID ;
/* error numbers */ /* error numbers */
enum { enum {
d_ERR_UNKNOWN = 0, /* unknown error */ d_ERR_UNKNOWN = 0, /* unknown error */
d_ERR_IASSERT, /* internal assertion failed */ d_ERR_IASSERT, /* internal assertion failed */
d_ERR_UASSERT, /* user assertion failed */ d_ERR_UASSERT, /* user assertion failed */
d_ERR_LCP /* user assertion failed */ d_ERR_LCP /* user assertion failed */
}; };
 End of changes. 15 change blocks. 
24 lines changed or deleted 48 lines changed or added


 export-dif.h   export-dif.h 
skipping to change at line 28 skipping to change at line 28
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_EXPORT_DIF_ #ifndef _ODE_EXPORT_DIF_
#define _ODE_EXPORT_DIF_ #define _ODE_EXPORT_DIF_
#include <ode/common.h> #include <ode/common.h>
#ifdef __cplusplus
extern "C" {
#endif
ODE_API void dWorldExportDIF (dWorldID w, FILE *file, const char *world_nam e); ODE_API void dWorldExportDIF (dWorldID w, FILE *file, const char *world_nam e);
#ifdef __cplusplus
}
#endif
#endif #endif
 End of changes. 2 change blocks. 
0 lines changed or deleted 8 lines changed or added


 matrix.h   matrix.h 
skipping to change at line 172 skipping to change at line 172
*/ */
ODE_API void dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d, ODE_API void dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d,
int n1, int n2, int r, int nskip); int n1, int n2, int r, int nskip);
/* given an n*n matrix A (with leading dimension nskip), remove the r'th ro w /* given an n*n matrix A (with leading dimension nskip), remove the r'th ro w
* and column by moving elements. the new matrix will have the same leading * and column by moving elements. the new matrix will have the same leading
* dimension. the last row and column of A are untouched on exit. * dimension. the last row and column of A are untouched on exit.
*/ */
ODE_API void dRemoveRowCol (dReal *A, int n, int nskip, int r); ODE_API void dRemoveRowCol (dReal *A, int n, int nskip, int r);
#if defined(__ODE__)
void _dSetZero (dReal *a, size_t n);
void _dSetValue (dReal *a, size_t n, dReal value);
dReal _dDot (const dReal *a, const dReal *b, int n);
void _dMultiply0 (dReal *A, const dReal *B, const dReal *C, int p,int q,int
r);
void _dMultiply1 (dReal *A, const dReal *B, const dReal *C, int p,int q,int
r);
void _dMultiply2 (dReal *A, const dReal *B, const dReal *C, int p,int q,int
r);
int _dFactorCholesky (dReal *A, int n, void *tmpbuf);
void _dSolveCholesky (const dReal *L, dReal *b, int n, void *tmpbuf);
int _dInvertPDMatrix (const dReal *A, dReal *Ainv, int n, void *tmpbuf);
int _dIsPositiveDefinite (const dReal *A, int n, void *tmpbuf);
void _dFactorLDLT (dReal *A, dReal *d, int n, int nskip);
void _dSolveL1 (const dReal *L, dReal *b, int n, int nskip);
void _dSolveL1T (const dReal *L, dReal *b, int n, int nskip);
void _dVectorScale (dReal *a, const dReal *d, int n);
void _dSolveLDLT (const dReal *L, const dReal *d, dReal *b, int n, int nski
p);
void _dLDLTAddTL (dReal *L, dReal *d, const dReal *a, int n, int nskip, voi
d *tmpbuf);
void _dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d, int n1, int
n2, int r, int nskip, void *tmpbuf);
void _dRemoveRowCol (dReal *A, int n, int nskip, int r);
PURE_INLINE size_t _dEstimateFactorCholeskyTmpbufSize(int n)
{
return dPAD(n) * sizeof(dReal);
}
PURE_INLINE size_t _dEstimateSolveCholeskyTmpbufSize(int n)
{
return dPAD(n) * sizeof(dReal);
}
PURE_INLINE size_t _dEstimateInvertPDMatrixTmpbufSize(int n)
{
size_t FactorCholesky_size = _dEstimateFactorCholeskyTmpbufSize(n);
size_t SolveCholesky_size = _dEstimateSolveCholeskyTmpbufSize(n);
size_t MaxCholesky_size = FactorCholesky_size > SolveCholesky_size ? Fact
orCholesky_size : SolveCholesky_size;
return dPAD(n) * (n + 1) * sizeof(dReal) + MaxCholesky_size;
}
PURE_INLINE size_t _dEstimateIsPositiveDefiniteTmpbufSize(int n)
{
return dPAD(n) * n * sizeof(dReal) + _dEstimateFactorCholeskyTmpbufSize(n
);
}
PURE_INLINE size_t _dEstimateLDLTAddTLTmpbufSize(int nskip)
{
return nskip * 2 * sizeof(dReal);
}
PURE_INLINE size_t _dEstimateLDLTRemoveTmpbufSize(int n2, int nskip)
{
return n2 * sizeof(dReal) + _dEstimateLDLTAddTLTmpbufSize(nskip);
}
// For internal use
#define dSetZero(a, n) _dSetZero(a, n)
#define dSetValue(a, n, value) _dSetValue(a, n, value)
#define dDot(a, b, n) _dDot(a, b, n)
#define dMultiply0(A, B, C, p, q, r) _dMultiply0(A, B, C, p, q, r)
#define dMultiply1(A, B, C, p, q, r) _dMultiply1(A, B, C, p, q, r)
#define dMultiply2(A, B, C, p, q, r) _dMultiply2(A, B, C, p, q, r)
#define dFactorCholesky(A, n, tmpbuf) _dFactorCholesky(A, n, tmpbuf)
#define dSolveCholesky(L, b, n, tmpbuf) _dSolveCholesky(L, b, n, tmpbuf)
#define dInvertPDMatrix(A, Ainv, n, tmpbuf) _dInvertPDMatrix(A, Ainv, n, tm
pbuf)
#define dIsPositiveDefinite(A, n, tmpbuf) _dIsPositiveDefinite(A, n, tmpbuf
)
#define dFactorLDLT(A, d, n, nskip) _dFactorLDLT(A, d, n, nskip)
#define dSolveL1(L, b, n, nskip) _dSolveL1(L, b, n, nskip)
#define dSolveL1T(L, b, n, nskip) _dSolveL1T(L, b, n, nskip)
#define dVectorScale(a, d, n) _dVectorScale(a, d, n)
#define dSolveLDLT(L, d, b, n, nskip) _dSolveLDLT(L, d, b, n, nskip)
#define dLDLTAddTL(L, d, a, n, nskip, tmpbuf) _dLDLTAddTL(L, d, a, n, nskip
, tmpbuf)
#define dLDLTRemove(A, p, L, d, n1, n2, r, nskip, tmpbuf) _dLDLTRemove(A, p
, L, d, n1, n2, r, nskip, tmpbuf)
#define dRemoveRowCol(A, n, nskip, r) _dRemoveRowCol(A, n, nskip, r)
#define dEstimateFactorCholeskyTmpbufSize(n) _dEstimateFactorCholeskyTmpbuf
Size(n)
#define dEstimateSolveCholeskyTmpbufSize(n) _dEstimateSolveCholeskyTmpbufSi
ze(n)
#define dEstimateInvertPDMatrixTmpbufSize(n) _dEstimateInvertPDMatrixTmpbuf
Size(n)
#define dEstimateIsPositiveDefiniteTmpbufSize(n) _dEstimateIsPositiveDefini
teTmpbufSize(n)
#define dEstimateLDLTAddTLTmpbufSize(nskip) _dEstimateLDLTAddTLTmpbufSize(n
skip)
#define dEstimateLDLTRemoveTmpbufSize(n2, nskip) _dEstimateLDLTRemoveTmpbuf
Size(n2, nskip)
#endif // defined(__ODE__)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 1 change blocks. 
0 lines changed or deleted 101 lines changed or added


 objects.h   objects.h 
skipping to change at line 114 skipping to change at line 114
ODE_API void dWorldSetCFM (dWorldID, dReal cfm); ODE_API void dWorldSetCFM (dWorldID, dReal cfm);
/** /**
* @brief Get the constraint force mixing value. * @brief Get the constraint force mixing value.
* @ingroup world * @ingroup world
* @return CFM value * @return CFM value
*/ */
ODE_API dReal dWorldGetCFM (dWorldID); ODE_API dReal dWorldGetCFM (dWorldID);
/** /**
* @brief Step the world. * @brief Set the world to use shared working memory along with another wor
ld.
*
* The worlds allocate working memory internally for simulation stepping. T
his
* memory is cached among the calls to @c dWordStep and @c dWorldQuickStep.
* Similarly, several worlds can be set up to share this memory caches thus
* reducing overall memory usage by cost of making worlds inappropriate for
* simultaneous simulation in multiple threads.
*
* If null value is passed for @a from_world parameter the world is detache
d from
* sharing and returns to defaults for working memory, reservation policy a
nd
* memory manager as if just created. This can also be used to enable use o
f shared
* memory for a world that has already had working memory allocated private
ly.
* Normally using shared memory after a world has its private working memor
y allocated
* is prohibited.
*
* Allocation policy used can only increase world's internal reserved memor
y size
* and never decreases it. @c dWorldCleanupWorkingMemory can be used to rel
ease
* working memory for a world in case if number of objects/joint decreases
* significantly in it.
*
* With sharing working memory worlds also automatically share memory reser
vation
* policy and memory manager. Thus, these parameters need to be customized
for
* initial world to be used as sharing source only.
*
* Failure result status means a memory allocation failure.
*
* @param w The world to use the shared memory with.
* @param from_world Null or the world the shared memory is to be used from
.
* @returns 1 for success and 0 for failure.
* *
* This uses a "big matrix" method that takes time on the order of m^3
* and memory on the order of m^2, where m is the total number of constrain
t
* rows. For large systems this will use a lot of memory and can be very sl
ow,
* but this is currently the most accurate method.
* @ingroup world * @ingroup world
* @param stepsize The number of seconds that the simulation has to advance * @see dWorldCleanupWorkingMemory
. * @see dWorldSetStepMemoryReservationPolicy
* @see dWorldSetStepMemoryManager
*/ */
ODE_API void dWorldStep (dWorldID, dReal stepsize); ODE_API int dWorldUseSharedWorkingMemory(dWorldID w, dWorldID from_world/*= NULL*/);
/** /**
* @brief Converts an impulse to a force. * @brief Release internal working memory allocated for world
*
* The worlds allocate working memory internally for simulation stepping. T
his
* function can be used to free world's internal memory cache in case if nu
mber of
* objects/joints in the world decreases significantly. By default, interna
l
* allocation policy is used to only increase cache size as necessary and n
ever
* decrease it.
*
* If a world shares its working memory with other worlds the cache deletio
n
* affects all the linked worlds. However the shared status itself remains
intact.
*
* The function call does affect neither memory reservation policy nor memo
ry manager.
*
* @param w The world to release working memory for.
*
* @ingroup world * @ingroup world
* @remarks * @see dWorldUseSharedWorkingMemory
* If you want to apply a linear or angular impulse to a rigid body, * @see dWorldSetStepMemoryReservationPolicy
* instead of a force or a torque, then you can use this function to conver * @see dWorldSetStepMemoryManager
t
* the desired impulse into a force/torque vector before calling the
* BodyAdd... function.
* The current algorithm simply scales the impulse by 1/stepsize,
* where stepsize is the step size for the next step that will be taken.
* This function is given a dWorldID because, in the future, the force
* computation may depend on integrator parameters that are set as
* properties of the world.
*/ */
ODE_API void dWorldImpulseToForce ODE_API void dWorldCleanupWorkingMemory(dWorldID w);
(
dWorldID, dReal stepsize, #define dWORLDSTEP_RESERVEFACTOR_DEFAULT 1.2f
dReal ix, dReal iy, dReal iz, dVector3 force #define dWORLDSTEP_RESERVESIZE_DEFAULT 65536U
);
/**
* @struct dWorldStepReserveInfo
* @brief Memory reservation policy descriptor structure for world stepping
functions.
*
* @c struct_size should be assigned the size of the structure.
*
* @c reserve_factor is a quotient that is multiplied by required memory si
ze
* to allocate extra reserve whenever reallocation is needed.
*
* @c reserve_minimum is a minimum size that is checked against whenever re
allocation
* is needed to allocate expected working memory minimum at once without ex
tra
* reallocations as number of bodies/joints grows.
*
* @ingroup world
* @see dWorldSetStepMemoryReservationPolicy
*/
typedef struct
{
unsigned struct_size;
float reserve_factor; // Use float as precision does not matter here
unsigned reserve_minimum;
} dWorldStepReserveInfo;
/**
* @brief Set memory reservation policy for world to be used with simulatio
n stepping functions
*
* The function allows to customize reservation policy to be used for inter
nal
* memory which is allocated to aid simulation for a world. By default, val
ues
* of @c dWORLDSTEP_RESERVEFACTOR_DEFAULT and @c dWORLDSTEP_RESERVESIZE_DEF
AULT
* are used.
*
* Passing @a policyinfo argument as NULL results in reservation policy bei
ng
* reset to defaults as if the world has been just created. The content of
* @a policyinfo structure is copied internally and does not need to remain
valid
* after the call returns.
*
* If the world uses working memory sharing, changing memory reservation po
licy
* affects all the worlds linked together.
*
* Failure result status means a memory allocation failure.
*
* @param w The world to change memory reservation policy for.
* @param policyinfo Null or a pointer to policy descriptor structure.
* @returns 1 for success and 0 for failure.
*
* @ingroup world
* @see dWorldUseSharedWorkingMemory
*/
ODE_API int dWorldSetStepMemoryReservationPolicy(dWorldID w, const dWorldSt
epReserveInfo *policyinfo/*=NULL*/);
/**
* @struct dWorldStepMemoryFunctionsInfo
* @brief World stepping memory manager descriptor structure
*
* This structure is intended to define the functions of memory manager to b
e used
* with world stepping functions.
*
* @c struct_size should be assigned the size of the structure
*
* @c alloc_block is a function to allocate memory block of given size.
*
* @c shrink_block is a function to shrink existing memory block to a smalle
r size.
* It must preserve the contents of block head while shrinking. The new bloc
k size
* is guaranteed to be always less than the existing one.
*
* @c free_block is a function to delete existing memory block.
*
* @ingroup init
* @see dWorldSetStepMemoryManager
*/
typedef struct
{
unsigned struct_size;
void *(*alloc_block)(size_t block_size);
void *(*shrink_block)(void *block_pointer, size_t block_current_size, siz
e_t block_smaller_size);
void (*free_block)(void *block_pointer, size_t block_current_size);
} dWorldStepMemoryFunctionsInfo;
/**
* @brief Set memory manager for world to be used with simulation stepping f
unctions
*
* The function allows to customize memory manager to be used for internal
* memory allocation during simulation for a world. By default, @c dAlloc/@c
dRealloc/@c dFree
* based memory manager is used.
*
* Passing @a memfuncs argument as NULL results in memory manager being
* reset to default one as if the world has been just created. The content o
f
* @a memfuncs structure is copied internally and does not need to remain va
lid
* after the call returns.
*
* If the world uses working memory sharing, changing memory manager
* affects all the worlds linked together.
*
* Failure result status means a memory allocation failure.
*
* @param w The world to change memory reservation policy for.
* @param memfuncs Null or a pointer to memory manager descriptor structure.
* @returns 1 for success and 0 for failure.
*
* @ingroup world
* @see dWorldUseSharedWorkingMemory
*/
ODE_API int dWorldSetStepMemoryManager(dWorldID w, const dWorldStepMemoryFu
nctionsInfo *memfuncs);
/** /**
* @brief Step the world. * @brief Step the world.
*
* This uses a "big matrix" method that takes time on the order of m^3
* and memory on the order of m^2, where m is the total number of constrain
t
* rows. For large systems this will use a lot of memory and can be very sl
ow,
* but this is currently the most accurate method.
*
* Failure result status means that the memory allocation has failed for op
eration.
* In such a case all the objects remain in unchanged state and simulation
can be
* retried as soon as more memory is available.
*
* @param w The world to be stepped
* @param stepsize The number of seconds that the simulation has to advance
.
* @returns 1 for success and 0 for failure
*
* @ingroup world * @ingroup world
* @remarks */
ODE_API int dWorldStep (dWorldID w, dReal stepsize);
/**
* @brief Quick-step the world.
*
* This uses an iterative method that takes time on the order of m*N * This uses an iterative method that takes time on the order of m*N
* and memory on the order of m, where m is the total number of constraint * and memory on the order of m, where m is the total number of constraint
* rows N is the number of iterations. * rows N is the number of iterations.
* For large systems this is a lot faster than dWorldStep(), * For large systems this is a lot faster than dWorldStep(),
* but it is less accurate. * but it is less accurate.
* @remarks *
* QuickStep is great for stacks of objects especially when the * QuickStep is great for stacks of objects especially when the
* auto-disable feature is used as well. * auto-disable feature is used as well.
* However, it has poor accuracy for near-singular systems. * However, it has poor accuracy for near-singular systems.
* Near-singular systems can occur when using high-friction contacts, motor s, * Near-singular systems can occur when using high-friction contacts, motor s,
* or certain articulated structures. For example, a robot with multiple le gs * or certain articulated structures. For example, a robot with multiple le gs
* sitting on the ground may be near-singular. * sitting on the ground may be near-singular.
* @remarks *
* There are ways to help overcome QuickStep's inaccuracy problems: * There are ways to help overcome QuickStep's inaccuracy problems:
*
* \li Increase CFM. * \li Increase CFM.
* \li Reduce the number of contacts in your system (e.g. use the minimum * \li Reduce the number of contacts in your system (e.g. use the minimum
* number of contacts for the feet of a robot or creature). * number of contacts for the feet of a robot or creature).
* \li Don't use excessive friction in the contacts. * \li Don't use excessive friction in the contacts.
* \li Use contact slip if appropriate * \li Use contact slip if appropriate
* \li Avoid kinematic loops (however, kinematic loops are inevitable in * \li Avoid kinematic loops (however, kinematic loops are inevitable in
* legged creatures). * legged creatures).
* \li Don't use excessive motor strength. * \li Don't use excessive motor strength.
* \liUse force-based motors instead of velocity-based motors. * \liUse force-based motors instead of velocity-based motors.
* *
* Increasing the number of QuickStep iterations may help a little bit, but * Increasing the number of QuickStep iterations may help a little bit, but
* it is not going to help much if your system is really near singular. * it is not going to help much if your system is really near singular.
*
* Failure result status means that the memory allocation has failed for op
eration.
* In such a case all the objects remain in unchanged state and simulation
can be
* retried as soon as more memory is available.
*
* @param w The world to be stepped
* @param stepsize The number of seconds that the simulation has to advance
.
* @returns 1 for success and 0 for failure
*
* @ingroup world
*/ */
ODE_API void dWorldQuickStep (dWorldID w, dReal stepsize); ODE_API int dWorldQuickStep (dWorldID w, dReal stepsize);
/**
* @brief Converts an impulse to a force.
* @ingroup world
* @remarks
* If you want to apply a linear or angular impulse to a rigid body,
* instead of a force or a torque, then you can use this function to convert
* the desired impulse into a force/torque vector before calling the
* BodyAdd... function.
* The current algorithm simply scales the impulse by 1/stepsize,
* where stepsize is the step size for the next step that will be taken.
* This function is given a dWorldID because, in the future, the force
* computation may depend on integrator parameters that are set as
* properties of the world.
*/
ODE_API void dWorldImpulseToForce
(
dWorldID, dReal stepsize,
dReal ix, dReal iy, dReal iz, dVector3 force
);
/** /**
* @brief Set the number of iterations that the QuickStep method performs p er * @brief Set the number of iterations that the QuickStep method performs p er
* step. * step.
* @ingroup world * @ingroup world
* @remarks * @remarks
* More iterations will give a more accurate solution, but will take * More iterations will give a more accurate solution, but will take
* longer to compute. * longer to compute.
* @param num The default is 20 iterations. * @param num The default is 20 iterations.
*/ */
skipping to change at line 250 skipping to change at line 438
*/ */
ODE_API void dWorldSetContactSurfaceLayer (dWorldID, dReal depth); ODE_API void dWorldSetContactSurfaceLayer (dWorldID, dReal depth);
/** /**
* @brief Get the depth of the surface layer around all geometry objects. * @brief Get the depth of the surface layer around all geometry objects.
* @ingroup world * @ingroup world
* @returns the depth * @returns the depth
*/ */
ODE_API dReal dWorldGetContactSurfaceLayer (dWorldID); ODE_API dReal dWorldGetContactSurfaceLayer (dWorldID);
/* StepFast1 functions */
/**
* @brief Step the world using the StepFast1 algorithm.
* @param stepsize the nr of seconds to advance the simulation.
* @param maxiterations The number of iterations to perform.
* @ingroup world
*/
ODE_API void dWorldStepFast1(dWorldID, dReal stepsize, int maxiterations);
/** /**
* @defgroup disable Automatic Enabling and Disabling * @defgroup disable Automatic Enabling and Disabling
* @ingroup world bodies * @ingroup world bodies
* *
* Every body can be enabled or disabled. Enabled bodies participate in the * Every body can be enabled or disabled. Enabled bodies participate in the
* simulation, while disabled bodies are turned off and do not get updated * simulation, while disabled bodies are turned off and do not get updated
* during a simulation step. New bodies are always created in the enabled s tate. * during a simulation step. New bodies are always created in the enabled s tate.
* *
* A disabled body that is connected through a joint to an enabled body wil l be * A disabled body that is connected through a joint to an enabled body wil l be
* automatically re-enabled at the next simulation step. * automatically re-enabled at the next simulation step.
skipping to change at line 293 skipping to change at line 471
* to zero with * to zero with
* *
* Thus, every body has six auto-disable parameters: an enabled flag, a idl e step * Thus, every body has six auto-disable parameters: an enabled flag, a idl e step
* count, an idle time, linear/angular average velocity thresholds, and the * count, an idle time, linear/angular average velocity thresholds, and the
* average samples count. * average samples count.
* *
* Newly created bodies get these parameters from world. * Newly created bodies get these parameters from world.
*/ */
/** /**
* @brief Set the AutoEnableDepth parameter used by the StepFast1 algorithm
.
* @ingroup disable
*/
ODE_API void dWorldSetAutoEnableDepthSF1(dWorldID, int autoEnableDepth);
/**
* @brief Get the AutoEnableDepth parameter used by the StepFast1 algorithm
.
* @ingroup disable
*/
ODE_API int dWorldGetAutoEnableDepthSF1(dWorldID);
/**
* @brief Get auto disable linear threshold for newly created bodies. * @brief Get auto disable linear threshold for newly created bodies.
* @ingroup disable * @ingroup disable
* @return the threshold * @return the threshold
*/ */
ODE_API dReal dWorldGetAutoDisableLinearThreshold (dWorldID); ODE_API dReal dWorldGetAutoDisableLinearThreshold (dWorldID);
/** /**
* @brief Set auto disable linear threshold for newly created bodies. * @brief Set auto disable linear threshold for newly created bodies.
* @param linear_threshold default is 0.01 * @param linear_threshold default is 0.01
* @ingroup disable * @ingroup disable
 End of changes. 16 change blocks. 
55 lines changed or deleted 263 lines changed or added


 odeconfig.h   odeconfig.h 
#ifndef ODECONFIG_H #ifndef ODECONFIG_H
#define ODECONFIG_H #define ODECONFIG_H
#ifndef dDOUBLE
#ifndef dSINGLE
#define dSINGLE
#endif
#endif
/* Pull in the standard headers */ /* Pull in the standard headers */
#include <stddef.h>
#include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <float.h> #include <float.h>
#if defined(ODE_DLL) || defined(ODE_LIB) || !defined(_MSC_VER) #if defined(ODE_DLL) || defined(ODE_LIB)
#define __ODE__ #define __ODE__
#endif #endif
/* Define a DLL export symbol for those platforms that need it */ /* Define a DLL export symbol for those platforms that need it */
#if defined(_MSC_VER) #if defined(_MSC_VER)
#if defined(ODE_DLL) #if defined(ODE_DLL)
#define ODE_API __declspec(dllexport) #define ODE_API __declspec(dllexport)
#elif !defined(ODE_LIB) #elif !defined(ODE_LIB)
#define ODE_DLL_API __declspec(dllimport) #define ODE_DLL_API __declspec(dllimport)
#endif #endif
skipping to change at line 50 skipping to change at line 46
# define ODE_API_DEPRECATED # define ODE_API_DEPRECATED
#endif #endif
/* Well-defined common data types...need to define for 64 bit systems */ /* Well-defined common data types...need to define for 64 bit systems */
#if defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(_ _x86_64__) #if defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(_ _x86_64__)
#define X86_64_SYSTEM 1 #define X86_64_SYSTEM 1
typedef int int32; typedef int int32;
typedef unsigned int uint32; typedef unsigned int uint32;
typedef short int16; typedef short int16;
typedef unsigned short uint16; typedef unsigned short uint16;
typedef char int8; typedef signed char int8;
typedef unsigned char uint8; typedef unsigned char uint8;
#else #else
typedef int int32; typedef int int32;
typedef unsigned int uint32; typedef unsigned int uint32;
typedef short int16; typedef short int16;
typedef unsigned short uint16; typedef unsigned short uint16;
typedef char int8; typedef signed char int8;
typedef unsigned char uint8; typedef unsigned char uint8;
#endif #endif
/* Visual C does not define these functions */ /* Visual C does not define these functions */
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define copysignf _copysign #define copysignf(x, y) ((float)_copysign(x, y))
#define copysign _copysign #define copysign(x, y) _copysign(x, y)
#define nextafterf(x, y) _nextafterf(x, y)
#define nextafter(x, y) _nextafter(x, y)
#if !defined(_WIN64)
#define _ODE__NEXTAFTERF_REQUIRED
#endif
#endif #endif
/* Define the dInfinity macro */ /* Define the dInfinity macro */
#ifdef INFINITY #ifdef INFINITY
#define dInfinity INFINITY #define dInfinity INFINITY
#elif defined(HUGE_VAL) #elif defined(HUGE_VAL)
#ifdef dSINGLE #ifdef dSINGLE
#ifdef HUGE_VALF #ifdef HUGE_VALF
#define dInfinity HUGE_VALF #define dInfinity HUGE_VALF
#else #else
 End of changes. 6 change blocks. 
11 lines changed or deleted 12 lines changed or added


 odecpp.h   odecpp.h 
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001, 2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
/* C++ interface for non-collision stuff */ /* C++ interface for non-collision stuff */
#ifndef _ODE_ODECPP_H_ #ifndef _ODE_ODECPP_H_
#define _ODE_ODECPP_H_ #define _ODE_ODECPP_H_
#ifdef __cplusplus #ifdef __cplusplus
//namespace ode { //namespace ode {
class dWorld { class dWorldSimpleIDContainer {
dWorldID _id; protected:
dWorldID _id;
dWorldSimpleIDContainer(): _id(0) {}
~dWorldSimpleIDContainer() { destroy(); }
void destroy() {
if (_id) {
dWorldDestroy(_id);
_id = 0;
}
}
};
class dWorldDynamicIDContainer: public dWorldSimpleIDContainer {
protected:
virtual ~dWorldDynamicIDContainer() {}
};
template <class dWorldTemplateBase>
class dWorldTemplate: public dWorldTemplateBase {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dWorld (const dWorld &); dWorldTemplate (const dWorldTemplate<dWorldTemplateBase> &);
void operator= (const dWorld &); void operator= (const dWorldTemplate<dWorldTemplateBase> &);
protected:
dWorldID get_id() const { return dWorldTemplateBase::_id; }
void set_id(dWorldID value) { dWorldTemplateBase::_id = value; }
public: public:
dWorld() dWorldTemplate()
{ _id = dWorldCreate(); } { set_id(dWorldCreate()); }
~dWorld()
{ dWorldDestroy (_id); }
dWorldID id() const dWorldID id() const
{ return _id; } { return get_id(); }
operator dWorldID() const operator dWorldID() const
{ return _id; } { return get_id(); }
void setGravity (dReal x, dReal y, dReal z) void setGravity (dReal x, dReal y, dReal z)
{ dWorldSetGravity (_id,x,y,z); } { dWorldSetGravity (get_id(), x, y, z); }
void setGravity (const dVector3 g) void setGravity (const dVector3 g)
{ setGravity (g[0], g[1], g[2]); } { setGravity (g[0], g[1], g[2]); }
void getGravity (dVector3 g) const void getGravity (dVector3 g) const
{ dWorldGetGravity (_id,g); } { dWorldGetGravity (get_id(), g); }
void setERP (dReal erp) void setERP (dReal erp)
{ dWorldSetERP(_id, erp); } { dWorldSetERP(get_id(), erp); }
dReal getERP() const dReal getERP() const
{ return dWorldGetERP(_id); } { return dWorldGetERP(get_id()); }
void setCFM (dReal cfm) void setCFM (dReal cfm)
{ dWorldSetCFM(_id, cfm); } { dWorldSetCFM(get_id(), cfm); }
dReal getCFM() const dReal getCFM() const
{ return dWorldGetCFM(_id); } { return dWorldGetCFM(get_id()); }
void step (dReal stepsize) void step (dReal stepsize)
{ dWorldStep (_id,stepsize); } { dWorldStep (get_id(), stepsize); }
void stepFast1 (dReal stepsize, int maxiterations)
{ dWorldStepFast1 (_id,stepsize,maxiterations); }
void setAutoEnableDepthSF1(int depth)
{ dWorldSetAutoEnableDepthSF1 (_id, depth); }
int getAutoEnableDepthSF1() const
{ return dWorldGetAutoEnableDepthSF1 (_id); }
void quickStep(dReal stepsize) void quickStep(dReal stepsize)
{ dWorldQuickStep (_id, stepsize); } { dWorldQuickStep (get_id(), stepsize); }
void setQuickStepNumIterations(int num) void setQuickStepNumIterations(int num)
{ dWorldSetQuickStepNumIterations (_id, num); } { dWorldSetQuickStepNumIterations (get_id(), num); }
int getQuickStepNumIterations() const int getQuickStepNumIterations() const
{ return dWorldGetQuickStepNumIterations (_id); } { return dWorldGetQuickStepNumIterations (get_id()); }
void setQuickStepW(dReal over_relaxation) void setQuickStepW(dReal over_relaxation)
{ dWorldSetQuickStepW (_id, over_relaxation); } { dWorldSetQuickStepW (get_id(), over_relaxation); }
dReal getQuickStepW() const dReal getQuickStepW() const
{ return dWorldGetQuickStepW (_id); } { return dWorldGetQuickStepW (get_id()); }
void setAutoDisableLinearThreshold (dReal threshold) void setAutoDisableLinearThreshold (dReal threshold)
{ dWorldSetAutoDisableLinearThreshold (_id,threshold); } { dWorldSetAutoDisableLinearThreshold (get_id(), threshold); }
dReal getAutoDisableLinearThreshold() const dReal getAutoDisableLinearThreshold() const
{ return dWorldGetAutoDisableLinearThreshold (_id); } { return dWorldGetAutoDisableLinearThreshold (get_id()); }
void setAutoDisableAngularThreshold (dReal threshold) void setAutoDisableAngularThreshold (dReal threshold)
{ dWorldSetAutoDisableAngularThreshold (_id,threshold); } { dWorldSetAutoDisableAngularThreshold (get_id(), threshold); }
dReal getAutoDisableAngularThreshold() const dReal getAutoDisableAngularThreshold() const
{ return dWorldGetAutoDisableAngularThreshold (_id); } { return dWorldGetAutoDisableAngularThreshold (get_id()); }
void setAutoDisableSteps (int steps) void setAutoDisableSteps (int steps)
{ dWorldSetAutoDisableSteps (_id,steps); } { dWorldSetAutoDisableSteps (get_id(), steps); }
int getAutoDisableSteps() const int getAutoDisableSteps() const
{ return dWorldGetAutoDisableSteps (_id); } { return dWorldGetAutoDisableSteps (get_id()); }
void setAutoDisableTime (dReal time) void setAutoDisableTime (dReal time)
{ dWorldSetAutoDisableTime (_id,time); } { dWorldSetAutoDisableTime (get_id(), time); }
dReal getAutoDisableTime() const dReal getAutoDisableTime() const
{ return dWorldGetAutoDisableTime (_id); } { return dWorldGetAutoDisableTime (get_id()); }
void setAutoDisableFlag (int do_auto_disable) void setAutoDisableFlag (int do_auto_disable)
{ dWorldSetAutoDisableFlag (_id,do_auto_disable); } { dWorldSetAutoDisableFlag (get_id(), do_auto_disable); }
int getAutoDisableFlag() const int getAutoDisableFlag() const
{ return dWorldGetAutoDisableFlag (_id); } { return dWorldGetAutoDisableFlag (get_id()); }
dReal getLinearDampingThreshold() const dReal getLinearDampingThreshold() const
{ return dWorldGetLinearDampingThreshold(_id); } { return dWorldGetLinearDampingThreshold(get_id()); }
void setLinearDampingThreshold(dReal threshold) void setLinearDampingThreshold(dReal threshold)
{ dWorldSetLinearDampingThreshold(_id, threshold); } { dWorldSetLinearDampingThreshold(get_id(), threshold); }
dReal getAngularDampingThreshold() const dReal getAngularDampingThreshold() const
{ return dWorldGetAngularDampingThreshold(_id); } { return dWorldGetAngularDampingThreshold(get_id()); }
void setAngularDampingThreshold(dReal threshold) void setAngularDampingThreshold(dReal threshold)
{ dWorldSetAngularDampingThreshold(_id, threshold); } { dWorldSetAngularDampingThreshold(get_id(), threshold); }
dReal getLinearDamping() const dReal getLinearDamping() const
{ return dWorldGetLinearDamping(_id); } { return dWorldGetLinearDamping(get_id()); }
void setLinearDamping(dReal scale) void setLinearDamping(dReal scale)
{ dWorldSetLinearDamping(_id, scale); } { dWorldSetLinearDamping(get_id(), scale); }
dReal getAngularDamping() const dReal getAngularDamping() const
{ return dWorldGetAngularDamping(_id); } { return dWorldGetAngularDamping(get_id()); }
void setAngularDamping(dReal scale) void setAngularDamping(dReal scale)
{ dWorldSetAngularDamping(_id, scale); } { dWorldSetAngularDamping(get_id(), scale); }
void setDamping(dReal linear_scale, dReal angular_scale) void setDamping(dReal linear_scale, dReal angular_scale)
{ dWorldSetDamping(_id, linear_scale, angular_scale); } { dWorldSetDamping(get_id(), linear_scale, angular_scale); }
dReal getMaxAngularSpeed() const dReal getMaxAngularSpeed() const
{ return dWorldGetMaxAngularSpeed(_id); } { return dWorldGetMaxAngularSpeed(get_id()); }
void setMaxAngularSpeed(dReal max_speed) void setMaxAngularSpeed(dReal max_speed)
{ dWorldSetMaxAngularSpeed(_id, max_speed); } { dWorldSetMaxAngularSpeed(get_id(), max_speed); }
void setContactSurfaceLayer(dReal depth) void setContactSurfaceLayer(dReal depth)
{ dWorldSetContactSurfaceLayer (_id, depth); } { dWorldSetContactSurfaceLayer (get_id(), depth); }
dReal getContactSurfaceLayer() const dReal getContactSurfaceLayer() const
{ return dWorldGetContactSurfaceLayer (_id); } { return dWorldGetContactSurfaceLayer (get_id()); }
void impulseToForce (dReal stepsize, dReal ix, dReal iy, dReal iz, void impulseToForce (dReal stepsize, dReal ix, dReal iy, dReal iz,
dVector3 force) dVector3 force)
{ dWorldImpulseToForce (_id,stepsize,ix,iy,iz,force); } { dWorldImpulseToForce (get_id(), stepsize, ix, iy, iz, force); }
};
class dBodySimpleIDContainer {
protected:
dBodyID _id;
dBodySimpleIDContainer(): _id(0) {}
~dBodySimpleIDContainer() { destroy(); }
void destroy() {
if (_id) {
dBodyDestroy(_id);
_id = 0;
}
}
}; };
class dBody { class dBodyDynamicIDContainer: public dBodySimpleIDContainer {
dBodyID _id; protected:
virtual ~dBodyDynamicIDContainer() {}
};
template <class dBodyTemplateBase, class dWorldTemplateBase>
class dBodyTemplate: public dBodyTemplateBase {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dBody (const dBody &); dBodyTemplate (const dBodyTemplate<dBodyTemplateBase, dWorldTemplateBase>
void operator= (const dBody &); &);
void operator= (const dBodyTemplate<dBodyTemplateBase, dWorldTemplateBase
> &);
protected:
dBodyID get_id() const { return dBodyTemplateBase::_id; }
void set_id(dBodyID value) { dBodyTemplateBase::_id = value; }
void destroy() { dBodyTemplateBase::destroy(); }
public: public:
dBody() dBodyTemplate()
{ _id = 0; } { }
dBody (dWorldID world) dBodyTemplate (dWorldID world)
{ _id = dBodyCreate (world); } { set_id(dBodyCreate(world)); }
dBody (dWorld& world) dBodyTemplate (dWorldTemplate<dWorldTemplateBase>& world)
{ _id = dBodyCreate (world.id()); } { set_id(dBodyCreate(world.id())); }
~dBody()
{ if (_id) dBodyDestroy (_id); }
void create (dWorldID world) { void create (dWorldID world) {
if (_id) dBodyDestroy (_id); destroy();
_id = dBodyCreate (world); set_id(dBodyCreate(world));
} }
void create (dWorld& world) { void create (dWorldTemplate<dWorldTemplateBase>& world) {
create(world.id()); create(world.id());
} }
dBodyID id() const dBodyID id() const
{ return _id; } { return get_id(); }
operator dBodyID() const operator dBodyID() const
{ return _id; } { return get_id(); }
void setData (void *data) void setData (void *data)
{ dBodySetData (_id,data); } { dBodySetData (get_id(), data); }
void *getData() const void *getData() const
{ return dBodyGetData (_id); } { return dBodyGetData (get_id()); }
void setPosition (dReal x, dReal y, dReal z) void setPosition (dReal x, dReal y, dReal z)
{ dBodySetPosition (_id,x,y,z); } { dBodySetPosition (get_id(), x, y, z); }
void setPosition (const dVector3 p) void setPosition (const dVector3 p)
{ setPosition(p[0], p[1], p[2]); } { setPosition(p[0], p[1], p[2]); }
void setRotation (const dMatrix3 R) void setRotation (const dMatrix3 R)
{ dBodySetRotation (_id,R); } { dBodySetRotation (get_id(), R); }
void setQuaternion (const dQuaternion q) void setQuaternion (const dQuaternion q)
{ dBodySetQuaternion (_id,q); } { dBodySetQuaternion (get_id(), q); }
void setLinearVel (dReal x, dReal y, dReal z) void setLinearVel (dReal x, dReal y, dReal z)
{ dBodySetLinearVel (_id,x,y,z); } { dBodySetLinearVel (get_id(), x, y, z); }
void setLinearVel (const dVector3 v) void setLinearVel (const dVector3 v)
{ setLinearVel(v[0], v[1], v[2]); } { setLinearVel(v[0], v[1], v[2]); }
void setAngularVel (dReal x, dReal y, dReal z) void setAngularVel (dReal x, dReal y, dReal z)
{ dBodySetAngularVel (_id,x,y,z); } { dBodySetAngularVel (get_id(), x, y, z); }
void setAngularVel (const dVector3 v) void setAngularVel (const dVector3 v)
{ setAngularVel (v[0], v[1], v[2]); } { setAngularVel (v[0], v[1], v[2]); }
const dReal * getPosition() const const dReal * getPosition() const
{ return dBodyGetPosition (_id); } { return dBodyGetPosition (get_id()); }
const dReal * getRotation() const const dReal * getRotation() const
{ return dBodyGetRotation (_id); } { return dBodyGetRotation (get_id()); }
const dReal * getQuaternion() const const dReal * getQuaternion() const
{ return dBodyGetQuaternion (_id); } { return dBodyGetQuaternion (get_id()); }
const dReal * getLinearVel() const const dReal * getLinearVel() const
{ return dBodyGetLinearVel (_id); } { return dBodyGetLinearVel (get_id()); }
const dReal * getAngularVel() const const dReal * getAngularVel() const
{ return dBodyGetAngularVel (_id); } { return dBodyGetAngularVel (get_id()); }
void setMass (const dMass *mass) void setMass (const dMass *mass)
{ dBodySetMass (_id,mass); } { dBodySetMass (get_id(), mass); }
void setMass (const dMass &mass) void setMass (const dMass &mass)
{ setMass (&mass); } { setMass (&mass); }
dMass getMass () const dMass getMass () const
{ dMass mass; dBodyGetMass (_id,&mass); return mass; } { dMass mass; dBodyGetMass (get_id(), &mass); return mass; }
void addForce (dReal fx, dReal fy, dReal fz) void addForce (dReal fx, dReal fy, dReal fz)
{ dBodyAddForce (_id, fx, fy, fz); } { dBodyAddForce (get_id(), fx, fy, fz); }
void addForce (const dVector3 f) void addForce (const dVector3 f)
{ addForce (f[0], f[1], f[2]); } { addForce (f[0], f[1], f[2]); }
void addTorque (dReal fx, dReal fy, dReal fz) void addTorque (dReal fx, dReal fy, dReal fz)
{ dBodyAddTorque (_id, fx, fy, fz); } { dBodyAddTorque (get_id(), fx, fy, fz); }
void addTorque (const dVector3 t) void addTorque (const dVector3 t)
{ addTorque(t[0], t[1], t[2]); } { addTorque(t[0], t[1], t[2]); }
void addRelForce (dReal fx, dReal fy, dReal fz) void addRelForce (dReal fx, dReal fy, dReal fz)
{ dBodyAddRelForce (_id, fx, fy, fz); } { dBodyAddRelForce (get_id(), fx, fy, fz); }
void addRelForce (const dVector3 f) void addRelForce (const dVector3 f)
{ addRelForce (f[0], f[1], f[2]); } { addRelForce (f[0], f[1], f[2]); }
void addRelTorque (dReal fx, dReal fy, dReal fz) void addRelTorque (dReal fx, dReal fy, dReal fz)
{ dBodyAddRelTorque (_id, fx, fy, fz); } { dBodyAddRelTorque (get_id(), fx, fy, fz); }
void addRelTorque (const dVector3 t) void addRelTorque (const dVector3 t)
{ addRelTorque (t[0], t[1], t[2]); } { addRelTorque (t[0], t[1], t[2]); }
void addForceAtPos (dReal fx, dReal fy, dReal fz, void addForceAtPos (dReal fx, dReal fy, dReal fz,
dReal px, dReal py, dReal pz) dReal px, dReal py, dReal pz)
{ dBodyAddForceAtPos (_id, fx, fy, fz, px, py, pz); } { dBodyAddForceAtPos (get_id(), fx, fy, fz, px, py, pz); }
void addForceAtPos (const dVector3 f, const dVector3 p) void addForceAtPos (const dVector3 f, const dVector3 p)
{ addForceAtPos (f[0], f[1], f[2], p[0], p[1], p[2]); } { addForceAtPos (f[0], f[1], f[2], p[0], p[1], p[2]); }
void addForceAtRelPos (dReal fx, dReal fy, dReal fz, void addForceAtRelPos (dReal fx, dReal fy, dReal fz,
dReal px, dReal py, dReal pz) dReal px, dReal py, dReal pz)
{ dBodyAddForceAtRelPos (_id, fx, fy, fz, px, py, pz); } { dBodyAddForceAtRelPos (get_id(), fx, fy, fz, px, py, pz); }
void addForceAtRelPos (const dVector3 f, const dVector3 p) void addForceAtRelPos (const dVector3 f, const dVector3 p)
{ addForceAtRelPos (f[0], f[1], f[2], p[0], p[1], p[2]); } { addForceAtRelPos (f[0], f[1], f[2], p[0], p[1], p[2]); }
void addRelForceAtPos (dReal fx, dReal fy, dReal fz, void addRelForceAtPos (dReal fx, dReal fy, dReal fz,
dReal px, dReal py, dReal pz) dReal px, dReal py, dReal pz)
{ dBodyAddRelForceAtPos (_id, fx, fy, fz, px, py, pz); } { dBodyAddRelForceAtPos (get_id(), fx, fy, fz, px, py, pz); }
void addRelForceAtPos (const dVector3 f, const dVector3 p) void addRelForceAtPos (const dVector3 f, const dVector3 p)
{ addRelForceAtPos (f[0], f[1], f[2], p[0], p[1], p[2]); } { addRelForceAtPos (f[0], f[1], f[2], p[0], p[1], p[2]); }
void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz, void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz,
dReal px, dReal py, dReal pz) dReal px, dReal py, dReal pz)
{ dBodyAddRelForceAtRelPos (_id, fx, fy, fz, px, py, pz); } { dBodyAddRelForceAtRelPos (get_id(), fx, fy, fz, px, py, pz); }
void addRelForceAtRelPos (const dVector3 f, const dVector3 p) void addRelForceAtRelPos (const dVector3 f, const dVector3 p)
{ addRelForceAtRelPos (f[0], f[1], f[2], p[0], p[1], p[2]); } { addRelForceAtRelPos (f[0], f[1], f[2], p[0], p[1], p[2]); }
const dReal * getForce() const const dReal * getForce() const
{ return dBodyGetForce(_id); } { return dBodyGetForce(get_id()); }
const dReal * getTorque() const const dReal * getTorque() const
{ return dBodyGetTorque(_id); } { return dBodyGetTorque(get_id()); }
void setForce (dReal x, dReal y, dReal z) void setForce (dReal x, dReal y, dReal z)
{ dBodySetForce (_id,x,y,z); } { dBodySetForce (get_id(), x, y, z); }
void setForce (const dVector3 f) void setForce (const dVector3 f)
{ setForce (f[0], f[1], f[2]); } { setForce (f[0], f[1], f[2]); }
void setTorque (dReal x, dReal y, dReal z) void setTorque (dReal x, dReal y, dReal z)
{ dBodySetTorque (_id,x,y,z); } { dBodySetTorque (get_id(), x, y, z); }
void setTorque (const dVector3 t) void setTorque (const dVector3 t)
{ setTorque (t[0], t[1], t[2]); } { setTorque (t[0], t[1], t[2]); }
void setDynamic() void setDynamic()
{ dBodySetDynamic (_id); } { dBodySetDynamic (get_id()); }
void setKinematic() void setKinematic()
{ dBodySetKinematic (_id); } { dBodySetKinematic (get_id()); }
bool isKinematic() const bool isKinematic() const
{ return dBodyIsKinematic (_id) != 0; } { return dBodyIsKinematic (get_id()) != 0; }
void enable() void enable()
{ dBodyEnable (_id); } { dBodyEnable (get_id()); }
void disable() void disable()
{ dBodyDisable (_id); } { dBodyDisable (get_id()); }
bool isEnabled() const bool isEnabled() const
{ return dBodyIsEnabled (_id) != 0; } { return dBodyIsEnabled (get_id()) != 0; }
void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const
{ dBodyGetRelPointPos (_id, px, py, pz, result); } { dBodyGetRelPointPos (get_id(), px, py, pz, result); }
void getRelPointPos (const dVector3 p, dVector3 result) const void getRelPointPos (const dVector3 p, dVector3 result) const
{ getRelPointPos (p[0], p[1], p[2], result); } { getRelPointPos (p[0], p[1], p[2], result); }
void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result) const void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result) const
{ dBodyGetRelPointVel (_id, px, py, pz, result); } { dBodyGetRelPointVel (get_id(), px, py, pz, result); }
void getRelPointVel (const dVector3 p, dVector3 result) const void getRelPointVel (const dVector3 p, dVector3 result) const
{ getRelPointVel (p[0], p[1], p[2], result); } { getRelPointVel (p[0], p[1], p[2], result); }
void getPointVel (dReal px, dReal py, dReal pz, dVector3 result) const void getPointVel (dReal px, dReal py, dReal pz, dVector3 result) const
{ dBodyGetPointVel (_id, px, py, pz, result); } { dBodyGetPointVel (get_id(), px, py, pz, result); }
void getPointVel (const dVector3 p, dVector3 result) const void getPointVel (const dVector3 p, dVector3 result) const
{ getPointVel (p[0], p[1], p[2], result); } { getPointVel (p[0], p[1], p[2], result); }
void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const
{ dBodyGetPosRelPoint (_id, px, py, pz, result); } { dBodyGetPosRelPoint (get_id(), px, py, pz, result); }
void getPosRelPoint (const dVector3 p, dVector3 result) const void getPosRelPoint (const dVector3 p, dVector3 result) const
{ getPosRelPoint (p[0], p[1], p[2], result); } { getPosRelPoint (p[0], p[1], p[2], result); }
void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const
{ dBodyVectorToWorld (_id, px, py, pz, result); } { dBodyVectorToWorld (get_id(), px, py, pz, result); }
void vectorToWorld (const dVector3 p, dVector3 result) const void vectorToWorld (const dVector3 p, dVector3 result) const
{ vectorToWorld (p[0], p[1], p[2], result); } { vectorToWorld (p[0], p[1], p[2], result); }
void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) cons t void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) cons t
{ dBodyVectorFromWorld (_id,px,py,pz,result); } { dBodyVectorFromWorld (get_id(), px, py, pz, result); }
void vectorFromWorld (const dVector3 p, dVector3 result) const void vectorFromWorld (const dVector3 p, dVector3 result) const
{ vectorFromWorld (p[0], p[1], p[2], result); } { vectorFromWorld (p[0], p[1], p[2], result); }
void setFiniteRotationMode (bool mode) void setFiniteRotationMode (bool mode)
{ dBodySetFiniteRotationMode (_id, mode); } { dBodySetFiniteRotationMode (get_id(), mode); }
void setFiniteRotationAxis (dReal x, dReal y, dReal z) void setFiniteRotationAxis (dReal x, dReal y, dReal z)
{ dBodySetFiniteRotationAxis (_id, x, y, z); } { dBodySetFiniteRotationAxis (get_id(), x, y, z); }
void setFiniteRotationAxis (const dVector3 a) void setFiniteRotationAxis (const dVector3 a)
{ setFiniteRotationAxis (a[0], a[1], a[2]); } { setFiniteRotationAxis (a[0], a[1], a[2]); }
bool getFiniteRotationMode() const bool getFiniteRotationMode() const
{ return dBodyGetFiniteRotationMode (_id) != 0; } { return dBodyGetFiniteRotationMode (get_id()) != 0; }
void getFiniteRotationAxis (dVector3 result) const void getFiniteRotationAxis (dVector3 result) const
{ dBodyGetFiniteRotationAxis (_id, result); } { dBodyGetFiniteRotationAxis (get_id(), result); }
int getNumJoints() const int getNumJoints() const
{ return dBodyGetNumJoints (_id); } { return dBodyGetNumJoints (get_id()); }
dJointID getJoint (int index) const dJointID getJoint (int index) const
{ return dBodyGetJoint (_id, index); } { return dBodyGetJoint (get_id(), index); }
void setGravityMode (bool mode) void setGravityMode (bool mode)
{ dBodySetGravityMode (_id,mode); } { dBodySetGravityMode (get_id(), mode); }
bool getGravityMode() const bool getGravityMode() const
{ return dBodyGetGravityMode (_id) != 0; } { return dBodyGetGravityMode (get_id()) != 0; }
bool isConnectedTo (dBodyID body) const bool isConnectedTo (dBodyID body) const
{ return dAreConnected (_id, body) != 0; } { return dAreConnected (get_id(), body) != 0; }
void setAutoDisableLinearThreshold (dReal threshold) void setAutoDisableLinearThreshold (dReal threshold)
{ dBodySetAutoDisableLinearThreshold (_id,threshold); } { dBodySetAutoDisableLinearThreshold (get_id(), threshold); }
dReal getAutoDisableLinearThreshold() const dReal getAutoDisableLinearThreshold() const
{ return dBodyGetAutoDisableLinearThreshold (_id); } { return dBodyGetAutoDisableLinearThreshold (get_id()); }
void setAutoDisableAngularThreshold (dReal threshold) void setAutoDisableAngularThreshold (dReal threshold)
{ dBodySetAutoDisableAngularThreshold (_id,threshold); } { dBodySetAutoDisableAngularThreshold (get_id(), threshold); }
dReal getAutoDisableAngularThreshold() const dReal getAutoDisableAngularThreshold() const
{ return dBodyGetAutoDisableAngularThreshold (_id); } { return dBodyGetAutoDisableAngularThreshold (get_id()); }
void setAutoDisableSteps (int steps) void setAutoDisableSteps (int steps)
{ dBodySetAutoDisableSteps (_id,steps); } { dBodySetAutoDisableSteps (get_id(), steps); }
int getAutoDisableSteps() const int getAutoDisableSteps() const
{ return dBodyGetAutoDisableSteps (_id); } { return dBodyGetAutoDisableSteps (get_id()); }
void setAutoDisableTime (dReal time) void setAutoDisableTime (dReal time)
{ dBodySetAutoDisableTime (_id,time); } { dBodySetAutoDisableTime (get_id(), time); }
dReal getAutoDisableTime() const dReal getAutoDisableTime() const
{ return dBodyGetAutoDisableTime (_id); } { return dBodyGetAutoDisableTime (get_id()); }
void setAutoDisableFlag (bool do_auto_disable) void setAutoDisableFlag (bool do_auto_disable)
{ dBodySetAutoDisableFlag (_id,do_auto_disable); } { dBodySetAutoDisableFlag (get_id(), do_auto_disable); }
bool getAutoDisableFlag() const bool getAutoDisableFlag() const
{ return dBodyGetAutoDisableFlag (_id) != 0; } { return dBodyGetAutoDisableFlag (get_id()) != 0; }
dReal getLinearDamping() const dReal getLinearDamping() const
{ return dBodyGetLinearDamping(_id); } { return dBodyGetLinearDamping(get_id()); }
void setLinearDamping(dReal scale) void setLinearDamping(dReal scale)
{ dBodySetLinearDamping(_id, scale); } { dBodySetLinearDamping(get_id(), scale); }
dReal getAngularDamping() const dReal getAngularDamping() const
{ return dBodyGetAngularDamping(_id); } { return dBodyGetAngularDamping(get_id()); }
void setAngularDamping(dReal scale) void setAngularDamping(dReal scale)
{ dBodySetAngularDamping(_id, scale); } { dBodySetAngularDamping(get_id(), scale); }
void setDamping(dReal linear_scale, dReal angular_scale) void setDamping(dReal linear_scale, dReal angular_scale)
{ dBodySetDamping(_id, linear_scale, angular_scale); } { dBodySetDamping(get_id(), linear_scale, angular_scale); }
dReal getLinearDampingThreshold() const dReal getLinearDampingThreshold() const
{ return dBodyGetLinearDampingThreshold(_id); } { return dBodyGetLinearDampingThreshold(get_id()); }
void setLinearDampingThreshold(dReal threshold) const void setLinearDampingThreshold(dReal threshold) const
{ dBodySetLinearDampingThreshold(_id, threshold); } { dBodySetLinearDampingThreshold(get_id(), threshold); }
dReal getAngularDampingThreshold() const dReal getAngularDampingThreshold() const
{ return dBodyGetAngularDampingThreshold(_id); } { return dBodyGetAngularDampingThreshold(get_id()); }
void setAngularDampingThreshold(dReal threshold) void setAngularDampingThreshold(dReal threshold)
{ dBodySetAngularDampingThreshold(_id, threshold); } { dBodySetAngularDampingThreshold(get_id(), threshold); }
void setDampingDefaults() void setDampingDefaults()
{ dBodySetDampingDefaults(_id); } { dBodySetDampingDefaults(get_id()); }
dReal getMaxAngularSpeed() const dReal getMaxAngularSpeed() const
{ return dBodyGetMaxAngularSpeed(_id); } { return dBodyGetMaxAngularSpeed(get_id()); }
void setMaxAngularSpeed(dReal max_speed) void setMaxAngularSpeed(dReal max_speed)
{ dBodySetMaxAngularSpeed(_id, max_speed); } { dBodySetMaxAngularSpeed(get_id(), max_speed); }
bool getGyroscopicMode() const bool getGyroscopicMode() const
{ return dBodyGetGyroscopicMode(_id) != 0; } { return dBodyGetGyroscopicMode(get_id()) != 0; }
void setGyroscopicMode(bool mode) void setGyroscopicMode(bool mode)
{ dBodySetGyroscopicMode(_id, mode); } { dBodySetGyroscopicMode(get_id(), mode); }
}; };
class dJointGroup { class dJointGroupSimpleIDContainer {
dJointGroupID _id; protected:
dJointGroupID _id;
dJointGroupSimpleIDContainer(): _id(0) {}
~dJointGroupSimpleIDContainer() { destroy(); }
void destroy() {
if (_id) {
dJointGroupDestroy(_id);
_id = 0;
}
}
};
class dJointGroupDynamicIDContainer: public dJointGroupSimpleIDContainer {
protected:
virtual ~dJointGroupDynamicIDContainer() {}
};
template <class dJointGroupTemplateBase>
class dJointGroupTemplate: public dJointGroupTemplateBase {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dJointGroup (const dJointGroup &); dJointGroupTemplate (const dJointGroupTemplate<dJointGroupTemplateBase> &
void operator= (const dJointGroup &); );
void operator= (const dJointGroupTemplate<dJointGroupTemplateBase> &);
protected:
dJointGroupID get_id() const { return dJointGroupTemplateBase::_id; }
void set_id(dJointGroupID value) { dJointGroupTemplateBase::_id = value;
}
void destroy() { dJointGroupTemplateBase::destroy(); }
public: public:
dJointGroup () dJointGroupTemplate ()
{ _id = dJointGroupCreate (0); } { set_id(dJointGroupCreate(0)); }
~dJointGroup()
{ dJointGroupDestroy (_id); }
void create () { void create () {
if (_id) dJointGroupDestroy (_id); destroy();
_id = dJointGroupCreate (0); set_id(dJointGroupCreate(0));
} }
dJointGroupID id() const dJointGroupID id() const
{ return _id; } { return get_id(); }
operator dJointGroupID() const operator dJointGroupID() const
{ return _id; } { return get_id(); }
void empty() void empty()
{ dJointGroupEmpty (_id); } { dJointGroupEmpty (get_id()); }
void clear() void clear()
{ empty(); } { empty(); }
}; };
class dJoint { class dJointSimpleIDContainer {
protected:
dJointID _id;
dJointSimpleIDContainer(): _id(0) {}
~dJointSimpleIDContainer() { destroy(); }
void destroy() {
if (_id) {
dJointDestroy (_id);
_id = 0;
}
}
};
class dJointDynamicIDContainer: public dJointSimpleIDContainer {
protected:
virtual ~dJointDynamicIDContainer() {}
};
template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dJointTemplate: public dJointTemplateBase {
private: private:
// intentionally undefined, don't use these // intentionally undefined, don't use these
dJoint (const dJoint &) ; dJointTemplate (const dJointTemplate<dJointTemplateBase, dWorldTemplateBa
void operator= (const dJoint &); se, dBodyTemplateBase> &) ;
void operator= (const dJointTemplate<dJointTemplateBase, dWorldTemplateBa
se, dBodyTemplateBase> &);
protected: protected:
dJointID _id; dJointID get_id() const { return dJointTemplateBase::_id; }
void set_id(dJointID value) { dJointTemplateBase::_id = value; }
dJoint() // don't let user construct pure dJoint objects void destroy() { dJointTemplateBase::destroy(); }
{ _id = 0; }
public: protected:
virtual ~dJoint() // :( Destructor must be virtual to suppress compiler w dJointTemplate() // don't let user construct pure dJointTemplate objects
arning "class XXX has virtual functions but non-virtual destructor" { }
{ if (_id) dJointDestroy (_id); }
public:
dJointID id() const dJointID id() const
{ return _id; } { return get_id(); }
operator dJointID() const operator dJointID() const
{ return _id; } { return get_id(); }
int getNumBodies() const int getNumBodies() const
{ return dJointGetNumBodies(_id); } { return dJointGetNumBodies(get_id()); }
void attach (dBodyID body1, dBodyID body2) void attach (dBodyID body1, dBodyID body2)
{ dJointAttach (_id, body1, body2); } { dJointAttach (get_id(), body1, body2); }
void attach (dBody& body1, dBody& body2) void attach (dBodyTemplate<dBodyTemplateBase, dWorldTemplateBase>& body1,
dBodyTemplate<dBodyTemplateBase, dWorldTemplateBase>& body2)
{ attach(body1.id(), body2.id()); } { attach(body1.id(), body2.id()); }
void enable() void enable()
{ dJointEnable (_id); } { dJointEnable (get_id()); }
void disable() void disable()
{ dJointDisable (_id); } { dJointDisable (get_id()); }
bool isEnabled() const bool isEnabled() const
{ return dJointIsEnabled (_id) != 0; } { return dJointIsEnabled (get_id()) != 0; }
void setData (void *data) void setData (void *data)
{ dJointSetData (_id, data); } { dJointSetData (get_id(), data); }
void *getData() const void *getData() const
{ return dJointGetData (_id); } { return dJointGetData (get_id()); }
dJointType getType() const dJointType getType() const
{ return dJointGetType (_id); } { return dJointGetType (get_id()); }
dBodyID getBody (int index) const dBodyID getBody (int index) const
{ return dJointGetBody (_id, index); } { return dJointGetBody (get_id(), index); }
void setFeedback(dJointFeedback *fb) void setFeedback(dJointFeedback *fb)
{ dJointSetFeedback(_id, fb); } { dJointSetFeedback(get_id(), fb); }
dJointFeedback *getFeedback() const dJointFeedback *getFeedback() const
{ return dJointGetFeedback(_id); } { return dJointGetFeedback(get_id()); }
// If not implemented it will do nothing as describe in the doc // If not implemented it will do nothing as describe in the doc
virtual void setParam (int, dReal) {}; virtual void setParam (int, dReal) {};
virtual dReal getParam (int) const { return 0; } virtual dReal getParam (int) const { return 0; }
}; };
class dBallJoint : public dJoint { template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dBallJointTemplate : public dJointTemplate<dJointTemplateBase, dWorld
TemplateBase, dBodyTemplateBase> {
private: private:
// intentionally undefined, don't use these // intentionally undefined, don't use these
dBallJoint (const dBallJoint &); dBallJointTemplate (const dBallJointTemplate<dJointTemplateBase, dWorldTe
void operator= (const dBallJoint &); mplateBase, dBodyTemplateBase> &);
void operator= (const dBallJointTemplate<dJointTemplateBase, dWorldTempla
teBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dBallJoint() { } dBallJointTemplate() { }
dBallJoint (dWorldID world, dJointGroupID group=0) dBallJointTemplate (dWorldID world, dJointGroupID group=0)
{ _id = dJointCreateBall (world, group); } { set_id(dJointCreateBall(world, group)); }
dBallJoint (dWorld& world, dJointGroupID group=0) dBallJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGrou
{ _id = dJointCreateBall (world.id(), group); } pID group=0)
{ set_id(dJointCreateBall(world.id(), group)); }
void create (dWorldID world, dJointGroupID group=0) { void create (dWorldID world, dJointGroupID group=0) {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreateBall (world, group); set_id(dJointCreateBall(world, group));
} }
void create (dWorld& world, dJointGroupID group=0) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up=0)
{ create(world.id(), group); } { create(world.id(), group); }
void setAnchor (dReal x, dReal y, dReal z) void setAnchor (dReal x, dReal y, dReal z)
{ dJointSetBallAnchor (_id, x, y, z); } { dJointSetBallAnchor (get_id(), x, y, z); }
void setAnchor (const dVector3 a) void setAnchor (const dVector3 a)
{ setAnchor (a[0], a[1], a[2]); } { setAnchor (a[0], a[1], a[2]); }
void getAnchor (dVector3 result) const void getAnchor (dVector3 result) const
{ dJointGetBallAnchor (_id, result); } { dJointGetBallAnchor (get_id(), result); }
void getAnchor2 (dVector3 result) const void getAnchor2 (dVector3 result) const
{ dJointGetBallAnchor2 (_id, result); } { dJointGetBallAnchor2 (get_id(), result); }
virtual void setParam (int parameter, dReal value) virtual void setParam (int parameter, dReal value)
{ dJointSetBallParam (_id, parameter, value); } { dJointSetBallParam (get_id(), parameter, value); }
virtual dReal getParam (int parameter) const virtual dReal getParam (int parameter) const
{ return dJointGetBallParam (_id, parameter); } { return dJointGetBallParam (get_id(), parameter); }
// TODO: expose params through methods // TODO: expose params through methods
} ; } ;
class dHingeJoint : public dJoint { template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dHingeJointTemplate : public dJointTemplate<dJointTemplateBase, dWorl
dTemplateBase, dBodyTemplateBase> {
private:
// intentionally undefined, don't use these // intentionally undefined, don't use these
dHingeJoint (const dHingeJoint &); dHingeJointTemplate (const dHingeJointTemplate<dJointTemplateBase, dWorld
void operator = (const dHingeJoint &); TemplateBase, dBodyTemplateBase> &);
void operator = (const dHingeJointTemplate<dJointTemplateBase, dWorldTemp
lateBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dHingeJoint() { } dHingeJointTemplate() { }
dHingeJoint (dWorldID world, dJointGroupID group=0) dHingeJointTemplate (dWorldID world, dJointGroupID group=0)
{ _id = dJointCreateHinge (world, group); } { set_id(dJointCreateHinge(world, group)); }
dHingeJoint (dWorld& world, dJointGroupID group=0) dHingeJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGro
{ _id = dJointCreateHinge (world.id(), group); } upID group=0)
{ set_id(dJointCreateHinge(world.id(), group)); }
void create (dWorldID world, dJointGroupID group=0) { void create (dWorldID world, dJointGroupID group=0) {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreateHinge (world, group); set_id(dJointCreateHinge (world, group));
} }
void create (dWorld& world, dJointGroupID group=0) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up=0)
{ create(world.id(), group); } { create(world.id(), group); }
void setAnchor (dReal x, dReal y, dReal z) void setAnchor (dReal x, dReal y, dReal z)
{ dJointSetHingeAnchor (_id, x, y, z); } { dJointSetHingeAnchor (get_id(), x, y, z); }
void setAnchor (const dVector3 a) void setAnchor (const dVector3 a)
{ setAnchor (a[0], a[1], a[2]); } { setAnchor (a[0], a[1], a[2]); }
void getAnchor (dVector3 result) const void getAnchor (dVector3 result) const
{ dJointGetHingeAnchor (_id, result); } { dJointGetHingeAnchor (get_id(), result); }
void getAnchor2 (dVector3 result) const void getAnchor2 (dVector3 result) const
{ dJointGetHingeAnchor2 (_id, result); } { dJointGetHingeAnchor2 (get_id(), result); }
void setAxis (dReal x, dReal y, dReal z) void setAxis (dReal x, dReal y, dReal z)
{ dJointSetHingeAxis (_id, x, y, z); } { dJointSetHingeAxis (get_id(), x, y, z); }
void setAxis (const dVector3 a) void setAxis (const dVector3 a)
{ setAxis(a[0], a[1], a[2]); } { setAxis(a[0], a[1], a[2]); }
void getAxis (dVector3 result) const void getAxis (dVector3 result) const
{ dJointGetHingeAxis (_id, result); } { dJointGetHingeAxis (get_id(), result); }
dReal getAngle() const dReal getAngle() const
{ return dJointGetHingeAngle (_id); } { return dJointGetHingeAngle (get_id()); }
dReal getAngleRate() const dReal getAngleRate() const
{ return dJointGetHingeAngleRate (_id); } { return dJointGetHingeAngleRate (get_id()); }
virtual void setParam (int parameter, dReal value) virtual void setParam (int parameter, dReal value)
{ dJointSetHingeParam (_id, parameter, value); } { dJointSetHingeParam (get_id(), parameter, value); }
virtual dReal getParam (int parameter) const virtual dReal getParam (int parameter) const
{ return dJointGetHingeParam (_id, parameter); } { return dJointGetHingeParam (get_id(), parameter); }
// TODO: expose params through methods // TODO: expose params through methods
void addTorque (dReal torque) void addTorque (dReal torque)
{ dJointAddHingeTorque(_id, torque); } { dJointAddHingeTorque(get_id(), torque); }
}; };
class dSliderJoint : public dJoint { template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dSliderJointTemplate : public dJointTemplate<dJointTemplateBase, dWor
ldTemplateBase, dBodyTemplateBase> {
private:
// intentionally undefined, don't use these // intentionally undefined, don't use these
dSliderJoint (const dSliderJoint &); dSliderJointTemplate (const dSliderJointTemplate<dJointTemplateBase, dWor
void operator = (const dSliderJoint &); ldTemplateBase, dBodyTemplateBase> &);
void operator = (const dSliderJointTemplate<dJointTemplateBase, dWorldTem
plateBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dSliderJoint() { } dSliderJointTemplate() { }
dSliderJoint (dWorldID world, dJointGroupID group=0) dSliderJointTemplate (dWorldID world, dJointGroupID group=0)
{ _id = dJointCreateSlider (world, group); } { set_id(dJointCreateSlider(world, group)); }
dSliderJoint (dWorld& world, dJointGroupID group=0) dSliderJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGr
{ _id = dJointCreateSlider (world.id(), group); } oupID group=0)
{ set_id(dJointCreateSlider(world.id(), group)); }
void create (dWorldID world, dJointGroupID group=0) { void create (dWorldID world, dJointGroupID group=0) {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreateSlider (world, group); set_id(dJointCreateSlider(world, group));
} }
void create (dWorld& world, dJointGroupID group=0) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up=0)
{ create(world.id(), group); } { create(world.id(), group); }
void setAxis (dReal x, dReal y, dReal z) void setAxis (dReal x, dReal y, dReal z)
{ dJointSetSliderAxis (_id, x, y, z); } { dJointSetSliderAxis (get_id(), x, y, z); }
void setAxis (const dVector3 a) void setAxis (const dVector3 a)
{ setAxis (a[0], a[1], a[2]); } { setAxis (a[0], a[1], a[2]); }
void getAxis (dVector3 result) const void getAxis (dVector3 result) const
{ dJointGetSliderAxis (_id, result); } { dJointGetSliderAxis (get_id(), result); }
dReal getPosition() const dReal getPosition() const
{ return dJointGetSliderPosition (_id); } { return dJointGetSliderPosition (get_id()); }
dReal getPositionRate() const dReal getPositionRate() const
{ return dJointGetSliderPositionRate (_id); } { return dJointGetSliderPositionRate (get_id()); }
virtual void setParam (int parameter, dReal value) virtual void setParam (int parameter, dReal value)
{ dJointSetSliderParam (_id, parameter, value); } { dJointSetSliderParam (get_id(), parameter, value); }
virtual dReal getParam (int parameter) const virtual dReal getParam (int parameter) const
{ return dJointGetSliderParam (_id, parameter); } { return dJointGetSliderParam (get_id(), parameter); }
// TODO: expose params through methods // TODO: expose params through methods
void addForce (dReal force) void addForce (dReal force)
{ dJointAddSliderForce(_id, force); } { dJointAddSliderForce(get_id(), force); }
}; };
class dUniversalJoint : public dJoint { template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dUniversalJointTemplate : public dJointTemplate<dJointTemplateBase, d
WorldTemplateBase, dBodyTemplateBase> {
private:
// intentionally undefined, don't use these // intentionally undefined, don't use these
dUniversalJoint (const dUniversalJoint &); dUniversalJointTemplate (const dUniversalJointTemplate<dJointTemplateBase
void operator = (const dUniversalJoint &); , dWorldTemplateBase, dBodyTemplateBase> &);
void operator = (const dUniversalJointTemplate<dJointTemplateBase, dWorld
TemplateBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dUniversalJoint() { } dUniversalJointTemplate() { }
dUniversalJoint (dWorldID world, dJointGroupID group=0) dUniversalJointTemplate (dWorldID world, dJointGroupID group=0)
{ _id = dJointCreateUniversal (world, group); } { set_id(dJointCreateUniversal(world, group)); }
dUniversalJoint (dWorld& world, dJointGroupID group=0) dUniversalJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJoin
{ _id = dJointCreateUniversal (world.id(), group); } tGroupID group=0)
{ set_id(dJointCreateUniversal(world.id(), group)); }
void create (dWorldID world, dJointGroupID group=0) { void create (dWorldID world, dJointGroupID group=0) {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreateUniversal (world, group); set_id(dJointCreateUniversal(world, group));
} }
void create (dWorld& world, dJointGroupID group=0) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up=0)
{ create(world.id(), group); } { create(world.id(), group); }
void setAnchor (dReal x, dReal y, dReal z) void setAnchor (dReal x, dReal y, dReal z)
{ dJointSetUniversalAnchor (_id, x, y, z); } { dJointSetUniversalAnchor (get_id(), x, y, z); }
void setAnchor (const dVector3 a) void setAnchor (const dVector3 a)
{ setAnchor(a[0], a[1], a[2]); } { setAnchor(a[0], a[1], a[2]); }
void setAxis1 (dReal x, dReal y, dReal z) void setAxis1 (dReal x, dReal y, dReal z)
{ dJointSetUniversalAxis1 (_id, x, y, z); } { dJointSetUniversalAxis1 (get_id(), x, y, z); }
void setAxis1 (const dVector3 a) void setAxis1 (const dVector3 a)
{ setAxis1 (a[0], a[1], a[2]); } { setAxis1 (a[0], a[1], a[2]); }
void setAxis2 (dReal x, dReal y, dReal z) void setAxis2 (dReal x, dReal y, dReal z)
{ dJointSetUniversalAxis2 (_id, x, y, z); } { dJointSetUniversalAxis2 (get_id(), x, y, z); }
void setAxis2 (const dVector3 a) void setAxis2 (const dVector3 a)
{ setAxis2 (a[0], a[1], a[2]); } { setAxis2 (a[0], a[1], a[2]); }
void getAnchor (dVector3 result) const void getAnchor (dVector3 result) const
{ dJointGetUniversalAnchor (_id, result); } { dJointGetUniversalAnchor (get_id(), result); }
void getAnchor2 (dVector3 result) const void getAnchor2 (dVector3 result) const
{ dJointGetUniversalAnchor2 (_id, result); } { dJointGetUniversalAnchor2 (get_id(), result); }
void getAxis1 (dVector3 result) const void getAxis1 (dVector3 result) const
{ dJointGetUniversalAxis1 (_id, result); } { dJointGetUniversalAxis1 (get_id(), result); }
void getAxis2 (dVector3 result) const void getAxis2 (dVector3 result) const
{ dJointGetUniversalAxis2 (_id, result); } { dJointGetUniversalAxis2 (get_id(), result); }
virtual void setParam (int parameter, dReal value) virtual void setParam (int parameter, dReal value)
{ dJointSetUniversalParam (_id, parameter, value); } { dJointSetUniversalParam (get_id(), parameter, value); }
virtual dReal getParam (int parameter) const virtual dReal getParam (int parameter) const
{ return dJointGetUniversalParam (_id, parameter); } { return dJointGetUniversalParam (get_id(), parameter); }
// TODO: expose params through methods // TODO: expose params through methods
void getAngles(dReal *angle1, dReal *angle2) const void getAngles(dReal *angle1, dReal *angle2) const
{ dJointGetUniversalAngles (_id, angle1, angle2); } { dJointGetUniversalAngles (get_id(), angle1, angle2); }
dReal getAngle1() const dReal getAngle1() const
{ return dJointGetUniversalAngle1 (_id); } { return dJointGetUniversalAngle1 (get_id()); }
dReal getAngle1Rate() const dReal getAngle1Rate() const
{ return dJointGetUniversalAngle1Rate (_id); } { return dJointGetUniversalAngle1Rate (get_id()); }
dReal getAngle2() const dReal getAngle2() const
{ return dJointGetUniversalAngle2 (_id); } { return dJointGetUniversalAngle2 (get_id()); }
dReal getAngle2Rate() const dReal getAngle2Rate() const
{ return dJointGetUniversalAngle2Rate (_id); } { return dJointGetUniversalAngle2Rate (get_id()); }
void addTorques (dReal torque1, dReal torque2) void addTorques (dReal torque1, dReal torque2)
{ dJointAddUniversalTorques(_id, torque1, torque2); } { dJointAddUniversalTorques(get_id(), torque1, torque2); }
}; };
class dHinge2Joint : public dJoint { template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dHinge2JointTemplate : public dJointTemplate<dJointTemplateBase, dWor
ldTemplateBase, dBodyTemplateBase> {
private:
// intentionally undefined, don't use these // intentionally undefined, don't use these
dHinge2Joint (const dHinge2Joint &); dHinge2JointTemplate (const dHinge2JointTemplate<dJointTemplateBase, dWor
void operator = (const dHinge2Joint &); ldTemplateBase, dBodyTemplateBase> &);
void operator = (const dHinge2JointTemplate<dJointTemplateBase, dWorldTem
plateBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dHinge2Joint() { } dHinge2JointTemplate() { }
dHinge2Joint (dWorldID world, dJointGroupID group=0) dHinge2JointTemplate (dWorldID world, dJointGroupID group=0)
{ _id = dJointCreateHinge2 (world, group); } { set_id(dJointCreateHinge2(world, group)); }
dHinge2Joint (dWorld& world, dJointGroupID group=0) dHinge2JointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGr
{ _id = dJointCreateHinge2 (world.id(), group); } oupID group=0)
{ set_id(dJointCreateHinge2(world.id(), group)); }
void create (dWorldID world, dJointGroupID group=0) { void create (dWorldID world, dJointGroupID group=0) {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreateHinge2 (world, group); set_id(dJointCreateHinge2(world, group));
} }
void create (dWorld& world, dJointGroupID group=0) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up=0)
{ create(world.id(), group); } { create(world.id(), group); }
void setAnchor (dReal x, dReal y, dReal z) void setAnchor (dReal x, dReal y, dReal z)
{ dJointSetHinge2Anchor (_id, x, y, z); } { dJointSetHinge2Anchor (get_id(), x, y, z); }
void setAnchor (const dVector3 a) void setAnchor (const dVector3 a)
{ setAnchor(a[0], a[1], a[2]); } { setAnchor(a[0], a[1], a[2]); }
void setAxis1 (dReal x, dReal y, dReal z) void setAxis1 (dReal x, dReal y, dReal z)
{ dJointSetHinge2Axis1 (_id, x, y, z); } { dJointSetHinge2Axis1 (get_id(), x, y, z); }
void setAxis1 (const dVector3 a) void setAxis1 (const dVector3 a)
{ setAxis1 (a[0], a[1], a[2]); } { setAxis1 (a[0], a[1], a[2]); }
void setAxis2 (dReal x, dReal y, dReal z) void setAxis2 (dReal x, dReal y, dReal z)
{ dJointSetHinge2Axis2 (_id, x, y, z); } { dJointSetHinge2Axis2 (get_id(), x, y, z); }
void setAxis2 (const dVector3 a) void setAxis2 (const dVector3 a)
{ setAxis2 (a[0], a[1], a[2]); } { setAxis2 (a[0], a[1], a[2]); }
void getAnchor (dVector3 result) const void getAnchor (dVector3 result) const
{ dJointGetHinge2Anchor (_id, result); } { dJointGetHinge2Anchor (get_id(), result); }
void getAnchor2 (dVector3 result) const void getAnchor2 (dVector3 result) const
{ dJointGetHinge2Anchor2 (_id, result); } { dJointGetHinge2Anchor2 (get_id(), result); }
void getAxis1 (dVector3 result) const void getAxis1 (dVector3 result) const
{ dJointGetHinge2Axis1 (_id, result); } { dJointGetHinge2Axis1 (get_id(), result); }
void getAxis2 (dVector3 result) const void getAxis2 (dVector3 result) const
{ dJointGetHinge2Axis2 (_id, result); } { dJointGetHinge2Axis2 (get_id(), result); }
dReal getAngle1() const dReal getAngle1() const
{ return dJointGetHinge2Angle1 (_id); } { return dJointGetHinge2Angle1 (get_id()); }
dReal getAngle1Rate() const dReal getAngle1Rate() const
{ return dJointGetHinge2Angle1Rate (_id); } { return dJointGetHinge2Angle1Rate (get_id()); }
dReal getAngle2Rate() const dReal getAngle2Rate() const
{ return dJointGetHinge2Angle2Rate (_id); } { return dJointGetHinge2Angle2Rate (get_id()); }
virtual void setParam (int parameter, dReal value) virtual void setParam (int parameter, dReal value)
{ dJointSetHinge2Param (_id, parameter, value); } { dJointSetHinge2Param (get_id(), parameter, value); }
virtual dReal getParam (int parameter) const virtual dReal getParam (int parameter) const
{ return dJointGetHinge2Param (_id, parameter); } { return dJointGetHinge2Param (get_id(), parameter); }
// TODO: expose params through methods // TODO: expose params through methods
void addTorques(dReal torque1, dReal torque2) void addTorques(dReal torque1, dReal torque2)
{ dJointAddHinge2Torques(_id, torque1, torque2); } { dJointAddHinge2Torques(get_id(), torque1, torque2); }
}; };
class dPRJoint : public dJoint { template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
dPRJoint (const dPRJoint &); mplateBase>
void operator = (const dPRJoint &); class dPRJointTemplate : public dJointTemplate<dJointTemplateBase, dWorldTe
mplateBase, dBodyTemplateBase> {
private:
// intentionally undefined, don't use these
dPRJointTemplate (const dPRJointTemplate<dJointTemplateBase, dWorldTempla
teBase, dBodyTemplateBase> &);
void operator = (const dPRJointTemplate<dJointTemplateBase, dWorldTemplat
eBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dPRJoint() { } dPRJointTemplate() { }
dPRJoint (dWorldID world, dJointGroupID group=0) dPRJointTemplate (dWorldID world, dJointGroupID group=0)
{ _id = dJointCreatePR (world, group); } { set_id(dJointCreatePR(world, group)); }
dPRJoint (dWorld& world, dJointGroupID group=0) dPRJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupI
{ _id = dJointCreatePR (world.id(), group); } D group=0)
{ set_id(dJointCreatePR(world.id(), group)); }
void create (dWorldID world, dJointGroupID group=0) { void create (dWorldID world, dJointGroupID group=0) {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreatePR (world, group); set_id(dJointCreatePR(world, group));
} }
void create (dWorld& world, dJointGroupID group=0) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up=0)
{ create(world.id(), group); } { create(world.id(), group); }
void setAnchor (dReal x, dReal y, dReal z) void setAnchor (dReal x, dReal y, dReal z)
{ dJointSetPRAnchor (_id, x, y, z); } { dJointSetPRAnchor (get_id(), x, y, z); }
void setAnchor (const dVector3 a) void setAnchor (const dVector3 a)
{ setAnchor (a[0], a[1], a[2]); } { setAnchor (a[0], a[1], a[2]); }
void setAxis1 (dReal x, dReal y, dReal z) void setAxis1 (dReal x, dReal y, dReal z)
{ dJointSetPRAxis1 (_id, x, y, z); } { dJointSetPRAxis1 (get_id(), x, y, z); }
void setAxis1 (const dVector3 a) void setAxis1 (const dVector3 a)
{ setAxis1(a[0], a[1], a[2]); } { setAxis1(a[0], a[1], a[2]); }
void setAxis2 (dReal x, dReal y, dReal z) void setAxis2 (dReal x, dReal y, dReal z)
{ dJointSetPRAxis2 (_id, x, y, z); } { dJointSetPRAxis2 (get_id(), x, y, z); }
void setAxis2 (const dVector3 a) void setAxis2 (const dVector3 a)
{ setAxis2(a[0], a[1], a[2]); } { setAxis2(a[0], a[1], a[2]); }
void getAnchor (dVector3 result) const void getAnchor (dVector3 result) const
{ dJointGetPRAnchor (_id, result); } { dJointGetPRAnchor (get_id(), result); }
void getAxis1 (dVector3 result) const void getAxis1 (dVector3 result) const
{ dJointGetPRAxis1 (_id, result); } { dJointGetPRAxis1 (get_id(), result); }
void getAxis2 (dVector3 result) const void getAxis2 (dVector3 result) const
{ dJointGetPRAxis2 (_id, result); } { dJointGetPRAxis2 (get_id(), result); }
dReal getPosition() const dReal getPosition() const
{ return dJointGetPRPosition (_id); } { return dJointGetPRPosition (get_id()); }
dReal getPositionRate() const dReal getPositionRate() const
{ return dJointGetPRPositionRate (_id); } { return dJointGetPRPositionRate (get_id()); }
dReal getAngle() const dReal getAngle() const
{ return dJointGetPRAngle (_id); } { return dJointGetPRAngle (get_id()); }
dReal getAngleRate() const dReal getAngleRate() const
{ return dJointGetPRAngleRate (_id); } { return dJointGetPRAngleRate (get_id()); }
virtual void setParam (int parameter, dReal value) virtual void setParam (int parameter, dReal value)
{ dJointSetPRParam (_id, parameter, value); } { dJointSetPRParam (get_id(), parameter, value); }
virtual dReal getParam (int parameter) const virtual dReal getParam (int parameter) const
{ return dJointGetPRParam (_id, parameter); } { return dJointGetPRParam (get_id(), parameter); }
}; };
class dPUJoint : public dJoint template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dPUJointTemplate : public dJointTemplate<dJointTemplateBase, dWorldTe
mplateBase, dBodyTemplateBase>
{ {
dPUJoint (const dPUJoint &); private:
void operator = (const dPUJoint &); // intentionally undefined, don't use these
dPUJointTemplate (const dPUJointTemplate<dJointTemplateBase, dWorldTempla
teBase, dBodyTemplateBase> &);
void operator = (const dPUJointTemplate<dJointTemplateBase, dWorldTemplat
eBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dPUJoint() { } dPUJointTemplate() { }
dPUJoint (dWorldID world, dJointGroupID group=0) dPUJointTemplate (dWorldID world, dJointGroupID group=0)
{ _id = dJointCreatePU (world, group); } { set_id(dJointCreatePU(world, group)); }
dPUJoint (dWorld& world, dJointGroupID group=0) dPUJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupI
{ _id = dJointCreatePU (world.id(), group); } D group=0)
{ set_id(dJointCreatePU(world.id(), group)); }
void create (dWorldID world, dJointGroupID group=0) void create (dWorldID world, dJointGroupID group=0)
{ {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreatePU (world, group); set_id(dJointCreatePU(world, group));
} }
void create (dWorld& world, dJointGroupID group=0) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up=0)
{ create(world.id(), group); } { create(world.id(), group); }
void setAnchor (dReal x, dReal y, dReal z) void setAnchor (dReal x, dReal y, dReal z)
{ dJointSetPUAnchor (_id, x, y, z); } { dJointSetPUAnchor (get_id(), x, y, z); }
void setAnchor (const dVector3 a) void setAnchor (const dVector3 a)
{ setAnchor (a[0], a[1], a[2]); } { setAnchor (a[0], a[1], a[2]); }
void setAxis1 (dReal x, dReal y, dReal z) void setAxis1 (dReal x, dReal y, dReal z)
{ dJointSetPUAxis1 (_id, x, y, z); } { dJointSetPUAxis1 (get_id(), x, y, z); }
void setAxis1 (const dVector3 a) void setAxis1 (const dVector3 a)
{ setAxis1(a[0], a[1], a[2]); } { setAxis1(a[0], a[1], a[2]); }
void setAxis2 (dReal x, dReal y, dReal z) void setAxis2 (dReal x, dReal y, dReal z)
{ dJointSetPUAxis2 (_id, x, y, z); } { dJointSetPUAxis2 (get_id(), x, y, z); }
void setAxis3 (dReal x, dReal y, dReal z) void setAxis3 (dReal x, dReal y, dReal z)
{ dJointSetPUAxis3 (_id, x, y, z); } { dJointSetPUAxis3 (get_id(), x, y, z); }
void setAxis3 (const dVector3 a) void setAxis3 (const dVector3 a)
{ setAxis3(a[0], a[1], a[2]); } { setAxis3(a[0], a[1], a[2]); }
void setAxisP (dReal x, dReal y, dReal z) void setAxisP (dReal x, dReal y, dReal z)
{ dJointSetPUAxis3 (_id, x, y, z); } { dJointSetPUAxis3 (get_id(), x, y, z); }
void setAxisP (const dVector3 a) void setAxisP (const dVector3 a)
{ setAxisP(a[0], a[1], a[2]); } { setAxisP(a[0], a[1], a[2]); }
virtual void getAnchor (dVector3 result) const virtual void getAnchor (dVector3 result) const
{ dJointGetPUAnchor (_id, result); } { dJointGetPUAnchor (get_id(), result); }
void getAxis1 (dVector3 result) const void getAxis1 (dVector3 result) const
{ dJointGetPUAxis1 (_id, result); } { dJointGetPUAxis1 (get_id(), result); }
void getAxis2 (dVector3 result) const void getAxis2 (dVector3 result) const
{ dJointGetPUAxis2 (_id, result); } { dJointGetPUAxis2 (get_id(), result); }
void getAxis3 (dVector3 result) const void getAxis3 (dVector3 result) const
{ dJointGetPUAxis3 (_id, result); } { dJointGetPUAxis3 (get_id(), result); }
void getAxisP (dVector3 result) const void getAxisP (dVector3 result) const
{ dJointGetPUAxis3 (_id, result); } { dJointGetPUAxis3 (get_id(), result); }
dReal getAngle1() const dReal getAngle1() const
{ return dJointGetPUAngle1 (_id); } { return dJointGetPUAngle1 (get_id()); }
dReal getAngle1Rate() const dReal getAngle1Rate() const
{ return dJointGetPUAngle1Rate (_id); } { return dJointGetPUAngle1Rate (get_id()); }
dReal getAngle2() const dReal getAngle2() const
{ return dJointGetPUAngle2 (_id); } { return dJointGetPUAngle2 (get_id()); }
dReal getAngle2Rate() const dReal getAngle2Rate() const
{ return dJointGetPUAngle2Rate (_id); } { return dJointGetPUAngle2Rate (get_id()); }
dReal getPosition() const dReal getPosition() const
{ return dJointGetPUPosition (_id); } { return dJointGetPUPosition (get_id()); }
dReal getPositionRate() const dReal getPositionRate() const
{ return dJointGetPUPositionRate (_id); } { return dJointGetPUPositionRate (get_id()); }
virtual void setParam (int parameter, dReal value) virtual void setParam (int parameter, dReal value)
{ dJointSetPUParam (_id, parameter, value); } { dJointSetPUParam (get_id(), parameter, value); }
virtual dReal getParam (int parameter) const virtual dReal getParam (int parameter) const
{ return dJointGetPUParam (_id, parameter); } { return dJointGetPUParam (get_id(), parameter); }
// TODO: expose params through methods // TODO: expose params through methods
}; };
class dPistonJoint : public dJoint template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dPistonJointTemplate : public dJointTemplate<dJointTemplateBase, dWor
ldTemplateBase, dBodyTemplateBase>
{ {
private:
// intentionally undefined, don't use these // intentionally undefined, don't use these
dPistonJoint (const dPistonJoint &); dPistonJointTemplate (const dPistonJointTemplate<dJointTemplateBase, dWor
void operator = (const dPistonJoint &); ldTemplateBase, dBodyTemplateBase> &);
void operator = (const dPistonJointTemplate<dJointTemplateBase, dWorldTem
plateBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dPistonJoint() { } dPistonJointTemplate() { }
dPistonJoint (dWorldID world, dJointGroupID group=0) dPistonJointTemplate (dWorldID world, dJointGroupID group=0)
{ _id = dJointCreatePiston (world, group); } { set_id(dJointCreatePiston(world, group)); }
dPistonJoint (dWorld& world, dJointGroupID group=0) dPistonJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGr
{ _id = dJointCreatePiston (world, group); } oupID group=0)
{ set_id(dJointCreatePiston(world, group)); }
void create (dWorldID world, dJointGroupID group=0) void create (dWorldID world, dJointGroupID group=0)
{ {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreatePiston (world, group); set_id(dJointCreatePiston(world, group));
} }
void create (dWorld& world, dJointGroupID group=0) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up=0)
{ create(world.id(), group); } { create(world.id(), group); }
void setAnchor (dReal x, dReal y, dReal z) void setAnchor (dReal x, dReal y, dReal z)
{ dJointSetPistonAnchor (_id, x, y, z); } { dJointSetPistonAnchor (get_id(), x, y, z); }
void setAnchor (const dVector3 a) void setAnchor (const dVector3 a)
{ setAnchor (a[0], a[1], a[2]); } { setAnchor (a[0], a[1], a[2]); }
void getAnchor (dVector3 result) const void getAnchor (dVector3 result) const
{ dJointGetPistonAnchor (_id, result); } { dJointGetPistonAnchor (get_id(), result); }
void getAnchor2 (dVector3 result) const void getAnchor2 (dVector3 result) const
{ dJointGetPistonAnchor2 (_id, result); } { dJointGetPistonAnchor2 (get_id(), result); }
void setAxis (dReal x, dReal y, dReal z) void setAxis (dReal x, dReal y, dReal z)
{ dJointSetPistonAxis (_id, x, y, z); } { dJointSetPistonAxis (get_id(), x, y, z); }
void setAxis (const dVector3 a) void setAxis (const dVector3 a)
{ setAxis(a[0], a[1], a[2]); } { setAxis(a[0], a[1], a[2]); }
void getAxis (dVector3 result) const void getAxis (dVector3 result) const
{ dJointGetPistonAxis (_id, result); } { dJointGetPistonAxis (get_id(), result); }
dReal getPosition() const dReal getPosition() const
{ return dJointGetPistonPosition (_id); } { return dJointGetPistonPosition (get_id()); }
dReal getPositionRate() const dReal getPositionRate() const
{ return dJointGetPistonPositionRate (_id); } { return dJointGetPistonPositionRate (get_id()); }
virtual void setParam (int parameter, dReal value) virtual void setParam (int parameter, dReal value)
{ dJointSetPistonParam (_id, parameter, value); } { dJointSetPistonParam (get_id(), parameter, value); }
virtual dReal getParam (int parameter) const virtual dReal getParam (int parameter) const
{ return dJointGetPistonParam (_id, parameter); } { return dJointGetPistonParam (get_id(), parameter); }
// TODO: expose params through methods // TODO: expose params through methods
void addForce (dReal force) void addForce (dReal force)
{ dJointAddPistonForce (_id, force); } { dJointAddPistonForce (get_id(), force); }
}; };
class dFixedJoint : public dJoint template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dFixedJointTemplate : public dJointTemplate<dJointTemplateBase, dWorl
dTemplateBase, dBodyTemplateBase>
{ {
private:
// intentionally undefined, don't use these // intentionally undefined, don't use these
dFixedJoint (const dFixedJoint &); dFixedJointTemplate (const dFixedJointTemplate<dJointTemplateBase, dWorld
void operator = (const dFixedJoint &); TemplateBase, dBodyTemplateBase> &);
void operator = (const dFixedJointTemplate<dJointTemplateBase, dWorldTemp
lateBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dFixedJoint() { } dFixedJointTemplate() { }
dFixedJoint (dWorldID world, dJointGroupID group=0) dFixedJointTemplate (dWorldID world, dJointGroupID group=0)
{ _id = dJointCreateFixed (world, group); } { set_id(dJointCreateFixed(world, group)); }
dFixedJoint (dWorld& world, dJointGroupID group=0) dFixedJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGro
{ _id = dJointCreateFixed (world, group); } upID group=0)
{ set_id(dJointCreateFixed(world, group)); }
void create (dWorldID world, dJointGroupID group=0) { void create (dWorldID world, dJointGroupID group=0) {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreateFixed (world, group); set_id(dJointCreateFixed(world, group));
} }
void create (dWorld& world, dJointGroupID group=0) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up=0)
{ create(world.id(), group); } { create(world.id(), group); }
void set() void set()
{ dJointSetFixed (_id); } { dJointSetFixed (get_id()); }
virtual void setParam (int parameter, dReal value) virtual void setParam (int parameter, dReal value)
{ dJointSetFixedParam (_id, parameter, value); } { dJointSetFixedParam (get_id(), parameter, value); }
virtual dReal getParam (int parameter) const virtual dReal getParam (int parameter) const
{ return dJointGetFixedParam (_id, parameter); } { return dJointGetFixedParam (get_id(), parameter); }
// TODO: expose params through methods // TODO: expose params through methods
}; };
class dContactJoint : public dJoint { template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dContactJointTemplate : public dJointTemplate<dJointTemplateBase, dWo
rldTemplateBase, dBodyTemplateBase> {
private:
// intentionally undefined, don't use these // intentionally undefined, don't use these
dContactJoint (const dContactJoint &); dContactJointTemplate (const dContactJointTemplate<dJointTemplateBase, dW
void operator = (const dContactJoint &); orldTemplateBase, dBodyTemplateBase> &);
void operator = (const dContactJointTemplate<dJointTemplateBase, dWorldTe
mplateBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dContactJoint() { } dContactJointTemplate() { }
dContactJoint (dWorldID world, dJointGroupID group, dContact *contact) dContactJointTemplate (dWorldID world, dJointGroupID group, dContact *con
{ _id = dJointCreateContact (world, group, contact); } tact)
dContactJoint (dWorld& world, dJointGroupID group, dContact *contact) { set_id(dJointCreateContact(world, group, contact)); }
{ _id = dJointCreateContact (world.id(), group, contact); } dContactJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointG
roupID group, dContact *contact)
{ set_id(dJointCreateContact(world.id(), group, contact)); }
void create (dWorldID world, dJointGroupID group, dContact *contact) { void create (dWorldID world, dJointGroupID group, dContact *contact) {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreateContact (world, group, contact); set_id(dJointCreateContact(world, group, contact));
} }
void create (dWorld& world, dJointGroupID group, dContact *contact) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up, dContact *contact)
{ create(world.id(), group, contact); } { create(world.id(), group, contact); }
}; };
class dNullJoint : public dJoint { template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dNullJointTemplate : public dJointTemplate<dJointTemplateBase, dWorld
TemplateBase, dBodyTemplateBase> {
private:
// intentionally undefined, don't use these // intentionally undefined, don't use these
dNullJoint (const dNullJoint &); dNullJointTemplate (const dNullJointTemplate<dJointTemplateBase, dWorldTe
void operator = (const dNullJoint &); mplateBase, dBodyTemplateBase> &);
void operator = (const dNullJointTemplate<dJointTemplateBase, dWorldTempl
ateBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dNullJoint() { } dNullJointTemplate() { }
dNullJoint (dWorldID world, dJointGroupID group=0) dNullJointTemplate (dWorldID world, dJointGroupID group=0)
{ _id = dJointCreateNull (world, group); } { set_id(dJointCreateNull(world, group)); }
dNullJoint (dWorld& world, dJointGroupID group=0) dNullJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGrou
{ _id = dJointCreateNull (world.id(), group); } pID group=0)
{ set_id(dJointCreateNull (world.id(), group)); }
void create (dWorldID world, dJointGroupID group=0) { void create (dWorldID world, dJointGroupID group=0) {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreateNull (world, group); set_id(dJointCreateNull(world, group));
} }
void create (dWorld& world, dJointGroupID group=0) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up=0)
{ create(world.id(), group); } { create(world.id(), group); }
}; };
class dAMotorJoint : public dJoint { template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dAMotorJointTemplate : public dJointTemplate<dJointTemplateBase, dWor
ldTemplateBase, dBodyTemplateBase> {
private:
// intentionally undefined, don't use these // intentionally undefined, don't use these
dAMotorJoint (const dAMotorJoint &); dAMotorJointTemplate (const dAMotorJointTemplate<dJointTemplateBase, dWor
void operator = (const dAMotorJoint &); ldTemplateBase, dBodyTemplateBase> &);
void operator = (const dAMotorJointTemplate<dJointTemplateBase, dWorldTem
plateBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dAMotorJoint() { } dAMotorJointTemplate() { }
dAMotorJoint (dWorldID world, dJointGroupID group=0) dAMotorJointTemplate (dWorldID world, dJointGroupID group=0)
{ _id = dJointCreateAMotor (world, group); } { set_id(dJointCreateAMotor(world, group)); }
dAMotorJoint (dWorld& world, dJointGroupID group=0) dAMotorJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGr
{ _id = dJointCreateAMotor (world.id(), group); } oupID group=0)
{ set_id(dJointCreateAMotor(world.id(), group)); }
void create (dWorldID world, dJointGroupID group=0) { void create (dWorldID world, dJointGroupID group=0) {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreateAMotor (world, group); set_id(dJointCreateAMotor(world, group));
} }
void create (dWorld& world, dJointGroupID group=0) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up=0)
{ create(world.id(), group); } { create(world.id(), group); }
void setMode (int mode) void setMode (int mode)
{ dJointSetAMotorMode (_id, mode); } { dJointSetAMotorMode (get_id(), mode); }
int getMode() const int getMode() const
{ return dJointGetAMotorMode (_id); } { return dJointGetAMotorMode (get_id()); }
void setNumAxes (int num) void setNumAxes (int num)
{ dJointSetAMotorNumAxes (_id, num); } { dJointSetAMotorNumAxes (get_id(), num); }
int getNumAxes() const int getNumAxes() const
{ return dJointGetAMotorNumAxes (_id); } { return dJointGetAMotorNumAxes (get_id()); }
void setAxis (int anum, int rel, dReal x, dReal y, dReal z) void setAxis (int anum, int rel, dReal x, dReal y, dReal z)
{ dJointSetAMotorAxis (_id, anum, rel, x, y, z); } { dJointSetAMotorAxis (get_id(), anum, rel, x, y, z); }
void setAxis (int anum, int rel, const dVector3 a) void setAxis (int anum, int rel, const dVector3 a)
{ setAxis(anum, rel, a[0], a[1], a[2]); } { setAxis(anum, rel, a[0], a[1], a[2]); }
void getAxis (int anum, dVector3 result) const void getAxis (int anum, dVector3 result) const
{ dJointGetAMotorAxis (_id, anum, result); } { dJointGetAMotorAxis (get_id(), anum, result); }
int getAxisRel (int anum) const int getAxisRel (int anum) const
{ return dJointGetAMotorAxisRel (_id, anum); } { return dJointGetAMotorAxisRel (get_id(), anum); }
void setAngle (int anum, dReal angle) void setAngle (int anum, dReal angle)
{ dJointSetAMotorAngle (_id, anum, angle); } { dJointSetAMotorAngle (get_id(), anum, angle); }
dReal getAngle (int anum) const dReal getAngle (int anum) const
{ return dJointGetAMotorAngle (_id, anum); } { return dJointGetAMotorAngle (get_id(), anum); }
dReal getAngleRate (int anum) dReal getAngleRate (int anum)
{ return dJointGetAMotorAngleRate (_id,anum); } { return dJointGetAMotorAngleRate (get_id(), anum); }
void setParam (int parameter, dReal value) void setParam (int parameter, dReal value)
{ dJointSetAMotorParam (_id, parameter, value); } { dJointSetAMotorParam (get_id(), parameter, value); }
dReal getParam (int parameter) const dReal getParam (int parameter) const
{ return dJointGetAMotorParam (_id, parameter); } { return dJointGetAMotorParam (get_id(), parameter); }
// TODO: expose params through methods // TODO: expose params through methods
void addTorques(dReal torque1, dReal torque2, dReal torque3) void addTorques(dReal torque1, dReal torque2, dReal torque3)
{ dJointAddAMotorTorques(_id, torque1, torque2, torque3); } { dJointAddAMotorTorques(get_id(), torque1, torque2, torque3); }
}; };
class dLMotorJoint : public dJoint { template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe
mplateBase>
class dLMotorJointTemplate : public dJointTemplate<dJointTemplateBase, dWor
ldTemplateBase, dBodyTemplateBase> {
private:
// intentionally undefined, don't use these // intentionally undefined, don't use these
dLMotorJoint (const dLMotorJoint &); dLMotorJointTemplate (const dLMotorJointTemplate<dJointTemplateBase, dWor
void operator = (const dLMotorJoint &); ldTemplateBase, dBodyTemplateBase> &);
void operator = (const dLMotorJointTemplate<dJointTemplateBase, dWorldTem
plateBase, dBodyTemplateBase> &);
protected:
typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl
ateBase> dBaseTemplate;
dJointID get_id() const { return dBaseTemplate::get_id(); }
void set_id(dJointID value) { dBaseTemplate::set_id(value); }
void destroy() { dBaseTemplate::destroy(); }
public: public:
dLMotorJoint() { } dLMotorJointTemplate() { }
dLMotorJoint (dWorldID world, dJointGroupID group=0) dLMotorJointTemplate (dWorldID world, dJointGroupID group=0)
{ _id = dJointCreateLMotor (world, group); } { set_id(dJointCreateLMotor(world, group)); }
dLMotorJoint (dWorld& world, dJointGroupID group=0) dLMotorJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGr
{ _id = dJointCreateLMotor (world.id(), group); } oupID group=0)
{ set_id(dJointCreateLMotor(world.id(), group)); }
void create (dWorldID world, dJointGroupID group=0) { void create (dWorldID world, dJointGroupID group=0) {
if (_id) dJointDestroy (_id); destroy();
_id = dJointCreateLMotor (world, group); set_id(dJointCreateLMotor(world, group));
} }
void create (dWorld& world, dJointGroupID group=0) void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro up=0)
{ create(world.id(), group); } { create(world.id(), group); }
void setNumAxes (int num) void setNumAxes (int num)
{ dJointSetLMotorNumAxes (_id, num); } { dJointSetLMotorNumAxes (get_id(), num); }
int getNumAxes() const int getNumAxes() const
{ return dJointGetLMotorNumAxes (_id); } { return dJointGetLMotorNumAxes (get_id()); }
void setAxis (int anum, int rel, dReal x, dReal y, dReal z) void setAxis (int anum, int rel, dReal x, dReal y, dReal z)
{ dJointSetLMotorAxis (_id, anum, rel, x, y, z); } { dJointSetLMotorAxis (get_id(), anum, rel, x, y, z); }
void setAxis (int anum, int rel, const dVector3 a) void setAxis (int anum, int rel, const dVector3 a)
{ setAxis(anum, rel, a[0], a[1], a[2]); } { setAxis(anum, rel, a[0], a[1], a[2]); }
void getAxis (int anum, dVector3 result) const void getAxis (int anum, dVector3 result) const
{ dJointGetLMotorAxis (_id, anum, result); } { dJointGetLMotorAxis (get_id(), anum, result); }
void setParam (int parameter, dReal value) void setParam (int parameter, dReal value)
{ dJointSetLMotorParam (_id, parameter, value); } { dJointSetLMotorParam (get_id(), parameter, value); }
dReal getParam (int parameter) const dReal getParam (int parameter) const
{ return dJointGetLMotorParam (_id, parameter); } { return dJointGetLMotorParam (get_id(), parameter); }
// TODO: expose params through methods // TODO: expose params through methods
}; };
//} //}
#if !defined(dODECPP_WORLD_TEMPLATE_BASE)
#if defined(dODECPP_BODY_TEMPLATE_BASE) || defined(dODECPP_JOINTGROUP_TEMPL
ATE_BASE) || defined(dODECPP_JOINT_TEMPLATE_BASE)
#error All the odecpp template bases must be defined or not defined togethe
r
#endif
#define dODECPP_WORLD_TEMPLATE_BASE dWorldDynamicIDContainer
#define dODECPP_BODY_TEMPLATE_BASE dBodyDynamicIDContainer
#define dODECPP_JOINTGROUP_TEMPLATE_BASE dJointGroupDynamicIDContainer
#define dODECPP_JOINT_TEMPLATE_BASE dJointDynamicIDContainer
#else // #if defined(dODECPP_WORLD_TEMPLATE_BASE)
#if !defined(dODECPP_BODY_TEMPLATE_BASE) || !defined(dODECPP_JOINTGROUP_TEM
PLATE_BASE) || !defined(dODECPP_JOINT_TEMPLATE_BASE)
#error All the odecpp template bases must be defined or not defined togethe
r
#endif
#endif // #if defined(dODECPP_WORLD_TEMPLATE_BASE)
typedef dWorldTemplate<dODECPP_WORLD_TEMPLATE_BASE> dWorld;
typedef dBodyTemplate<dODECPP_BODY_TEMPLATE_BASE, dODECPP_WORLD_TEMPLATE_BA
SE> dBody;
typedef dJointGroupTemplate<dODECPP_JOINTGROUP_TEMPLATE_BASE> dJointGroup;
typedef dJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMPLATE_
BASE, dODECPP_BODY_TEMPLATE_BASE> dJoint;
typedef dBallJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMPL
ATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dBallJoint;
typedef dHingeJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMP
LATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dHingeJoint;
typedef dSliderJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEM
PLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dSliderJoint;
typedef dUniversalJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_
TEMPLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dUniversalJoint;
typedef dHinge2JointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEM
PLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dHinge2Joint;
typedef dPRJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMPLAT
E_BASE, dODECPP_BODY_TEMPLATE_BASE> dPRJoint;
typedef dPUJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMPLAT
E_BASE, dODECPP_BODY_TEMPLATE_BASE> dPUJoint;
typedef dPistonJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEM
PLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dPistonJoint;
typedef dFixedJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMP
LATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dFixedJoint;
typedef dContactJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TE
MPLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dContactJoint;
typedef dNullJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMPL
ATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dNullJoint;
typedef dAMotorJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEM
PLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dAMotorJoint;
typedef dLMotorJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEM
PLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dLMotorJoint;
#endif #endif
#endif #endif
// Local variables: // Local variables:
// mode:c++ // mode:c++
// c-basic-offset:2 // c-basic-offset:2
// End: // End:
 End of changes. 328 change blocks. 
435 lines changed or deleted 792 lines changed or added


 odecpp_collision.h   odecpp_collision.h 
skipping to change at line 110 skipping to change at line 110
unsigned long getCollideBits() unsigned long getCollideBits()
{ return dGeomGetCollideBits (_id); } { return dGeomGetCollideBits (_id); }
void enable() void enable()
{ dGeomEnable (_id); } { dGeomEnable (_id); }
void disable() void disable()
{ dGeomDisable (_id); } { dGeomDisable (_id); }
int isEnabled() int isEnabled()
{ return dGeomIsEnabled (_id); } { return dGeomIsEnabled (_id); }
void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomGetRelPointPos (_id, px, py, pz, result); }
void getRelPointPos (const dVector3 p, dVector3 result) const
{ getRelPointPos (p[0], p[1], p[2], result); }
void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomGetPosRelPoint (_id, px, py, pz, result); }
void getPosRelPoint (const dVector3 p, dVector3 result) const
{ getPosRelPoint (p[0], p[1], p[2], result); }
void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomVectorToWorld (_id, px, py, pz, result); }
void vectorToWorld (const dVector3 p, dVector3 result) const
{ vectorToWorld (p[0], p[1], p[2], result); }
void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) cons
t
{ dGeomVectorFromWorld (_id, px, py, pz, result); }
void vectorFromWorld (const dVector3 p, dVector3 result) const
{ vectorFromWorld (p[0], p[1], p[2], result); }
void collide2 (dGeomID g, void *data, dNearCallback *callback) void collide2 (dGeomID g, void *data, dNearCallback *callback)
{ dSpaceCollide2 (_id,g,data,callback); } { dSpaceCollide2 (_id,g,data,callback); }
}; };
class dSpace : public dGeom { class dSpace : public dGeom {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dSpace (dSpace &); dSpace (dSpace &);
void operator= (dSpace &); void operator= (dSpace &);
protected: protected:
 End of changes. 1 change blocks. 
0 lines changed or deleted 21 lines changed or added


 odeinit.h   odeinit.h 
skipping to change at line 74 skipping to change at line 74
* If @c dInitFlagManualThreadCleanup was not specified during initializati on, * If @c dInitFlagManualThreadCleanup was not specified during initializati on,
* calls to @c dCleanupODEAllDataForThread are not allowed. * calls to @c dCleanupODEAllDataForThread are not allowed.
* *
* @see dInitODE2 * @see dInitODE2
* @see dAllocateODEDataForThread * @see dAllocateODEDataForThread
* @see dSpaceSetManualCleanup * @see dSpaceSetManualCleanup
* @see dCloseODE * @see dCloseODE
* @ingroup init * @ingroup init
*/ */
enum dInitODEFlags { enum dInitODEFlags {
dInitFlagManualThreadCleanup = 0x00000001, //@< Thread local data is to be cleared explicitly on @c dCleanupODEAllDataForThread function call dInitFlagManualThreadCleanup = 0x00000001 //@< Thread local data is to be cleared explicitly on @c dCleanupODEAllDataForThread function call
}; };
/** /**
* @brief Initializes ODE library. * @brief Initializes ODE library.
* *
* @c dInitODE is obsolete. @c dInitODE2 is to be used for library initiali zation. * @c dInitODE is obsolete. @c dInitODE2 is to be used for library initiali zation.
* *
* A call to @c dInitODE is equal to the following initialization sequence * A call to @c dInitODE is equal to the following initialization sequence
* @code * @code
* dInitODE2(0); * dInitODE2(0);
skipping to change at line 147 skipping to change at line 147
* applications should use explicit flags they need rather than allocating everything. * applications should use explicit flags they need rather than allocating everything.
* *
* @see dAllocateODEDataForThread * @see dAllocateODEDataForThread
* @ingroup init * @ingroup init
*/ */
enum dAllocateODEDataFlags { enum dAllocateODEDataFlags {
dAllocateFlagBasicData = 0, //@< Allocate basic data required for li brary to operate dAllocateFlagBasicData = 0, //@< Allocate basic data required for li brary to operate
dAllocateFlagCollisionData = 0x00000001, //@< Allocate data for coll ision detection dAllocateFlagCollisionData = 0x00000001, //@< Allocate data for coll ision detection
dAllocateMaskAll = ~0U, //@< Allocate all the possible data that is currently defined or will be defined in the future. dAllocateMaskAll = ~0U //@< Allocate all the possible data that is c urrently defined or will be defined in the future.
}; };
/** /**
* @brief Allocate thread local data to allow the thread calling ODE. * @brief Allocate thread local data to allow the thread calling ODE.
* @param uiAllocateFlags Allocation options bitmask. * @param uiAllocateFlags Allocation options bitmask.
* @return A nonzero if allocation succeeded and zero otherwise. * @return A nonzero if allocation succeeded and zero otherwise.
* *
* The function is required to be called for every thread that is going to use * The function is required to be called for every thread that is going to use
* ODE. This function allocates the data that is required for accessing ODE from * ODE. This function allocates the data that is required for accessing ODE from
* current thread along with optional data required for particular ODE subs ystems. * current thread along with optional data required for particular ODE subs ystems.
skipping to change at line 225 skipping to change at line 225
* before calling @c dCloseODE. In particular it is not allowed to call * before calling @c dCloseODE. In particular it is not allowed to call
* @c dCleanupODEAllDataForThread after @c dCloseODE. * @c dCleanupODEAllDataForThread after @c dCloseODE.
* *
* @see dInitODE2 * @see dInitODE2
* @see dCleanupODEAllDataForThread * @see dCleanupODEAllDataForThread
* @ingroup init * @ingroup init
*/ */
ODE_API void dCloseODE(void); ODE_API void dCloseODE(void);
#ifdef __cplusplus #ifdef __cplusplus
}; // extern "C" } // extern "C"
#endif #endif
#endif // _ODE_ODEINIT_H_ #endif // _ODE_ODEINIT_H_
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 odemath.h   odemath.h 
skipping to change at line 28 skipping to change at line 28
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_ODEMATH_H_ #ifndef _ODE_ODEMATH_H_
#define _ODE_ODEMATH_H_ #define _ODE_ODEMATH_H_
#include <ode/common.h> #include <ode/common.h>
#ifdef __GNUC__
#define PURE_INLINE extern inline
#else
#define PURE_INLINE inline
#endif
/* /*
* macro to access elements i,j in an NxM matrix A, independent of the * macro to access elements i,j in an NxM matrix A, independent of the
* matrix storage convention. * matrix storage convention.
*/ */
#define dACCESS33(A,i,j) ((A)[(i)*4+(j)]) #define dACCESS33(A,i,j) ((A)[(i)*4+(j)])
/* /*
* Macro to test for valid floating point values * Macro to test for valid floating point values
*/ */
#define dVALIDVEC3(v) (!(dIsNan(v[0]) || dIsNan(v[1]) || dIsNan(v[2]))) #define dVALIDVEC3(v) (!(dIsNan(v[0]) || dIsNan(v[1]) || dIsNan(v[2])))
#define dVALIDVEC4(v) (!(dIsNan(v[0]) || dIsNan(v[1]) || dIsNan(v[2]) || dI sNan(v[3]))) #define dVALIDVEC4(v) (!(dIsNan(v[0]) || dIsNan(v[1]) || dIsNan(v[2]) || dI sNan(v[3])))
#define dVALIDMAT3(m) (!(dIsNan(m[0]) || dIsNan(m[1]) || dIsNan(m[2]) || dI sNan(m[3]) || dIsNan(m[4]) || dIsNan(m[5]) || dIsNan(m[6]) || dIsNan(m[7]) || dIsNan(m[8]) || dIsNan(m[9]) || dIsNan(m[10]) || dIsNan(m[11]))) #define dVALIDMAT3(m) (!(dIsNan(m[0]) || dIsNan(m[1]) || dIsNan(m[2]) || dI sNan(m[3]) || dIsNan(m[4]) || dIsNan(m[5]) || dIsNan(m[6]) || dIsNan(m[7]) || dIsNan(m[8]) || dIsNan(m[9]) || dIsNan(m[10]) || dIsNan(m[11])))
#define dVALIDMAT4(m) (!(dIsNan(m[0]) || dIsNan(m[1]) || dIsNan(m[2]) || dI sNan(m[3]) || dIsNan(m[4]) || dIsNan(m[5]) || dIsNan(m[6]) || dIsNan(m[7]) || dIsNan(m[8]) || dIsNan(m[9]) || dIsNan(m[10]) || dIsNan(m[11]) || dIsNan (m[12]) || dIsNan(m[13]) || dIsNan(m[14]) || dIsNan(m[15]) )) #define dVALIDMAT4(m) (!(dIsNan(m[0]) || dIsNan(m[1]) || dIsNan(m[2]) || dI sNan(m[3]) || dIsNan(m[4]) || dIsNan(m[5]) || dIsNan(m[6]) || dIsNan(m[7]) || dIsNan(m[8]) || dIsNan(m[9]) || dIsNan(m[10]) || dIsNan(m[11]) || dIsNan (m[12]) || dIsNan(m[13]) || dIsNan(m[14]) || dIsNan(m[15]) ))
/* // Some vector math
* General purpose vector operations with other vectors or constants. PURE_INLINE void dAddVectors3(dReal *res, const dReal *a, const dReal *b)
*/ {
dReal res_0, res_1, res_2;
res_0 = a[0] + b[0];
res_1 = a[1] + b[1];
res_2 = a[2] + b[2];
// Only assign after all the calculations are over to avoid incurring mem
ory aliasing
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
#define dOP(a,op,b,c) do { \ PURE_INLINE void dSubtractVectors3(dReal *res, const dReal *a, const dReal
(a)[0] = ((b)[0]) op ((c)[0]); \ *b)
(a)[1] = ((b)[1]) op ((c)[1]); \ {
(a)[2] = ((b)[2]) op ((c)[2]); \ dReal res_0, res_1, res_2;
} while (0) res_0 = a[0] - b[0];
#define dOPC(a,op,b,c) do { \ res_1 = a[1] - b[1];
(a)[0] = ((b)[0]) op (c); \ res_2 = a[2] - b[2];
(a)[1] = ((b)[1]) op (c); \ // Only assign after all the calculations are over to avoid incurring mem
(a)[2] = ((b)[2]) op (c); \ ory aliasing
} while (0) res[0] = res_0; res[1] = res_1; res[2] = res_2;
#define dOPE(a,op,b) do {\ }
(a)[0] op ((b)[0]); \
(a)[1] op ((b)[1]); \
(a)[2] op ((b)[2]); \
} while (0)
#define dOPEC(a,op,c) do { \
(a)[0] op (c); \
(a)[1] op (c); \
(a)[2] op (c); \
} while (0)
/// Define an equation with operatos
/// For example this function can be used to replace
/// <PRE>
/// for (int i=0; i<3; ++i)
/// a[i] += b[i] + c[i];
/// </PRE>
#define dOPE2(a,op1,b,op2,c) do { \
(a)[0] op1 ((b)[0]) op2 ((c)[0]); \
(a)[1] op1 ((b)[1]) op2 ((c)[1]); \
(a)[2] op1 ((b)[2]) op2 ((c)[2]); \
} while (0)
/* PURE_INLINE void dAddScaledVectors3(dReal *res, const dReal *a, const dReal
* Length, and squared length helpers. dLENGTH returns the length of a dVec *b, dReal a_scale, dReal b_scale)
tor3. {
* dLENGTHSQUARED return the squared length of a dVector3. dReal res_0, res_1, res_2;
*/ res_0 = a_scale * a[0] + b_scale * b[0];
res_1 = a_scale * a[1] + b_scale * b[1];
res_2 = a_scale * a[2] + b_scale * b[2];
// Only assign after all the calculations are over to avoid incurring mem
ory aliasing
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
#define dLENGTHSQUARED(a) (((a)[0])*((a)[0]) + ((a)[1])*((a)[1]) + ((a)[2]) PURE_INLINE void dScaleVector3(dReal *res, dReal nScale)
*((a)[2])) {
res[0] *= nScale ;
res[1] *= nScale ;
res[2] *= nScale ;
}
#ifdef __cplusplus PURE_INLINE void dNegateVector3(dReal *res)
{
res[0] = -res[0];
res[1] = -res[1];
res[2] = -res[2];
}
PURE_INLINE dReal dLENGTH (const dReal *a) { return dSqrt(dLENGTHSQUARED(a) PURE_INLINE void dCopyVector3(dReal *res, const dReal *a)
); } {
dReal res_0, res_1, res_2;
res_0 = a[0];
res_1 = a[1];
res_2 = a[2];
// Only assign after all the calculations are over to avoid incurring mem
ory aliasing
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
#else PURE_INLINE void dCopyScaledVector3(dReal *res, const dReal *a, dReal nScal
e)
{
dReal res_0, res_1, res_2;
res_0 = a[0] * nScale;
res_1 = a[1] * nScale;
res_2 = a[2] * nScale;
// Only assign after all the calculations are over to avoid incurring mem
ory aliasing
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
#define dLENGTH(a) ( dSqrt( ((a)[0])*((a)[0]) + ((a)[1])*((a)[1]) + ((a)[2] PURE_INLINE void dCopyNegatedVector3(dReal *res, const dReal *a)
)*((a)[2]) ) ) {
dReal res_0, res_1, res_2;
res_0 = -a[0];
res_1 = -a[1];
res_2 = -a[2];
// Only assign after all the calculations are over to avoid incurring mem
ory aliasing
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
#endif /* __cplusplus */ PURE_INLINE void dCopyVector4(dReal *res, const dReal *a)
{
dReal res_0, res_1, res_2, res_3;
res_0 = a[0];
res_1 = a[1];
res_2 = a[2];
res_3 = a[3];
// Only assign after all the calculations are over to avoid incurring mem
ory aliasing
res[0] = res_0; res[1] = res_1; res[2] = res_2; res[3] = res_3;
}
/* PURE_INLINE void dCopyMatrix4x4(dReal *res, const dReal *a)
* 3-way dot product. dDOTpq means that elements of `a' and `b' are spaced {
* p and q indexes apart respectively. dDOT() means dDOT11. dCopyVector4(res + 0, a + 0);
* in C++ we could use function templates to get all the versions of these dCopyVector4(res + 4, a + 4);
* functions - but on some compilers this will result in sub-optimal code. dCopyVector4(res + 8, a + 8);
*/ }
#define dDOTpq(a,b,p,q) ((a)[0]*(b)[0] + (a)[p]*(b)[q] + (a)[2*(p)]*(b)[2*( PURE_INLINE void dCopyMatrix4x3(dReal *res, const dReal *a)
q)]) {
dCopyVector3(res + 0, a + 0);
dCopyVector3(res + 4, a + 4);
dCopyVector3(res + 8, a + 8);
}
#ifdef __cplusplus PURE_INLINE void dGetMatrixColumn3(dReal *res, const dReal *a, unsigned n)
{
dReal res_0, res_1, res_2;
res_0 = a[n + 0];
res_1 = a[n + 4];
res_2 = a[n + 8];
// Only assign after all the calculations are over to avoid incurring mem
ory aliasing
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
PURE_INLINE dReal dCalcVectorLength3(const dReal *a)
{
return dSqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
}
PURE_INLINE dReal dCalcVectorLengthSquare3(const dReal *a)
{
return (a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
}
PURE_INLINE dReal dDOT (const dReal *a, const dReal *b) { return dDOTpq(a PURE_INLINE dReal dCalcPointDepth3(const dReal *test_p, const dReal *plane_
,b,1,1); } p, const dReal *plane_n)
PURE_INLINE dReal dDOT13 (const dReal *a, const dReal *b) { return dDOTpq(a {
,b,1,3); } return (plane_p[0] - test_p[0]) * plane_n[0] + (plane_p[1] - test_p[1]) *
PURE_INLINE dReal dDOT31 (const dReal *a, const dReal *b) { return dDOTpq(a plane_n[1] + (plane_p[2] - test_p[2]) * plane_n[2];
,b,3,1); } }
PURE_INLINE dReal dDOT33 (const dReal *a, const dReal *b) { return dDOTpq(a
,b,3,3); } /*
PURE_INLINE dReal dDOT14 (const dReal *a, const dReal *b) { return dDOTpq(a * 3-way dot product. _dCalcVectorDot3 means that elements of `a' and `b' ar
,b,1,4); } e spaced
PURE_INLINE dReal dDOT41 (const dReal *a, const dReal *b) { return dDOTpq(a * step_a and step_b indexes apart respectively. dCalcVectorDot3() means dDo
,b,4,1); } t311.
PURE_INLINE dReal dDOT44 (const dReal *a, const dReal *b) { return dDOTpq(a */
,b,4,4); }
PURE_INLINE dReal _dCalcVectorDot3(const dReal *a, const dReal *b, unsigned
#else step_a, unsigned step_b)
{
#define dDOT(a,b) dDOTpq(a,b,1,1) return a[0] * b[0] + a[step_a] * b[step_b] + a[2 * step_a] * b[2 * step_b
#define dDOT13(a,b) dDOTpq(a,b,1,3) ];
#define dDOT31(a,b) dDOTpq(a,b,3,1) }
#define dDOT33(a,b) dDOTpq(a,b,3,3)
#define dDOT14(a,b) dDOTpq(a,b,1,4)
#define dDOT41(a,b) dDOTpq(a,b,4,1)
#define dDOT44(a,b) dDOTpq(a,b,4,4)
#endif /* __cplusplus */ PURE_INLINE dReal dCalcVectorDot3 (const dReal *a, const dReal *b) { ret
urn _dCalcVectorDot3(a,b,1,1); }
PURE_INLINE dReal dCalcVectorDot3_13 (const dReal *a, const dReal *b) { ret
urn _dCalcVectorDot3(a,b,1,3); }
PURE_INLINE dReal dCalcVectorDot3_31 (const dReal *a, const dReal *b) { ret
urn _dCalcVectorDot3(a,b,3,1); }
PURE_INLINE dReal dCalcVectorDot3_33 (const dReal *a, const dReal *b) { ret
urn _dCalcVectorDot3(a,b,3,3); }
PURE_INLINE dReal dCalcVectorDot3_14 (const dReal *a, const dReal *b) { ret
urn _dCalcVectorDot3(a,b,1,4); }
PURE_INLINE dReal dCalcVectorDot3_41 (const dReal *a, const dReal *b) { ret
urn _dCalcVectorDot3(a,b,4,1); }
PURE_INLINE dReal dCalcVectorDot3_44 (const dReal *a, const dReal *b) { ret
urn _dCalcVectorDot3(a,b,4,4); }
/* /*
* cross product, set a = b x c. dCROSSpqr means that elements of `a', `b' * cross product, set res = a x b. _dCalcVectorCross3 means that elements o
* and `c' are spaced p, q and r indexes apart respectively. f `res', `a'
* dCROSS() means dCROSS111. `op' is normally `=', but you can set it to * and `b' are spaced step_res, step_a and step_b indexes apart respectivel
* +=, -= etc to get other effects. y.
* dCalcVectorCross3() means dCross3111.
*/ */
#define dCROSS(a,op,b,c) \ PURE_INLINE void _dCalcVectorCross3(dReal *res, const dReal *a, const dReal
do { \ *b, unsigned step_res, unsigned step_a, unsigned step_b)
(a)[0] op ((b)[1]*(c)[2] - (b)[2]*(c)[1]); \ {
(a)[1] op ((b)[2]*(c)[0] - (b)[0]*(c)[2]); \ dReal res_0, res_1, res_2;
(a)[2] op ((b)[0]*(c)[1] - (b)[1]*(c)[0]); \ res_0 = a[ step_a]*b[2*step_b] - a[2*step_a]*b[ step_b];
} while(0) res_1 = a[2*step_a]*b[ 0] - a[ 0]*b[2*step_b];
#define dCROSSpqr(a,op,b,c,p,q,r) \ res_2 = a[ 0]*b[ step_b] - a[ step_a]*b[ 0];
do { \ // Only assign after all the calculations are over to avoid incurring mem
(a)[ 0] op ((b)[ q]*(c)[2*r] - (b)[2*q]*(c)[ r]); \ ory aliasing
(a)[ p] op ((b)[2*q]*(c)[ 0] - (b)[ 0]*(c)[2*r]); \ res[ 0] = res_0;
(a)[2*p] op ((b)[ 0]*(c)[ r] - (b)[ q]*(c)[ 0]); \ res[ step_res] = res_1;
} while(0) res[2*step_res] = res_2;
#define dCROSS114(a,op,b,c) dCROSSpqr(a,op,b,c,1,1,4) }
#define dCROSS141(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,1)
#define dCROSS144(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,4) PURE_INLINE void dCalcVectorCross3 (dReal *res, const dReal *a, const dR
#define dCROSS411(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,1) eal *b) { _dCalcVectorCross3(res, a, b, 1, 1, 1); }
#define dCROSS414(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,4) PURE_INLINE void dCalcVectorCross3_114(dReal *res, const dReal *a, const dR
#define dCROSS441(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,1) eal *b) { _dCalcVectorCross3(res, a, b, 1, 1, 4); }
#define dCROSS444(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,4) PURE_INLINE void dCalcVectorCross3_141(dReal *res, const dReal *a, const dR
eal *b) { _dCalcVectorCross3(res, a, b, 1, 4, 1); }
PURE_INLINE void dCalcVectorCross3_144(dReal *res, const dReal *a, const dR
eal *b) { _dCalcVectorCross3(res, a, b, 1, 4, 4); }
PURE_INLINE void dCalcVectorCross3_411(dReal *res, const dReal *a, const dR
eal *b) { _dCalcVectorCross3(res, a, b, 4, 1, 1); }
PURE_INLINE void dCalcVectorCross3_414(dReal *res, const dReal *a, const dR
eal *b) { _dCalcVectorCross3(res, a, b, 4, 1, 4); }
PURE_INLINE void dCalcVectorCross3_441(dReal *res, const dReal *a, const dR
eal *b) { _dCalcVectorCross3(res, a, b, 4, 4, 1); }
PURE_INLINE void dCalcVectorCross3_444(dReal *res, const dReal *a, const dR
eal *b) { _dCalcVectorCross3(res, a, b, 4, 4, 4); }
PURE_INLINE void dAddVectorCross3(dReal *res, const dReal *a, const dReal *
b)
{
dReal tmp[3];
dCalcVectorCross3(tmp, a, b);
dAddVectors3(res, res, tmp);
}
PURE_INLINE void dSubtractVectorCross3(dReal *res, const dReal *a, const dR
eal *b)
{
dReal tmp[3];
dCalcVectorCross3(tmp, a, b);
dSubtractVectors3(res, res, tmp);
}
/* /*
* set a 3x3 submatrix of A to a matrix such that submatrix(A)*b = a x b. * set a 3x3 submatrix of A to a matrix such that submatrix(A)*b = a x b.
* A is stored by rows, and has `skip' elements per row. the matrix is * A is stored by rows, and has `skip' elements per row. the matrix is
* assumed to be already zero, so this does not write zero elements! * assumed to be already zero, so this does not write zero elements!
* if (plus,minus) is (+,-) then a positive version will be written. * if (plus,minus) is (+,-) then a positive version will be written.
* if (plus,minus) is (-,+) then a negative version will be written. * if (plus,minus) is (-,+) then a negative version will be written.
*/ */
#define dCROSSMAT(A,a,skip,plus,minus) \ PURE_INLINE void dSetCrossMatrixPlus(dReal *res, const dReal *a, unsigned s
do { \ kip)
(A)[1] = minus (a)[2]; \ {
(A)[2] = plus (a)[1]; \ const dReal a_0 = a[0], a_1 = a[1], a_2 = a[2];
(A)[(skip)+0] = plus (a)[2]; \ res[1] = -a_2;
(A)[(skip)+2] = minus (a)[0]; \ res[2] = +a_1;
(A)[2*(skip)+0] = minus (a)[1]; \ res[skip+0] = +a_2;
(A)[2*(skip)+1] = plus (a)[0]; \ res[skip+2] = -a_0;
} while(0) res[2*skip+0] = -a_1;
res[2*skip+1] = +a_0;
}
PURE_INLINE void dSetCrossMatrixMinus(dReal *res, const dReal *a, unsigned
skip)
{
const dReal a_0 = a[0], a_1 = a[1], a_2 = a[2];
res[1] = +a_2;
res[2] = -a_1;
res[skip+0] = -a_2;
res[skip+2] = +a_0;
res[2*skip+0] = +a_1;
res[2*skip+1] = -a_0;
}
/* /*
* compute the distance between two 3D-vectors * compute the distance between two 3D-vectors
*/ */
#ifdef __cplusplus PURE_INLINE dReal dCalcPointsDistance3(const dReal *a, const dReal *b)
PURE_INLINE dReal dDISTANCE (const dVector3 a, const dVector3 b) {
{ return dSqrt( (a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1]) + dReal res;
(a[2]-b[2])*(a[2]-b[2]) ); } dReal tmp[3];
#else dSubtractVectors3(tmp, a, b);
#define dDISTANCE(a,b) \ res = dCalcVectorLength3(tmp);
(dSqrt( ((a)[0]-(b)[0])*((a)[0]-(b)[0]) + ((a)[1]-(b)[1])*((a)[1]-(b return res;
)[1]) + ((a)[2]-(b)[2])*((a)[2]-(b)[2]) )) }
#endif
/* /*
* special case matrix multipication, with operator selection * special case matrix multiplication, with operator selection
*/ */
#define dMULTIPLYOP0_331(A,op,B,C) \ PURE_INLINE void dMultiplyHelper0_331(dReal *res, const dReal *a, const dRe
do { \ al *b)
(A)[0] op dDOT((B),(C)); \ {
(A)[1] op dDOT((B+4),(C)); \ dReal res_0, res_1, res_2;
(A)[2] op dDOT((B+8),(C)); \ res_0 = dCalcVectorDot3(a, b);
} while(0) res_1 = dCalcVectorDot3(a + 4, b);
#define dMULTIPLYOP1_331(A,op,B,C) \ res_2 = dCalcVectorDot3(a + 8, b);
do { \ // Only assign after all the calculations are over to avoid incurring mem
(A)[0] op dDOT41((B),(C)); \ ory aliasing
(A)[1] op dDOT41((B+1),(C)); \ res[0] = res_0; res[1] = res_1; res[2] = res_2;
(A)[2] op dDOT41((B+2),(C)); \ }
} while(0)
#define dMULTIPLYOP0_133(A,op,B,C) \ PURE_INLINE void dMultiplyHelper1_331(dReal *res, const dReal *a, const dRe
do { \ al *b)
(A)[0] op dDOT14((B),(C)); \ {
(A)[1] op dDOT14((B),(C+1)); \ dReal res_0, res_1, res_2;
(A)[2] op dDOT14((B),(C+2)); \ res_0 = dCalcVectorDot3_41(a, b);
} while(0) res_1 = dCalcVectorDot3_41(a + 1, b);
#define dMULTIPLYOP0_333(A,op,B,C) \ res_2 = dCalcVectorDot3_41(a + 2, b);
do { \ // Only assign after all the calculations are over to avoid incurring mem
(A)[0] op dDOT14((B),(C)); \ ory aliasing
(A)[1] op dDOT14((B),(C+1)); \ res[0] = res_0; res[1] = res_1; res[2] = res_2;
(A)[2] op dDOT14((B),(C+2)); \ }
(A)[4] op dDOT14((B+4),(C)); \
(A)[5] op dDOT14((B+4),(C+1)); \
(A)[6] op dDOT14((B+4),(C+2)); \
(A)[8] op dDOT14((B+8),(C)); \
(A)[9] op dDOT14((B+8),(C+1)); \
(A)[10] op dDOT14((B+8),(C+2)); \
} while(0)
#define dMULTIPLYOP1_333(A,op,B,C) \
do { \
(A)[0] op dDOT44((B),(C)); \
(A)[1] op dDOT44((B),(C+1)); \
(A)[2] op dDOT44((B),(C+2)); \
(A)[4] op dDOT44((B+1),(C)); \
(A)[5] op dDOT44((B+1),(C+1)); \
(A)[6] op dDOT44((B+1),(C+2)); \
(A)[8] op dDOT44((B+2),(C)); \
(A)[9] op dDOT44((B+2),(C+1)); \
(A)[10] op dDOT44((B+2),(C+2)); \
} while(0)
#define dMULTIPLYOP2_333(A,op,B,C) \
do { \
(A)[0] op dDOT((B),(C)); \
(A)[1] op dDOT((B),(C+4)); \
(A)[2] op dDOT((B),(C+8)); \
(A)[4] op dDOT((B+4),(C)); \
(A)[5] op dDOT((B+4),(C+4)); \
(A)[6] op dDOT((B+4),(C+8)); \
(A)[8] op dDOT((B+8),(C)); \
(A)[9] op dDOT((B+8),(C+4)); \
(A)[10] op dDOT((B+8),(C+8)); \
} while(0)
#ifdef __cplusplus PURE_INLINE void dMultiplyHelper0_133(dReal *res, const dReal *a, const dRe
al *b)
{
dMultiplyHelper1_331(res, b, a);
}
#define DECL template <class TA, class TB, class TC> PURE_INLINE void PURE_INLINE void dMultiplyHelper1_133(dReal *res, const dReal *a, const dRe
al *b)
{
dReal res_0, res_1, res_2;
res_0 = dCalcVectorDot3_44(a, b);
res_1 = dCalcVectorDot3_44(a + 1, b);
res_2 = dCalcVectorDot3_44(a + 2, b);
// Only assign after all the calculations are over to avoid incurring mem
ory aliasing
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
/* /*
Note: NEVER call any of these functions/macros with the same variable for A and C, Note: NEVER call any of these functions/macros with the same variable for A and C,
it is not equivalent to A*=B. it is not equivalent to A*=B.
*/ */
DECL dMULTIPLY0_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_331(A,= PURE_INLINE void dMultiply0_331(dReal *res, const dReal *a, const dReal *b)
,B,C); } {
DECL dMULTIPLY1_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_331(A,= dMultiplyHelper0_331(res, a, b);
,B,C); } }
DECL dMULTIPLY0_133(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_133(A,=
,B,C); }
DECL dMULTIPLY0_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_333(A,=
,B,C); }
DECL dMULTIPLY1_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_333(A,=
,B,C); }
DECL dMULTIPLY2_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP2_333(A,=
,B,C); }
DECL dMULTIPLYADD0_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_331(
A,+=,B,C); }
DECL dMULTIPLYADD1_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_331(
A,+=,B,C); }
DECL dMULTIPLYADD0_133(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_133(
A,+=,B,C); }
DECL dMULTIPLYADD0_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_333(
A,+=,B,C); }
DECL dMULTIPLYADD1_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_333(
A,+=,B,C); }
DECL dMULTIPLYADD2_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP2_333(
A,+=,B,C); }
#undef DECL
#else
#define dMULTIPLY0_331(A,B,C) dMULTIPLYOP0_331(A,=,B,C)
#define dMULTIPLY1_331(A,B,C) dMULTIPLYOP1_331(A,=,B,C)
#define dMULTIPLY0_133(A,B,C) dMULTIPLYOP0_133(A,=,B,C)
#define dMULTIPLY0_333(A,B,C) dMULTIPLYOP0_333(A,=,B,C)
#define dMULTIPLY1_333(A,B,C) dMULTIPLYOP1_333(A,=,B,C)
#define dMULTIPLY2_333(A,B,C) dMULTIPLYOP2_333(A,=,B,C)
#define dMULTIPLYADD0_331(A,B,C) dMULTIPLYOP0_331(A,+=,B,C)
#define dMULTIPLYADD1_331(A,B,C) dMULTIPLYOP1_331(A,+=,B,C)
#define dMULTIPLYADD0_133(A,B,C) dMULTIPLYOP0_133(A,+=,B,C)
#define dMULTIPLYADD0_333(A,B,C) dMULTIPLYOP0_333(A,+=,B,C)
#define dMULTIPLYADD1_333(A,B,C) dMULTIPLYOP1_333(A,+=,B,C)
#define dMULTIPLYADD2_333(A,B,C) dMULTIPLYOP2_333(A,+=,B,C)
#endif PURE_INLINE void dMultiply1_331(dReal *res, const dReal *a, const dReal *b)
{
dMultiplyHelper1_331(res, a, b);
}
#ifdef __cplusplus PURE_INLINE void dMultiply0_133(dReal *res, const dReal *a, const dReal *b)
extern "C" { {
#endif dMultiplyHelper0_133(res, a, b);
}
/* PURE_INLINE void dMultiply0_333(dReal *res, const dReal *a, const dReal *b)
* normalize 3x1 and 4x1 vectors (i.e. scale them to unit length) {
*/ dMultiplyHelper0_133(res + 0, a + 0, b);
dMultiplyHelper0_133(res + 4, a + 4, b);
dMultiplyHelper0_133(res + 8, a + 8, b);
}
#if defined(__ODE__) PURE_INLINE void dMultiply1_333(dReal *res, const dReal *a, const dReal *b)
{
dMultiplyHelper1_133(res + 0, b, a + 0);
dMultiplyHelper1_133(res + 4, b, a + 1);
dMultiplyHelper1_133(res + 8, b, a + 2);
}
int _dSafeNormalize3 (dVector3 a); PURE_INLINE void dMultiply2_333(dReal *res, const dReal *a, const dReal *b)
int _dSafeNormalize4 (dVector4 a); {
dMultiplyHelper0_331(res + 0, b, a + 0);
dMultiplyHelper0_331(res + 4, b, a + 4);
dMultiplyHelper0_331(res + 8, b, a + 8);
}
static __inline void _dNormalize3(dVector3 a) PURE_INLINE void dMultiplyAdd0_331(dReal *res, const dReal *a, const dReal *b)
{ {
int bNormalizationResult = _dSafeNormalize3(a); dReal tmp[3];
dIASSERT(bNormalizationResult); dMultiplyHelper0_331(tmp, a, b);
dVARIABLEUSED(bNormalizationResult); dAddVectors3(res, res, tmp);
} }
static __inline void _dNormalize4(dVector4 a) PURE_INLINE void dMultiplyAdd1_331(dReal *res, const dReal *a, const dReal *b)
{ {
int bNormalizationResult = _dSafeNormalize4(a); dReal tmp[3];
dIASSERT(bNormalizationResult); dMultiplyHelper1_331(tmp, a, b);
dVARIABLEUSED(bNormalizationResult); dAddVectors3(res, res, tmp);
} }
#endif // defined(__ODE__) PURE_INLINE void dMultiplyAdd0_133(dReal *res, const dReal *a, const dReal
*b)
{
dReal tmp[3];
dMultiplyHelper0_133(tmp, a, b);
dAddVectors3(res, res, tmp);
}
PURE_INLINE void dMultiplyAdd0_333(dReal *res, const dReal *a, const dReal
*b)
{
dReal tmp[3];
dMultiplyHelper0_133(tmp, a + 0, b);
dAddVectors3(res+ 0, res + 0, tmp);
dMultiplyHelper0_133(tmp, a + 4, b);
dAddVectors3(res + 4, res + 4, tmp);
dMultiplyHelper0_133(tmp, a + 8, b);
dAddVectors3(res + 8, res + 8, tmp);
}
PURE_INLINE void dMultiplyAdd1_333(dReal *res, const dReal *a, const dReal
*b)
{
dReal tmp[3];
dMultiplyHelper1_133(tmp, b, a + 0);
dAddVectors3(res + 0, res + 0, tmp);
dMultiplyHelper1_133(tmp, b, a + 1);
dAddVectors3(res + 4, res + 4, tmp);
dMultiplyHelper1_133(tmp, b, a + 2);
dAddVectors3(res + 8, res + 8, tmp);
}
PURE_INLINE void dMultiplyAdd2_333(dReal *res, const dReal *a, const dReal
*b)
{
dReal tmp[3];
dMultiplyHelper0_331(tmp, b, a + 0);
dAddVectors3(res + 0, res + 0, tmp);
dMultiplyHelper0_331(tmp, b, a + 4);
dAddVectors3(res + 4, res + 4, tmp);
dMultiplyHelper0_331(tmp, b, a + 8);
dAddVectors3(res + 8, res + 8, tmp);
}
// Include legacy macros here
#include <ode/odemath_legacy.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* normalize 3x1 and 4x1 vectors (i.e. scale them to unit length)
*/
// For DLL export // For DLL export
ODE_API int dSafeNormalize3 (dVector3 a); ODE_API int dSafeNormalize3 (dVector3 a);
ODE_API int dSafeNormalize4 (dVector4 a); ODE_API int dSafeNormalize4 (dVector4 a);
ODE_API void dNormalize3 (dVector3 a); // Potentially asserts on zero vec ODE_API void dNormalize3 (dVector3 a); // Potentially asserts on zero vec
ODE_API void dNormalize4 (dVector4 a); // Potentially asserts on zero vec ODE_API void dNormalize4 (dVector4 a); // Potentially asserts on zero vec
#if defined(__ODE__) #if defined(__ODE__)
int _dSafeNormalize3 (dVector3 a);
int _dSafeNormalize4 (dVector4 a);
PURE_INLINE void _dNormalize3(dVector3 a)
{
int bNormalizationResult = _dSafeNormalize3(a);
dIVERIFY(bNormalizationResult);
}
PURE_INLINE void _dNormalize4(dVector4 a)
{
int bNormalizationResult = _dSafeNormalize4(a);
dIVERIFY(bNormalizationResult);
}
// For internal use // For internal use
#define dSafeNormalize3(a) _dSafeNormalize3(a) #define dSafeNormalize3(a) _dSafeNormalize3(a)
#define dSafeNormalize4(a) _dSafeNormalize4(a) #define dSafeNormalize4(a) _dSafeNormalize4(a)
#define dNormalize3(a) _dNormalize3(a) #define dNormalize3(a) _dNormalize3(a)
#define dNormalize4(a) _dNormalize4(a) #define dNormalize4(a) _dNormalize4(a)
#endif // defined(__ODE__) #endif // defined(__ODE__)
/* /*
* given a unit length "normal" vector n, generate vectors p and q vectors * given a unit length "normal" vector n, generate vectors p and q vectors
 End of changes. 35 change blocks. 
249 lines changed or deleted 382 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/