When I check a sphere against my frustum (d3d dx9 engine, c++), it's all good.
Now I made a function to check a bounding box against the frustum, but it now does this:
every object is only rendered when it's inside the frustum AND somehow intersects with the frustum planes.
I've double checked the min and max positions of the bounding boxes, they're all ok.
Can someone help me out?
Here's the code:
bool CD3dcam::SphereInFrustum(D3DXVECTOR3* pPosition, float pRadius){ float fDistance; for(int i=0;i<6;++i) { fDistance = D3DXPlaneDotCoord(&mFrustumPlane, pPosition) + pRadius; if(fDistance < -pRadius) return false; // outside the frustum if((float)fabs(fDistance) < pRadius) return true; // intersects } return true; // inside the frustum completely or intersecting; see XLS}// NO PROBLEMS WITH SHERE CHECKINGbool CD3dcam::BoxInFrustum(D3DXVECTOR3* pMinPosition, D3DXVECTOR3* pMaxPosition){ float fDistance; for(int i=0;i<6;++i) { fDistance = D3DXPlaneDotCoord(&mFrustumPlane, pMinPosition); if(fDistance <= 0) return true; fDistance = D3DXPlaneDotCoord(&mFrustumPlane, pMaxPosition); if(fDistance <= 0) return true; } return false;}