[ODE] Re: plane class with half space aabb

Erwin de Vries erwin at vo.com
Sat Jun 28 01:17:01 2003


Looks interesting. Instead of adding an int to every plane i would use the
available gflags member in dxgeom though. There are lots of unused bits in
there, that can be used for these purposes.

I would like to define a new rule in ODE that says a geometry implementation
may use every bit above 0xffff. The geomtransform class would also benefit
from this. It would save 8 bytes there.

Erwin

----- Original Message -----
From: "Tim Schmidt" <tisch@uni-paderborn.de>
To: <ode@q12.org>
Sent: Friday, June 27, 2003 17:11
Subject: [ODE] Re: plane class with half space aabb


>
> There was an error in the diff-file. This one should be ok.
>


----------------------------------------------------------------------------
----


> 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);
>   }
>