   Cube Frustum Culling - SOLVED
  I'm trying to find a way to more efficiently cull an axis-aligned cube.Right now, I'm testing all eight points against all six planes, and reacting accordingly. Everything works fine.Now, I read a paper that seems to make sense; instead of testing eight points, you can test two, the one that has to be behind the plane, if the cube is behind the plane or intersecting, and the one that has to be in front of the plane, if the cube is in front of the plane or intersecting.Now, at every frame, I extract the frustum clipping planes (stored in a float[6][4]), and then I essentially dot the vector of the cube point, (distance away from the center of the cube, (0.5,0.5,0.5), (-0.5,-0.5,-0.5), etc..), with the plane's normal vector, and find out which results in the max and min dot products. Now, if I've got this right (I might not), this should give me the point most likely to be in front and in back of the plane respectively.Here's the optimized code for doing this; storing the coordinates of the vertex that's supposed to be in front of the plane, relative to the center of a unit cube (stored in a vec3[6]):for (int C = 0; C < 6; C++) Closest[C] = Vector3DG((float)(Frustum[C][0] > 0) - 0.5f, (float)(Frustum[C][1] > 0) - 0.5f, (float)(Frustum[C][2] > 0) - 0.5f);And here's my code that checks if a cube is in the frustum.    int CubeFrustum(Point3D Center, float Scale)    {   Point3D FarPoint, NearPoint;   float Temp;   for (int C = 0; C < 6; C++){  NearPoint = Center + (CurrentEngine->Closest[C] * Scale);  Temp = CurrentEngine->Frustum[C][0] * NearPoint.X + CurrentEngine->Frustum[C][1] * NearPoint.Y + CurrentEngine->Frustum[C][2] * NearPoint.Z + CurrentEngine->Frustum[C][3];  if (Temp < 0) return BOUNDING_OUTSIDE;  FarPoint = Center - (CurrentEngine->Closest[C] * Scale);  if (Temp > 0 && CurrentEngine->Frustum[C][0] * FarPoint.X + CurrentEngine->Frustum[C][1] * FarPoint.Y + CurrentEngine->Frustum[C][2] * FarPoint.Z + CurrentEngine->Frustum[C][3] < 0) return BOUNDING_INTERSECT;   }   return BOUNDING_INSIDE;    }Now, I have no idea why this isn't working. It seems to me that it should be, but it's not.Anyone have any ideas?Solution:Ah. Interesecting one plane doesn't mean intersection; it can mean outside, if it's behind any of the other planes.[Edited by - Erondial on May 29, 2009 10:28:25 PM]