[ODE] Space additions for dRay

Erwin de Vries erwin at vo.com
Sun Aug 4 12:35:01 2002


Hi,

Today i've added some new stuff to the space. (Hash & simple) The concept is
'locking' the space. A locked space is a space where no modifications to
itself and the geometries it contains are allowed. Internally the space_aabb
pointers are calculated once in a Lock()/Unlock() sequence. Nested
lock/unlock pairs are not allowed.

It can be used to do instant collision detection for (but not limited to)
rays with minimal overhead.

The implementation is as follows:

// Puts the space in locked mode.
void dSpaceLock (dSpaceID space);

// Collides a single geometry with the other geometries in the space
void dSpaceCollideGeom (dSpaceID space, dxGeom* g, void *data, dNearCallback
*callback);

// Puts the space back in normal mode.
void dSpaceUnlock (dSpaceID space);

// Tells whether the space is currently locked.
int dSpaceLocked(dSpaceID space);

Thats it. These functions do not interfere with current behavior, so it is
all backwards compatible.

A current problem is dBodySetPosition(), etc. Unlike dGeomSetPostition(),
etc, we cant assert these, because there is no telling which geometries
point to a body's data. I dont have a good solution to this problem. What
would be possible is to regenerate a list of AABB's in the dSpaceUnlock()
function, and compare it to the one generated in the previous dSpaceLock().
If they dont match, assert. Only in debugmode of course.

I'll post this soon. Would you like to add this to the core code, Russ? I
just created it, so i havent tested it much, but i will do so the next days
It passes the space test incuded with ODE. Internally i had to change some
things in the hashspace. It now uses buffered allocations (using dArray)
instead of stack allocations for the lists of objects, which of course might
be a little slower, and certainly uses more memory. But i've not yet tested
how much. Couldnt be -that- much.

Erwin