Tao.Ode: vector has zero size

Greetings,

First of all, let me thank you for the remarkable work you have done in producing this great API. I don´t know if this is an issue so here it goes:

I´ve been doing some coding in Tao.Ode. I wanted to simulate a simple sphere rolling on an inclined plane. So i did the usual initializations, created the sphere with the dCreateSphere method and for the plane i created a model in 3ds max and imported it in opengl. The plane is perfectly rendered in opengl. I start by making the sphere fall direct to the plane. Sometimes the sphere collides with the plane and bounces off, but in 90% of the cases, my application stops and i keep receiving this message in the console:

ODE Message 2: vector has zero size (\Local\ode\tools\ode-0.6\ode\src\odemath.cpp:129

This happens in this call:
Ode.dJointAttach(joint, b1, b2);

My Collision callback is:

private void CollisionCallback(IntPtr data, IntPtr o1, IntPtr o2)
{
int MAX_COLLISIONS = 10;

IntPtr b1 = Ode.dGeomGetBody(o1);
IntPtr b2 = Ode.dGeomGetBody(o2);

if (b1 == null || b2 == null)
return;

Ode.dContactGeom[] contactGeoms = new Ode.dContactGeom[MAX_COLLISIONS];
int numc = Ode.dCollide(o1, o2, MAX_COLLISIONS, contactGeoms, System.Runtime.InteropServices.Marshal.SizeOf(contactGeoms[0]));
Ode.dContact[] contact = new Tao.Ode.Ode.dContact[numc];

for (int i = 0; i < contact.Length; i++)
{
contact[i].surface.mode = (int)Ode.dContactFlags.dContactBounce | (int)Ode.dContactFlags.dContactSoftCFM | (int)Ode.dContactFlags.dContactSlip1 | (int)Ode.dContactFlags.dContactSlip2; ;
contact[i].surface.mu = Ode.dInfinity;
contact[i].surface.mu2 = 0;
contact[i].surface.bounce = 0.6f;
contact[i].surface.soft_cfm = 0.005f;

contact[i].geom = contactGeoms[i];
}

for (int i = 0; i < numc; i++)
{
IntPtr joint = Ode.dJointCreateContact(world, contactgroup, ref contact[i]);
Ode.dJointAttach(joint, b1, b2);
}
}

Am i doing something wrong?
Thanks in advance!,

Pedro Costa

PS: Btw i´m using the most recent version of TAO.Ode.

Theme by La Boite a site | Powered by Drupal