[ODE] Autodisable

Joe Ante joe at uti.is
Sat May 29 18:38:08 MST 2004


Hi Russ and others,

Here are the patches for the disable body / enable body callbacks.
www.otee.dk/Joe/autodisablepatch
I added several functions. Two which you might wonder why I added them are:

dBodyGetGeom () I needed this in order to switch between enabled/disabled
spaces in the enable / disable body callback.

dBodyIsResting () I needed this to visualize the contacts in the same way it
was done in the old test_crash.


I originally thought I could just move geoms between an enabled space and
disabled space based on their bodies enabled state and then dSpaceCollide
the enabled space and dSpaceCollide2 (disableSpace, enabledSpace);

That however doesn¹t work and it introduces jitter in the simulation. You
can easily see the problem by adding:
    if (b1 && b2 && !dBodyIsEnabled (b1) && !dBodyIsEnabled (b2))
        return;
To test_crash nearcallback.


Why does it fail:
Imagine 2 disabled bodies stacked and sleeping. Then a third falling down.
This will generate a contact between the upper sleeping box and the falling
box. But in the first frame no contact will be created between the lower and
upper sleeping boxes. Which means that the upper sleeping box can freely
push downwards for one step. This makes the box stacks wobble up and down.


To overcome this problem I looked into creating a new dxSpace which would
work like Oles described it a few days ago it but it would have required a
change to dxGeom (adding another geoms linked list)

For simplicity (The code to do it turned out surprisingly big though) I
created a class which generates contacts between disabled bodies properly
while not wasting time colliding disabled bodies and generating contacts
between them if its not necessary. The code uses the stl internally. I see
this as a temporary solution to optimize the collision detection, the real
solution involves writing a proper space that hides all the cruft from the
user. The DualSpace.h however works for now and it has a similar interface
as the spaces and uses spaces internally.
 
I created a new_crash_test.cpp which is like crash_test but using the Dual
Space, I also changed the code to use the ode's builtin autodisable code
instead of the autodisable code that was written directly inside crash test.

www.otee.dk/Joe/DualSpace.cpp
www.otee.dk/Joe/DualSpace.h
www.otee.dk/Joe/new_crash_test.cpp


Any way, ive profiled the code and it made a big difference for my test
scenes. If you have a big amount of sleeping bodies in a scene and a small
amount of enabled bodies you will see a big performance improvement in
collision detection speed. If your scene is made up of only enabled bodies
you wont see any performance improvement.

Joe Ante




More information about the ODE mailing list