diff --git a/OdeWorld.cc b/OdeWorld.cc index 1207a78..2e569ab 100644 --- a/OdeWorld.cc +++ b/OdeWorld.cc @@ -152,7 +152,7 @@ dGeomID OdeWorld::addCube(const string & name, bool static_data, dMass mass; dMassSetBox(&mass, 1.0, args[0], args[1], args[2]); dMassTranslate(&mass, args[3], args[4], args[5]); - setupGeom(name, static_data, body, id, true, &mass, + setupGeom(name, static_data, body, id, &mass, args[3], args[4], args[5], args[6], args[7], args[8]); return id; @@ -167,7 +167,7 @@ dGeomID OdeWorld::addSphere(const string & name, bool static_data, dMass mass; dMassSetSphere(&mass, 1.0, args[0]); dMassTranslate(&mass, args[1], args[2], args[3]); - setupGeom(name, static_data, body, id, true, &mass, + setupGeom(name, static_data, body, id, &mass, args[1], args[2], args[3], 0.0, 0.0, 0.0); return id; @@ -182,7 +182,7 @@ dGeomID OdeWorld::addCylinder(const string & name, bool static_data, dMass mass; dMassSetCylinder(&mass, 1.0, 3, args[0], args[1]); dMassTranslate(&mass, args[2], args[3], args[4]); - setupGeom(name, static_data, body, id, true, &mass, + setupGeom(name, static_data, body, id, &mass, args[2], args[3], args[4], args[5], args[6], args[7]); return id; @@ -195,9 +195,9 @@ dGeomID OdeWorld::addCCylinder(const string & name, bool static_data, return 0; dGeomID id = dCreateCCylinder(m_space, args[0], args[1]); dMass mass; - dMassSetCylinder(&mass, 1.0, 3, args[0], args[1]); + dMassSetCappedCylinder(&mass, 1.0, 3, args[0], args[1]); dMassTranslate(&mass, args[2], args[3], args[4]); - setupGeom(name, static_data, body, id, true, &mass, + setupGeom(name, static_data, body, id, &mass, args[2], args[3], args[4], args[5], args[6], args[7]); return id; @@ -211,23 +211,21 @@ dGeomID OdeWorld::addPlane(const string & name, bool static_data, float a, b, c, d; /* TODO: find a, b, c, d from args */ dGeomID id = dCreatePlane(m_space, a, b, c, d); - setupGeom(name, static_data, body, id, false, NULL, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); return id; } void OdeWorld::setupGeom(const std::string & name, bool static_data, - dBodyID * body, dGeomID geom, bool placeable, dMass * mass, + dBodyID * body, dGeomID geom, dMass * mass, float locx, float locy, float locz, float rotx, float roty, float rotz) { - if (placeable && !static_data && *body == 0) - *body = dBodyCreate(m_world); - if (placeable) - dGeomSetBody(geom, *body); - /* TODO: set up mass, location, and rotation */ - if (placeable) + if (!static_data) { + if (*body == 0) + *body = dBodyCreate(m_world); + + dGeomSetBody(geom, *body); + dMatrix3 rot; dRFromEulerAngles(rot, rotx, roty, rotz); dGeomSetRotation(geom, rot); diff --git a/OdeWorld.h b/OdeWorld.h index 91bbe0d..83300b3 100644 --- a/OdeWorld.h +++ b/OdeWorld.h @@ -40,7 +40,7 @@ class OdeWorld std::map m_objects; void setupGeom(const std::string & name, bool static_data, - dBodyID * body, dGeomID geom, bool placeable, dMass * mass, + dBodyID * body, dGeomID geom, dMass * mass, float locx, float locy, float locz, float rotx, float roty, float rotz); };