[ODE] My ODE++

Jon Watte hplus-ode at mindcontrol.org
Thu Jan 8 10:15:08 MST 2004


I've been having troubles getting my messages to show up on the list. I'm copying you in person; if you don't see it on the list, can you forward it?

> very Clear, Rugged and Hierarchical c++ mplementation.
> My be then ODE will be more ealsily become "Managed
> Code".
 
The current managed wrapper in CVS isn't all that rich. I've spent some time writing one that's a little more full featured.

The approach I took was:

- write very shallow, managed classes that wrap the IDs.
- use dReal in all the interfaces (the current wrapper uses double)
- use Microsoft.DirectX classes for vector, quaternion and matrix
  This allows you to remove one copy if you use Direct3D, and it does not change the number of copies required otherwise -- although it does require Microsoft.DirectX being installed.

Also, the current managed version in CVS transposes matrices when going into ODE, but doesn't transpose quaternions; it claims to do this because of "left handedness" which is wrong AFAICT.

I chose to make the classes NOT own the Ids, because I need to return classes from functions like dGeomGetBody(). Instead, it's up to you to call Destroy on an instance to deallocate the un-managed sub-part. An alternative would be to keep the managed class in user data (which, because it's un-managed, is a real pain), or keep a hash table of Id->Class instances. In both cases, that would mean that there was a permanent reference to the class, so garbage collection wouldn't happen, and you'd have to dispose the object manually anyway, so having light-weight objects containing the Id seemed better. I may turn these into __value structs even (haven't yet).

I also lowered the impedance in usage by adding flavors of geometry building for trimesh that take a Mesh instance, or that take a GraphicsStream for vertices.

The big pain is the callbacks. I chose to keep the callbacks on the C++ side for collision, just assembling a list of collision descs; this list is returned as a result of calling collision, and then you can go through it, add joints, etc. Yeah, this means more copying, but that's not where the big bottleneck is in most systems. And, it's managed code; it does require copying no matter what you want, unless you're prepared to tag all of ODE internals with __value and __gc tags and change it to abide by the Managed rules. (Hint: you don't).

So, I'm playing around with this, and initially it looks pretty decent, but it's not full yet, it only builds on my machine, it has a bunch of hacks to get it working, blah blah blah and I'll probably lose interest before it's production worthy. But in the unlikely event that I don't, I'd be happy to contribute it back to CVS.

Cheers,

			/ h+




More information about the ODE mailing list