[ODE] Re: plane class with half space aabb
Tim Schmidt
tisch at uni-paderborn.de
Fri Jun 27 08:38:02 2003
This is a multi-part message in MIME format.
--------------060709010305030702060109
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
There was an error in the diff-file. This one should be ok.
--------------060709010305030702060109
Content-Type: text/plain;
name="planeWithHalfSpaceAABB.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="planeWithHalfSpaceAABB.txt"
diff -r -C 2 ode/ode/src/collision_std.cpp odenew/ode/src/collision_std.cpp
*** ode/ode/src/collision_std.cpp Fri Jun 27 15:49:06 2003
--- odenew/ode/src/collision_std.cpp Fri Jun 27 16:07:32 2003
***************
*** 65,68 ****
--- 65,69 ----
struct dxPlane : public dxGeom {
dReal p[4];
+ int halfSpaceOpenSide;
dxPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d);
void computeAABB();
***************
*** 303,306 ****
--- 304,343 ----
+ // This function detects a possible alignment of the normal
+ // vector and an axis.
+
+ static void detectAxisAlignment (dxPlane *g)
+ {
+ if (g->p[0] == -1)
+ {
+ g->halfSpaceOpenSide = 0;
+ }
+ else if (g->p[0] == 1)
+ {
+ g->halfSpaceOpenSide = 1;
+ }
+ else if (g->p[1] == -1)
+ {
+ g->halfSpaceOpenSide = 2;
+ }
+ else if (g->p[1] == 1)
+ {
+ g->halfSpaceOpenSide = 3;
+ }
+ else if (g->p[2] == -1)
+ {
+ g->halfSpaceOpenSide = 4;
+ }
+ else if (g->p[2] == 1)
+ {
+ g->halfSpaceOpenSide = 5;
+ }
+ else // not aligned
+ {
+ g->halfSpaceOpenSide = -1;
+ }
+ }
+
+
dxPlane::dxPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d) :
dxGeom (space,0)
***************
*** 312,315 ****
--- 349,353 ----
p[3] = d;
make_sure_plane_normal_has_unit_length (this);
+ detectAxisAlignment(this);
}
***************
*** 317,322 ****
void dxPlane::computeAABB()
{
- // @@@ planes that have normal vectors aligned along an axis can use a
- // @@@ less comprehensive (half space) bounding box.
aabb[0] = -dInfinity;
aabb[1] = dInfinity;
--- 355,358 ----
***************
*** 325,328 ****
--- 361,368 ----
aabb[4] = -dInfinity;
aabb[5] = dInfinity;
+ if (halfSpaceOpenSide >= 0)
+ {
+ aabb[halfSpaceOpenSide] = p[3];
+ }
}
***************
*** 344,347 ****
--- 384,388 ----
p->p[3] = d;
make_sure_plane_normal_has_unit_length (p);
+ detectAxisAlignment(p);
dGeomMoved (g);
}
--------------060709010305030702060109--