[ODE] dGeomMoved hook

Jon Watte (ODE) hplus-ode at mindcontrol.org
Sun Oct 14 15:42:46 MST 2007

Thanks for paying attention!

I don't like the name for dGeomGetBodyNext(), even if it was there 
before. dBodyGetFirstGeom() and dBodyGetNextGeom() would be good names, 
I suppose -- except you'd pass a geom to the second function...

dGeomGetBodyNext() sounds as if a geom has more than one body (which 
isn't true). However, I undestand it's already existing, and it's hard 
to come up with a better name.

I don't like this part, though, as the callback might get called more 
than once per body -- and you don't get a callback if the body has no 
geom. Sorry to be so difficult :-) I think the callback could better 
live inside the body disable/sleep code.

--- ode/src/collision_space.cpp	(revisão 1288)
+++ ode/src/collision_space.cpp	(cópia de trabalho)
@@ -47,6 +47,10 @@
    dAASSERT (geom);

+  // notify the user the body moved
+  if (geom->body && geom->body->moved_callback)
+    geom->body->moved_callback(geom->body);
    // if geom is offset, mark it as needing a calculate
    if (geom->offset_posr) {
      geom->gflags |= GEOM_POSR_BAD;


			/ h+

Daniel K. O. wrote:
> Jon Watte (ODE) escreveu:
>> I don't think this should be per geom, because you may have many geoms
>> for a single body. The logical place to put it is on the body. Geoms
>> without a body don't move at all.
> Indeed, thanks for pointing this out. I attached a second patch for
> dBodySetMovedCallback() instead:
> http://sourceforge.net/tracker/index.php?func=detail&aid=1813079&group_id=24884&atid=382801
> This also exposes dGeomGetBodyNext(), and creates a dBodyGetFirstGeom().
> I know I should submit it in another patch, but IMHO if you want to do
> something interesting (like destroying bodies that are too far away,
> like projectiles) you may need access to the geoms (to destroy them too).

More information about the ODE mailing list