d3dx8: [patch 2/2] Implement D3DXBoxBoundProbe

H. Verbeet hverbeet at gmail.com
Mon Jul 28 12:45:27 CDT 2008

2008/7/28 David Adam <david.adam.cnrs at gmail.com>:
> +     ortho = D3DXVec3Dot(praydirection, &normal[i]);
> +     if ( ortho && D3DXVec3Subtract(&difference, &point, prayposition) )
> +     {
> +      t = D3DXVec3Dot(&difference, &normal[i]) / ortho;
While correct, due to the fact that the box is axis-aligned, this just
turns into an expensive way to calculate
t = (point->x - prayposition->x) / praydirection->x
t = (point->y - prayposition->y) / praydirection->y
t = (point->z - prayposition->x) / praydirection->z
depending on the face you're testing against. I think performance wise
it makes more sense to just write it out for each face, and get rid of
the for-loop and normal.

> +    if ( number_intersection == 2 ) return TRUE;
This implies that eg. a ray that starts inside the box doesn't
intersect it. Is that intentional? Otherwise you could return early as
soon as you find an intersection, and skip testing the other faces.
Also note that at least in theory the ray can intersect all six faces
of the box if it goes through two opposing corners.

More information about the wine-patches mailing list