[ODE] dxHashSpace::collide2

Adam D. Moss aspirin at ntlworld.com
Tue Jan 28 11:45:02 2003


This is a multi-part message in MIME format.
--------------6AA5026233094F9AEC49DF81
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi!

I implemented dxHashSpace::collide2() in the O(n^2) manner
of dxSimpleSpace::collide2() since I was happier to have a
relatively inefficient implementation than have no implementation
at all (and an implicit abort()).

The patch for this is attached.

I know it'd be significantly nicer to have an implementation that
really took advantage of the hash structure when collide2()ing
geoms with a hash-space, to avoid the O(n1*n2).  I assume that's
why Russ left the function stubbed-out.

--Adam
-- 
Adam D. Moss   . ,,^^   adam@gimp.org   http://www.foxbox.org/   co:3
--------------6AA5026233094F9AEC49DF81
Content-Type: text/plain; charset=us-ascii;
 name="ODE-COLLIDE2.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ODE-COLLIDE2.diff"

Index: ode/src/collision_space.cpp
===================================================================
RCS file: /cvsroot/opende/ode/ode/src/collision_space.cpp,v
retrieving revision 1.4
diff -u -u -r1.4 collision_space.cpp
--- ode/src/collision_space.cpp	9 Dec 2002 01:12:02 -0000	1.4
+++ ode/src/collision_space.cpp	28 Jan 2003 18:35:47 -0000
@@ -620,8 +620,21 @@
 void dxHashSpace::collide2 (void *data, dxGeom *geom,
 			    dNearCallback *callback)
 {
-  //@@@
-  dDebug (0,"dxHashSpace::collide2() not yet implemented");
+  dAASSERT (geom && callback);
+
+  // this could take advantage of the hash structure to avoid
+  // O(n^2) complexity, but it does not yet.
+
+  lock_count++;
+  cleanGeoms();
+  geom->recomputeAABB();
+
+  // intersect bounding boxes
+  for (dxGeom *g=first; g; g=g->next) {
+    collideAABBs (g,geom,data,callback);
+  }
+
+  lock_count--;
 }
 
 //****************************************************************************

--------------6AA5026233094F9AEC49DF81--