This seems to be occasionally culling things that are visible on screen when rendering with all world coordinates within the AABB and the same view and projection matrix... The code is pretty straight forward, so not sure what the issue is?
XMMATRIX xmproj = XMMatrixPerspectiveFovLH(fov, aspectRatio, 0.1f, 1000.0f);
XMMATRIX xmview;
xmview = XMMatrixTranslation(-x, -y, -z);
xmview *= XMMatrixRotationY(-yaw);
xmview *= XMMatrixRotationX(-pitch);
...
class Frustum
{
public:
void update(XMMATRIX projection, XMMATRIX view)
{
frustum.CreateFromMatrix(frustum, projection);
frustum.Transform(frustum, view);
}
bool contains(const AxisAlignedBoundaryBox3F &aabb)const
{
//AxisAlignedBoundaryBox3 is (min,max) but DirectX::BoundingBox is (centre,extents)!
Vector3F p1 = aabb.p1;
Vector3F p2 = aabb.p2;
Vector3F size = p2 - p1;
Vector3F centre = p1 + size / 2.f;
XMFLOAT3 xsize(size.x, size.y, size.z);
XMFLOAT3 xcentre(centre.x, centre.y, centre.z);
bool ret = frustum.Contains(BoundingBox(xcentre, xsize)) != DISJOINT;
assert(ret || frustum.Intersects(BoundingBox(xcentre, xsize)) == DISJOINT);
return ret;
}
private:
BoundingFrustum frustum;
};