2
I’m using the library ODE (Open Dynamics Engine) to simulate physics in my application. To create the bounding box and cylinder geometry I am using the following code
dMass m1;
dMassSetZero(&m1);
dMassSetCappedCylinderTotal(&m1, mass, 2, lx/2.0, lz);
dBodySetMass(body, &m1);
dBodySetPosition(body, x0, y0, z0);
dBodySetRotation(body, R);
dGeomID geom = dCreateCylinder(PhysicsEngine::space, lx / 2.0, lz);
dGeomSetBody(geom, body);
No error is generated, and object is generated correctly. However when performing collision handling:
const int N = 100;
dContact contact[N];
int n = dCollide(o1, o2, N, &contact[0].geom, sizeof(dContact));
for (int i = 0; i < n; i++) {
contact[i].surface.mode = dContactSlip2 | dContactSlip1;
contact[i].surface.mu = dInfinity;
contact[i].surface.slip1 = 0.1;
contact[i].surface.slip2 = 0.1;
dJointID c = dJointCreateContact(PhysicsEngine::world, PhysicsEngine::contactgroup, &contact[i]);
dJointAttach(c, dGeomGetBody(contact[i].geom.g1), dGeomGetBody(contact[i].geom.g2));
}
The engine recognizes collisions of:
- Flat and Cylinder
- Cube and Cylinder
- Ball and Cylinder
but does not recognize Cylinder with Cylinder, as in the image
Does anyone have any idea what it might be? I’m using the current version of the library, available in this repository and used the following command to compile it
./premake4.exe --with-tests --with-libccd --with-demos vs2010
Take a look at the library’s own wiki documentation in the section Collision Tests Supported. There is a note (note 3) saying that collisions between cylinders require the libccd is enabled. Maybe that’s what’s missing.
– Luiz Vieira
Only now have I noticed that in your command line you actually already include the libccd. Well, other than that, maybe you’re picking up Dlls from a wrong place? Another thing: your "collision treatment" actually creates Joints. The problem is in the creation of the Joints or in fact the call of
dCollide
not working? Debug to be sure.– Luiz Vieira
@Luizvieira Valeu, it worked fine. I had recompiled, but I only updated the headers (.h) and the libraries (.lib), but I didn’t update the DLL. As I did not present errors I thought everything was in order
– Sveen
https://imgur.com/a/xyjOWwT
– Sveen
The collision treatment takes place in a loop, and recovers all collisions with dCollide, then I configure the forces through dCreateContact
– Sveen
I’m glad it worked. Good luck.
– Luiz Vieira