Quadtree space and dSpaceCollide2
Christian Muschick <[email protected]> Fri, 16 Nov 2007 12:19:19 +0100
| Newsgroups | gmane.comp.lib.ode |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------080009010603090808040703
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hello!
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
meantime?
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)
regards
chris
--------------080009010603090808040703
Content-Type: text/x-patch;
name="dspacecollide2.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="dspacecollide2.patch"
Index: collision_space.cpp
===================================================================
--- collision_space.cpp (revision 1314)
+++ collision_space.cpp (working copy)
@@ -761,11 +761,15 @@
// iterate through the space that has the fewest geoms, calling
// collide2 in the other space for each one.
if (s1->count < s2->count) {
+ dAASSERT (s1->count == 0 || s1->first != NULL,
+ "Cannot enumerate space geoms in dSpaceCollide2.");
for (dxGeom *g = s1->first; g; g=g->next) {
s2->collide2 (data,g,callback);
}
}
else {
+ dAASSERT (s2->count == 0 || s2->first != NULL,
+ "Cannot enumerate space geoms in dSpaceCollide2.");
for (dxGeom *g = s2->first; g; g=g->next) {
s1->collide2 (data,g,callback);
}
--------------080009010603090808040703
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ODE mailing list
[email protected]
http://ode.org/mailman/listinfo/ode
--------------080009010603090808040703--