[Solved] Tao.Ode TriMesh problem

Started by
0 comments, last by deavik 16 years, 3 months ago
Hello all, I was just trying to get to know Ode a little more with the wonderful Tao.Ode. I got a simple box falling under gravity and colliding with a plane (Ode plane). But then I tried to replace that with a trimesh containing 4 triangles and I'm having lots of problems. - My box bounces once and then "falls through" the trimesh. The number of contacts return by dCollide becomes 0 when this starts. Here is my "NearCallback" function:

	static private void NearCallback(IntPtr data, IntPtr o1, IntPtr o2) {
		IntPtr b1 = Ode.dGeomGetBody(o1);
		IntPtr b2 = Ode.dGeomGetBody(o2);
		
		Ode.dContact[] contacts = new Ode.dContact[4]; //max of 4 contacts
		Ode.dContactGeom[] contactGeoms = new Ode.dContactGeom[contacts.Length];
		
		int numContacts = Ode.dCollide(o1, o2, contactGeoms.Length, contactGeoms, Marshal.SizeOf(contactGeoms[0]));
		
		Console.Write("{0},", numContacts);
		
		for (int i=0; i<numContacts; ++i) {
			// set surface contact parameters
			contacts.surface.mode = (int) (Ode.dContactFlags.dContactBounce|Ode.dContactFlags.dContactSoftCFM);
			contacts.surface.mu = Ode.dInfinity;
			contacts.surface.mu2 = 0f;
			contacts.surface.bounce = 0.01f;
			contacts.surface.bounce_vel = 0.1f;
			contacts.surface.soft_cfm = 0.01f;
			
			contacts.geom = contactGeoms;
			
			IntPtr joint = Ode.dJointCreateContact(worldId, contactGroupId, ref contacts);
			Ode.dJointAttach(joint, b1, b2);
		}
	}


- I get segfaults (at first I thought they were random, now it crashes consistently after collision):

Stacktrace:

  at (wrapper managed-to-native) Tao.Ode.Ode.dCollide (intptr,intptr,int,Tao.Ode.Ode/dContactGeom[],int) <0x0000e>
  at (wrapper managed-to-native) Tao.Ode.Ode.dCollide (intptr,intptr,int,Tao.Ode.Ode/dContactGeom[],int) <0xffffffff>
  at glfwtest.App.NearCallback (intptr,intptr,intptr) [0x0001e] in /mnt/home/src/dotnet/glfwtest/src/Main.cs:367
  at (wrapper native-to-managed) glfwtest.App.NearCallback (intptr,intptr,intptr) <0xffffffff>
  at (wrapper managed-to-native) Tao.Ode.Ode.dSpaceCollide (intptr,intptr,Tao.Ode.Ode/dNearCallback) <0x0000e>
  at (wrapper managed-to-native) Tao.Ode.Ode.dSpaceCollide (intptr,intptr,Tao.Ode.Ode/dNearCallback) <0xffffffff>
  at glfwtest.App.RunPhysics () [0x00000] in /mnt/home/src/dotnet/glfwtest/src/Main.cs:405
  at glfwtest.App.Main (string[]) [0x000d5] in /mnt/home/src/dotnet/glfwtest/src/Main.cs:142
  at (wrapper runtime-invoke) glfwtest.App.runtime_invoke_int_string[] (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

	/usr/bin/mono [0x52e45d]
	/usr/bin/mono [0x4f643e]
	/lib/libc.so.6 [0x2b2d5cc13120]
	/usr/lib/libode.so(_ZN6Opcode11OBBCollider8_CollideEPKNS_14AABBNoLeafNodeE+0x4c6) [0x2aaab4b91726]
	/usr/lib/libode.so(_ZN6Opcode11OBBCollider8_CollideEPKNS_14AABBNoLeafNodeE+0x16f5) [0x2aaab4b92955]
	/usr/lib/libode.so(_ZN6Opcode11OBBCollider7CollideERNS_8OBBCacheERKN8IceMaths3OBBERKNS_5ModelEPKNS3_9Matrix4x4ESC_+0x120) [0x2aaab4b95e60]
	/usr/lib/libode.so(_Z11dCollideBTLP6dxGeomS0_iP12dContactGeomi+0x13a8) [0x2aaab4b6ead8]
	/usr/lib/libode.so(dCollide+0xeb) [0x2aaab4b275ab]
	[0x4028ca60]

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================


I'm confused as everything worked fine when the geometry was a plane created with dCreatePlane. Oh, and for debugging I called dGeomTriMeshGetTriangle for every triangle and the vertices are correct. I would much appreciate some tips, as the code that changed from plane->trimesh was minimal and I don't know where something could have gone wrong. Thanks! [Edited by - deavik on January 4, 2008 1:18:02 PM]
Advertisement
Well I said I was new to Ode and I definitely have a lot to learn :)

Ode doesn't make a copy of the TriMesh data, and the pointers you give it have to remain throughout the running time of the app.

This topic is closed to new replies.

Advertisement