[ODE] Re: dSpaceCollide2 - quadspace vs hashspace bug
Hannes Norda
hannes.norda at gmail.com
Mon Dec 13 10:17:14 MST 2004
Due to the lack of interest in this topic I feel obliged to reply to myself. :)
I just patched in the not-so-beautiful solution here..
In dSpaceCollide2, collision_space.cpp, add these lines:
if(s1->type == dQuadTreeSpaceClass)
{
for (dxGeom *g = s2->first; g; g=g->next) {
s1->collide2 (data,g,callback);
}
}
else if(s2->type == dQuadTreeSpaceClass)
{
for (dxGeom *g = s1->first; g; g=g->next) {
s2->collide2 (data,g,callback);
}
}
else
... just before these lines:
// iterate through the space that has the fewest geoms, calling
// collide2 in the other space for each one.
if (s1->count < s2->count) {
/Hannes
On Fri, 10 Dec 2004 15:43:01 +0100, Hannes Norda <hannes.norda at gmail.com> wrote:
> Hi!
>
> I noticed that when using dSpaceCollide2 to collide a hashspace with a
> quadspace, and the hashspace contains more objects than the quadspace,
> no collision occurs.
>
> The root of the problem seems to be that the quadspace doesn't use the
> variable dxGeom *first; in dxSpace. It is always NULL.
>
> Look at this piece of code (in dSpaceCollide2, collision_space.cpp):
> // 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);
> }
> }
>
> When (hashspace->count > quadspace->count) there will be no
> collisions, since the for-loop is immediately ended.
>
> Anyone else stumbled across this and solved it nicely?
> Anyhow, I guess I will do some research and see if I can perhaps
> modify void dxQuadTreeSpace::add(dxGeom* g) and make it work. Not
> very familiar with quadspace internal structure, so we'll see what
> happens.... :)
>
> Normally this isn't an issue for me, since I store my static world in
> the quadspace and my dynamic objects in the hashspace, and I've always
> had more static objects up until I made a small test application
> yesterday. Was mildly confused when all of a sudden no collisions
> occured..
>
> /Hannes
>
More information about the ODE
mailing list