Ive also tried with the bleeding edge odedotnet code from the svn repository, but it doesnt change anything.
![Sad :(](./images/smilies/icon_sad.gif)
My collision code: http://pastebin.kubuntu-de.org/5336
The OnCollision method is the same as in the howto.
May someone give a hint?
Code: Select all
if(b1 == null || b2 == null)
{
u.print("b1 oder b2 == null", true);
}
else
{
if(b1.ConnectedToExcluding(b2, JointType.Contact))
return;
}
Code: Select all
ContactGeom[] contactgeoms = e.Geom1.Collide(e.Geom2, 13);
Contact[] contact = new Contact[contactgeoms.Length];
I don't think you need this. Just use c.Attach(b1, b2); as before. Bodies with IntPtr.zero handles are the same as the surrounding space...Edit: Okay, simply changing the c.Attach(...) in line 35 from (b1, b2) to (b1, null)
Code: Select all
dBodyID b1 = dGeomGetBody(o1);
dBodyID b2 = dGeomGetBody(o2);
// don't generate contacts if both are bodiless.
// this is mainly to prevent intersecting static geoms (e.g. scenery) from hogging resources.
// however in some cases this would be undesirable (e.g. you have non physically simulated objects
// that you still want to detect collisions with... Ghosts maybe?)
if ( !(b1 || b2) ) return;
// If both geoms have bodies, which are joined by a non contact joint, then return.
// e.g. could be useful for a ragdoll, if limbs overlap.
if (b1 && b2 && dAreConnectedExcluding(b1, b2, dJointTypeContact)) return;
// array of available contact points
const int MAX_CONTACTS = 12;
dContact contact[MAX_CONTACTS];
int numc = dCollide(o1, o2, MAX_CONTACTS, &contact[0].geom, sizeof(dContact));
// No contacts
if (numc == 0) return;
// ignore ray collisions
if ( (dGeomGetClass(o1) == dRayClass) || (dGeomGetClass(o2) == dRayClass))
{
return;
}
// for each contact, create an actual contact joint between two bodies
// these will be removed after simulation stepping
for (int i = 0; i < numc; i++)
{
contact[i].surface.mode = dContactBounce | dContactSoftCFM;
contact[i].surface.mu = 100;
contact[i].surface.bounce = 0;
contact[i].surface.bounce_vel = 0;
contact[i].surface.soft_cfm = 0;
dJointID c = dJointCreateContact(dWorld, dPerStepContactJointGroup, contact+i);
dJointAttach(c, b1, b2);
}
I know that in the cpp-version the last parameter of dCollide is sizeof(*contactgeomarray*). Now I tried to imitate this value by using contactgeomarray.Length, but that doesnt do the job.ODE INTERNAL ERROR 1: assertion "skip >= (int)sizeof(dContactGeom)" failed in dCollideBoxBox()
As you can see, I have filled an array of ContactGeoms with the ones of the contact-array and it at least doesnt provoke an error... Or is it supposed to be something else?IntPtr o1,
IntPtr o2,
int flags,
d.ContactGeom[] contact,
int skip
Code: Select all
static void near(IntPtr space, IntPtr g1, IntPtr g2)
{
IntPtr b1 = d.GeomGetBody(g1);
IntPtr b2 = d.GeomGetBody(g2);
if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
return;
int count = d.Collide(g1, g2, MAX_CONTACTS, contacts, d.ContactGeom.SizeOf);
for (int i = 0; i < count; ++i)
{
contact.geom = contacts[i];
IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact);
d.JointAttach(joint, b1, b2);
}
}
Code: Select all
contact[i].geom = geoms[i];