Skip to content

Commit

Permalink
ODE: renamed CappedCylinder to Capsule (as in ODE 0.6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed May 30, 2018
1 parent 205fab5 commit 9864943
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 89 deletions.
14 changes: 7 additions & 7 deletions Externals/ode/config/msvcdefs.def
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ dClosestLineSegmentPoints
dCollide
dCollideRaySphere
dCollideRayBox
dCollideRayCCylinder
dCollideRayCapsule
dCreateBox
dCreateCCylinder
dCreateCapsule
dCreateGeom
dCreateGeomClass
dCreateGeomTransform
Expand All @@ -85,9 +85,9 @@ dFactorLDLT
dGeomBoxGetLengths
dGeomBoxPointDepth
dGeomBoxSetLengths
dGeomCCylinderGetParams
dGeomCCylinderPointDepth
dGeomCCylinderSetParams
dGeomCapsuleGetParams
dGeomCapsulePointDepth
dGeomCapsuleSetParams
dGeomDestroy
dGeomDisable
dGeomEnable
Expand Down Expand Up @@ -227,8 +227,8 @@ dMassAdjust
dMassRotate
dMassSetBox
dMassSetBoxTotal
dMassSetCappedCylinder
dMassSetCappedCylinderTotal
dMassSetCapsule
dMassSetCapsuleTotal
dMassSetCylinder
dMassSetCylinderTotal
dMassSetParameters
Expand Down
19 changes: 12 additions & 7 deletions Externals/ode/include/ode/collision.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ enum {
enum {
dSphereClass = 0,
dBoxClass,
dCCylinderClass, // XXX: Cylinder was renamed to Capsule
dCapsuleClass,
dCylinderClass,
dPlaneClass,
dRayClass,
Expand Down Expand Up @@ -435,12 +435,17 @@ ODE_API void dGeomPlaneSetParams (dGeomID plane, dReal a, dReal b, dReal c, dRea
ODE_API void dGeomPlaneGetParams (dGeomID plane, dVector4 result);
ODE_API dReal dGeomPlanePointDepth (dGeomID plane, dReal x, dReal y, dReal z);

// XXX: Cylinder was renamed to Capsule
dGeomID dCreateCCylinder (dSpaceID space, dReal radius, dReal length);
void dGeomCCylinderSetParams (dGeomID ccylinder, dReal radius, dReal length);
void dGeomCCylinderGetParams (dGeomID ccylinder, dReal *radius, dReal *length);

dReal dGeomCCylinderPointDepth (dGeomID ccylinder, dReal x, dReal y, dReal z);
ODE_API dGeomID dCreateCapsule (dSpaceID space, dReal radius, dReal length);
ODE_API void dGeomCapsuleSetParams (dGeomID ccylinder, dReal radius, dReal length);
ODE_API void dGeomCapsuleGetParams (dGeomID ccylinder, dReal *radius, dReal *length);
ODE_API dReal dGeomCapsulePointDepth (dGeomID ccylinder, dReal x, dReal y, dReal z);

// For now we want to have a backwards compatible C-API, note: C++ API is not.
#define dCreateCCylinder dCreateCapsule
#define dGeomCCylinderSetParams dGeomCapsuleSetParams
#define dGeomCCylinderGetParams dGeomCapsuleGetParams
#define dGeomCCylinderPointDepth dGeomCapsulePointDepth
#define dCCylinderClass dCapsuleClass

ODE_API dGeomID dCreateRay (dSpaceID space, dReal length);
ODE_API void dGeomRaySetLength (dGeomID ray, dReal length);
Expand Down
8 changes: 4 additions & 4 deletions Externals/ode/include/ode/geom.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void dCloseODE();
/* class numbers */
extern GLOBAL_SHAREDLIB_SPEC int dSphereClass;
extern GLOBAL_SHAREDLIB_SPEC int dBoxClass;
extern GLOBAL_SHAREDLIB_SPEC int dCCylinderClass;
extern GLOBAL_SHAREDLIB_SPEC int dCapsuleClass;
extern GLOBAL_SHAREDLIB_SPEC int dPlaneClass;
extern GLOBAL_SHAREDLIB_SPEC int dGeomGroupClass;
extern GLOBAL_SHAREDLIB_SPEC int dGeomTransformClass;
Expand All @@ -73,21 +73,21 @@ extern GLOBAL_SHAREDLIB_SPEC int dGeomTransformClass;
dGeomID dCreateSphere (dSpaceID space, dReal radius);
dGeomID dCreateBox (dSpaceID space, dReal lx, dReal ly, dReal lz);
dGeomID dCreatePlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d);
dGeomID dCreateCCylinder (dSpaceID space, dReal radius, dReal length);
dGeomID dCreateCapsule (dSpaceID space, dReal radius, dReal length);
dGeomID dCreateGeomGroup (dSpaceID space);

/* set geometry parameters */
void dGeomSphereSetRadius (dGeomID sphere, dReal radius);
void dGeomBoxSetLengths (dGeomID box, dReal lx, dReal ly, dReal lz);
void dGeomPlaneSetParams (dGeomID plane, dReal a, dReal b, dReal c, dReal d);
void dGeomCCylinderSetParams (dGeomID ccylinder, dReal radius, dReal length);
void dGeomCapsuleSetParams (dGeomID ccylinder, dReal radius, dReal length);

/* get geometry parameters */
int dGeomGetClass (dGeomID);
dReal dGeomSphereGetRadius (dGeomID sphere);
void dGeomBoxGetLengths (dGeomID box, dVector3 result);
void dGeomPlaneGetParams (dGeomID plane, dVector4 result);
void dGeomCCylinderGetParams (dGeomID ccylinder,
void dGeomCapsuleGetParams (dGeomID ccylinder,
dReal *radius, dReal *length);

/* general functions */
Expand Down
16 changes: 10 additions & 6 deletions Externals/ode/include/ode/mass.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ ODE_API void dMassSetParameters (dMass *, dReal themass,
ODE_API void dMassSetSphere (dMass *, dReal density, dReal radius);
ODE_API void dMassSetSphereTotal (dMass *, dReal total_mass, dReal radius);

// XXX: Cylinder was renamed to Capsule
ODE_API void dMassSetCappedCylinder (dMass *, dReal density, int direction,
dReal radius, dReal length);
ODE_API void dMassSetCappedCylinderTotal (dMass *, dReal total_mass, int direction,
dReal radius, dReal length);
ODE_API void dMassSetCapsule (dMass *, dReal density, int direction,
dReal radius, dReal length);
ODE_API void dMassSetCapsuleTotal (dMass *, dReal total_mass, int direction,
dReal radius, dReal length);

ODE_API void dMassSetCylinder (dMass *, dReal density, int direction,
dReal radius, dReal length);
Expand All @@ -67,6 +66,9 @@ ODE_API void dMassRotate (dMass *, const dMatrix3 R);

ODE_API void dMassAdd (dMass *a, const dMass *b);

// Backwards compatible API
#define dMassSetCappedCylinder dMassSetCapsule
#define dMassSetCappedCylinderTotal dMassSetCapsuleTotal


struct dMass {
Expand All @@ -85,8 +87,10 @@ struct dMass {
{ dMassSetParameters (this,themass,cgx,cgy,cgz,I11,I22,I33,I12,I13,I23); }
void setSphere (dReal density, dReal radius)
{ dMassSetSphere (this,density,radius); }
void setCappedCylinder (dReal density, int direction, dReal a, dReal b)
void setCapsule (dReal density, int direction, dReal a, dReal b)
{ dMassSetCappedCylinder (this,density,direction,a,b); }
void setCappedCylinder (dReal density, int direction, dReal a, dReal b)
{ setCapsule(density, direction, a, b); }
void setBox (dReal density, dReal lx, dReal ly, dReal lz)
{ dMassSetBox (this,density,lx,ly,lz); }
void adjust (dReal newmass)
Expand Down
20 changes: 10 additions & 10 deletions Externals/ode/include/ode/odecpp_collision.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,26 +251,26 @@ class dPlane : public dGeom {
{ dGeomPlaneGetParams (_id,result); }
};

// XXX: Cylinder was renamed to Capsule
class dCCylinder : public dGeom {

class dCapsule : public dGeom {
// intentionally undefined, don't use these
dCCylinder (dCCylinder &);
void operator= (dCCylinder &);
dCapsule (dCapsule &);
void operator= (dCapsule &);

public:
dCCylinder() { }
dCCylinder (dSpaceID space, dReal radius, dReal length)
{ _id = dCreateCCylinder (space,radius,length); }
dCapsule() { }
dCapsule (dSpaceID space, dReal radius, dReal length)
{ _id = dCreateCapsule (space,radius,length); }

void create (dSpaceID space, dReal radius, dReal length) {
if (_id) dGeomDestroy (_id);
_id = dCreateCCylinder (space,radius,length);
_id = dCreateCapsule (space,radius,length);
}

void setParams (dReal radius, dReal length)
{ dGeomCCylinderSetParams (_id, radius, length); }
{ dGeomCapsuleSetParams (_id, radius, length); }
void getParams (dReal *radius, dReal *length) const
{ dGeomCCylinderGetParams (_id,radius,length); }
{ dGeomCapsuleGetParams (_id,radius,length); }
};


Expand Down
12 changes: 6 additions & 6 deletions Externals/ode/ode/src/collision_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,20 @@ static void initColliders()
setCollider (dSphereClass,dPlaneClass,&dCollideSpherePlane);
setCollider (dBoxClass,dBoxClass,&dCollideBoxBox);
setCollider (dBoxClass,dPlaneClass,&dCollideBoxPlane);
setCollider (dCCylinderClass,dSphereClass,&dCollideCCylinderSphere);
setCollider (dCCylinderClass,dBoxClass,&dCollideCCylinderBox);
setCollider (dCCylinderClass,dCCylinderClass,&dCollideCCylinderCCylinder);
setCollider (dCCylinderClass,dPlaneClass,&dCollideCCylinderPlane);
setCollider (dCapsuleClass,dSphereClass,&dCollideCapsuleSphere);
setCollider (dCapsuleClass,dBoxClass,&dCollideCapsuleBox);
setCollider (dCapsuleClass,dCapsuleClass,&dCollideCapsuleCapsule);
setCollider (dCapsuleClass,dPlaneClass,&dCollideCapsulePlane);
setCollider (dRayClass,dSphereClass,&dCollideRaySphere);
setCollider (dRayClass,dBoxClass,&dCollideRayBox);
setCollider (dRayClass,dCCylinderClass,&dCollideRayCCylinder);
setCollider (dRayClass,dCapsuleClass,&dCollideRayCapsule);
setCollider (dRayClass,dPlaneClass,&dCollideRayPlane);
#ifdef dTRIMESH_ENABLED
setCollider (dTriMeshClass,dSphereClass,&dCollideSTL);
setCollider (dTriMeshClass,dBoxClass,&dCollideBTL);
setCollider (dTriMeshClass,dRayClass,&dCollideRTL);
setCollider (dTriMeshClass,dTriMeshClass,&dCollideTTL);
setCollider (dTriMeshClass,dCCylinderClass,&dCollideCCTL);
setCollider (dTriMeshClass,dCapsuleClass,&dCollideCCTL);
#endif
setAllColliders (dGeomTransformClass,&dCollideTransform);
}
Expand Down
66 changes: 33 additions & 33 deletions Externals/ode/ode/src/collision_std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ struct dxBox : public dxGeom {
};


struct dxCCylinder : public dxGeom {
struct dxCapsule : public dxGeom {
dReal radius,lz; // radius, length along z axis
dxCCylinder (dSpaceID space, dReal _radius, dReal _length);
dxCapsule (dSpaceID space, dReal _radius, dReal _length);
void computeAABB();
};

Expand Down Expand Up @@ -215,17 +215,17 @@ dReal dGeomBoxPointDepth (dGeomID g, dReal x, dReal y, dReal z)
//****************************************************************************
// capped cylinder public API

dxCCylinder::dxCCylinder (dSpaceID space, dReal _radius, dReal _length) :
dxCapsule::dxCapsule (dSpaceID space, dReal _radius, dReal _length) :
dxGeom (space,1)
{
dAASSERT (_radius > 0 && _length > 0);
type = dCCylinderClass;
type = dCapsuleClass;
radius = _radius;
lz = _length;
}


void dxCCylinder::computeAABB()
void dxCapsule::computeAABB()
{
dReal xrange = dFabs(R[2] * lz) * REAL(0.5) + radius;
dReal yrange = dFabs(R[6] * lz) * REAL(0.5) + radius;
Expand All @@ -239,36 +239,36 @@ void dxCCylinder::computeAABB()
}


dGeomID dCreateCCylinder (dSpaceID space, dReal radius, dReal length)
dGeomID dCreateCapsule (dSpaceID space, dReal radius, dReal length)
{
return new dxCCylinder (space,radius,length);
return new dxCapsule (space,radius,length);
}


void dGeomCCylinderSetParams (dGeomID g, dReal radius, dReal length)
void dGeomCapsuleSetParams (dGeomID g, dReal radius, dReal length)
{
dUASSERT (g && g->type == dCCylinderClass,"argument not a ccylinder");
dUASSERT (g && g->type == dCapsuleClass,"argument not a ccylinder");
dAASSERT (radius > 0 && length > 0);
dxCCylinder *c = (dxCCylinder*) g;
dxCapsule *c = (dxCapsule*) g;
c->radius = radius;
c->lz = length;
dGeomMoved (g);
}


void dGeomCCylinderGetParams (dGeomID g, dReal *radius, dReal *length)
void dGeomCapsuleGetParams (dGeomID g, dReal *radius, dReal *length)
{
dUASSERT (g && g->type == dCCylinderClass,"argument not a ccylinder");
dxCCylinder *c = (dxCCylinder*) g;
dUASSERT (g && g->type == dCapsuleClass,"argument not a ccylinder");
dxCapsule *c = (dxCapsule*) g;
*radius = c->radius;
*length = c->lz;
}


dReal dGeomCCylinderPointDepth (dGeomID g, dReal x, dReal y, dReal z)
dReal dGeomCapsulePointDepth (dGeomID g, dReal x, dReal y, dReal z)
{
dUASSERT (g && g->type == dCCylinderClass,"argument not a ccylinder");
dxCCylinder *c = (dxCCylinder*) g;
dUASSERT (g && g->type == dCapsuleClass,"argument not a ccylinder");
dxCapsule *c = (dxCapsule*) g;
dVector3 a;
a[0] = x - c->pos[0];
a[1] = y - c->pos[1];
Expand Down Expand Up @@ -1519,13 +1519,13 @@ int dCollideBoxPlane (dxGeom *o1, dxGeom *o2,
}


int dCollideCCylinderSphere (dxGeom *o1, dxGeom *o2, int flags,
int dCollideCapsuleSphere (dxGeom *o1, dxGeom *o2, int flags,
dContactGeom *contact, int skip)
{
dIASSERT (skip >= (int)sizeof(dContactGeom));
dIASSERT (o1->type == dCCylinderClass);
dIASSERT (o1->type == dCapsuleClass);
dIASSERT (o2->type == dSphereClass);
dxCCylinder *ccyl = (dxCCylinder*) o1;
dxCapsule *ccyl = (dxCapsule*) o1;
dxSphere *sphere = (dxSphere*) o2;

contact->g1 = o1;
Expand All @@ -1549,13 +1549,13 @@ int dCollideCCylinderSphere (dxGeom *o1, dxGeom *o2, int flags,
}


int dCollideCCylinderBox (dxGeom *o1, dxGeom *o2, int flags,
int dCollideCapsuleBox (dxGeom *o1, dxGeom *o2, int flags,
dContactGeom *contact, int skip)
{
dIASSERT (skip >= (int)sizeof(dContactGeom));
dIASSERT (o1->type == dCCylinderClass);
dIASSERT (o1->type == dCapsuleClass);
dIASSERT (o2->type == dBoxClass);
dxCCylinder *cyl = (dxCCylinder*) o1;
dxCapsule *cyl = (dxCapsule*) o1;
dxBox *box = (dxBox*) o2;

contact->g1 = o1;
Expand Down Expand Up @@ -1586,17 +1586,17 @@ int dCollideCCylinderBox (dxGeom *o1, dxGeom *o2, int flags,
}


int dCollideCCylinderCCylinder (dxGeom *o1, dxGeom *o2,
int dCollideCapsuleCapsule (dxGeom *o1, dxGeom *o2,
int flags, dContactGeom *contact, int skip)
{
int i;
const dReal tolerance = REAL(1e-5);

dIASSERT (skip >= (int)sizeof(dContactGeom));
dIASSERT (o1->type == dCCylinderClass);
dIASSERT (o2->type == dCCylinderClass);
dxCCylinder *cyl1 = (dxCCylinder*) o1;
dxCCylinder *cyl2 = (dxCCylinder*) o2;
dIASSERT (o1->type == dCapsuleClass);
dIASSERT (o2->type == dCapsuleClass);
dxCapsule *cyl1 = (dxCapsule*) o1;
dxCapsule *cyl2 = (dxCapsule*) o2;

contact->g1 = o1;
contact->g2 = o2;
Expand Down Expand Up @@ -1698,13 +1698,13 @@ int dCollideCCylinderCCylinder (dxGeom *o1, dxGeom *o2,
}


int dCollideCCylinderPlane (dxGeom *o1, dxGeom *o2, int flags,
int dCollideCapsulePlane (dxGeom *o1, dxGeom *o2, int flags,
dContactGeom *contact, int skip)
{
dIASSERT (skip >= (int)sizeof(dContactGeom));
dIASSERT (o1->type == dCCylinderClass);
dIASSERT (o1->type == dCapsuleClass);
dIASSERT (o2->type == dPlaneClass);
dxCCylinder *ccyl = (dxCCylinder*) o1;
dxCapsule *ccyl = (dxCapsule*) o1;
dxPlane *plane = (dxPlane*) o2;

// collide the deepest capping sphere with the plane
Expand Down Expand Up @@ -1905,14 +1905,14 @@ int dCollideRayBox (dxGeom *o1, dxGeom *o2, int flags,
}


int dCollideRayCCylinder (dxGeom *o1, dxGeom *o2,
int dCollideRayCapsule (dxGeom *o1, dxGeom *o2,
int flags, dContactGeom *contact, int skip)
{
dIASSERT (skip >= (int)sizeof(dContactGeom));
dIASSERT (o1->type == dRayClass);
// dIASSERT (o2->type == dCCylinderClass);
// dIASSERT (o2->type == dCapsuleClass);
dxRay *ray = (dxRay*) o1;
dxCCylinder *ccyl = (dxCCylinder*) o2;
dxCapsule *ccyl = (dxCapsule*) o2;

contact->g1 = ray;
contact->g2 = ccyl;
Expand Down
Loading

0 comments on commit 9864943

Please sign in to comment.