[ODE] Quadtree space and dSpaceCollide2

Christian Muschick christian.muschick at gmail.com
Fri Nov 16 04:19:19 MST 2007


I don't know why my last post on this topic got no reply, perhaps 
because it was an answer to an ancient message. Anyway, here I go again:

dSpaceCollide2 is broken when used with quadtree spaces. The reason for 
this is that geoms cannot currently be enumerated for quadtree spaces. 
Now when colliding quadtree vs quadtree space or quadtree vs hashspace 
with less geoms in the quadtree, the collision call is silently ignored.

The relevant code in collision_space.cpp (s1->first always is NULL if s1 
is a quadtree space, same goes for s2->first):

	// iterate through the space that has the fewest geoms, calling
	// collide2 in the other space for each one.
	if (s1->count < s2->count) {
	  for (dxGeom *g = s1->first; g; g=g->next) {
	    s2->collide2 (data,g,callback);
	else {
	  for (dxGeom *g = s2->first; g; g=g->next) {
	    s1->collide2 (data,g,callback);

Because this behaviour cost me an entire day, I suggest at least to 
insert assertions so this doesn't go unnoticed. Workarounds at the 
application level are possible, e.g. iterate manually over hashspace 
geoms if the ode would iterate over quadtree geoms.

The last time this came up, workarounds in dSpaceCollide2 (such as 
testing whether one space is a quadtree and reversing the test if 
neccessary) were deemed not acceptable. Perhaps this has changed in the 

The best solution of course would be to implement iterating over 
quadtree geoms. This has been a missing feature for quite some time now, 
so I assume there is some difficulty involved? As I don't have too much 
time (who has...), I would like to hear opinions on the topic before 
digging into the code...

For now I have attached a patch which at least aborts the program 
instead of ignoring the issue (UNTESTED, with the purpose to get a 
discussion going)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dspacecollide2.patch
Type: text/x-patch
Size: 799 bytes
Desc: not available
Url : http://ode.org/pipermail/ode/attachments/20071116/840ef21d/dspacecollide2.bin

More information about the ODE mailing list