Culling (visibility helpers)
Mibo.Elmish.Culling is a tiny helper module that keeps visibility math separate from your renderer and your spatial partitioning.
It operates on MonoGame primitives:
BoundingFrustumBoundingSphereBoundingBoxRectangle
3D: frustum culling
let frustum = Camera3D.boundingFrustum camera
if Culling.isVisible frustum entitySphere then
// submit draw commands
()
Or for AABBs:
if Culling.isGenericVisible frustum nodeBounds then
()
2D: rectangle overlap
This is typically paired with Camera2D.viewportBounds:
let viewBounds = Camera2D.viewportBounds camera viewport
if Culling.isVisible2D viewBounds spriteBounds then
()
What this is not
This module doesn’t try to be your spatial index.
- If you have many objects: use a grid / quadtree / BVH / octree.
- Use these helpers at the edge: “is this node/object worth considering for rendering?”
val frustum: obj
val viewBounds: obj
Mibo