[ODE] Bodies and Worlds

Russ Smith russ at q12.org
Thu Nov 15 15:27:02 MST 2001


> It would be nice if I could create a body without adding it to a world, or
> deactivate the physics for a body without having its properties (mass, etc)
> be deleted.
> An extension of this would be the ability to transfer bodies between worlds.
> 
> I suggest the following methods be appended to the interface:
> dBodyID dBodyCreate (void);
> void dAddBodyToWorld(dWorldID,dBodyID);
> void dRemoveBodyFromWorld(dWorldID,dBodyID);

i have considered this issue. there are two main ways to deactivate
a body:
  1. remove it from the world, or
  2. set a "disabled" flag on it.

the problem with option 1 is automatic re-enabling of bodies.
for example, you remove a bunch of bodies from the world - but
you want them to be automatically reinserted/reactivated when
something else in the world touches them. but they're no longer
in the world - so what world do they get inserted into --> the
world of the touching bodies ... but what about if bodies from
two different worlds touch a body that is in no world? BTW, by
"touch" i mean "connect a joint between". you could easily
have the situation where your system lived in two different
worlds. the basic problem is that you are allowing non world
bodies to participate in a world, which complicates things.

the solution recommended by erwin, that i have just implemented,
is this:
  void dBodyDisable (body)
  void dBodyEnable (body)
  int dBodyIsEnabled (body)

these function set a "disabled" flag on the body, so it wont be
included in any computations. bodies get reenabled when they
are touched by an active body. the actual code change to
implement this was very small. anyway, i wrote a whole doc section
on this which should be available via CVS in a few days.

to transfer bodies between worlds (and groups of bodies without
breaking the joint connections) there will be explicit functions
to do this.

one argument in favour of the no-arg dBodyCreate() is that it makes
the C++ interface easier (e.g. creating arrays of bodies). but i
think the advantages of forcing everything to be in a world outweigh
that.

dissenting opinions are of course welcome.

russ.

--
Russell Smith
http://www.q12.org



More information about the ODE mailing list