simvx.graphics.scene.frustum

View frustum culling utilities.

Module Contents

Classes

Frustum

View frustum defined by 6 planes for culling.

Data

API

simvx.graphics.scene.frustum.log

‘getLogger(…)’

simvx.graphics.scene.frustum.__all__

[‘Frustum’]

class simvx.graphics.scene.frustum.Frustum

View frustum defined by 6 planes for culling.

Initialization

extract_from_matrix(vp: numpy.ndarray) None

Extract frustum planes from view-projection matrix.

Planes: left, right, bottom, top, near, far.

The side planes come from the -w <= x, y <= w clip conditions, which no depth convention touches. The depth pair comes from 0 <= z <= w, the volume both backends enforce, read in the engine’s reverse-Z sense: the near plane is z <= w and the far plane is z >= 0. Reading the OpenGL z >= -w for “near” would keep everything out to roughly twice the near distance that the GPU then clipped anyway, so the cull and the rasteriser would disagree about what is in front of the camera.

test_sphere(center: numpy.ndarray, radius: float) bool

Test if sphere intersects or is inside the frustum.

cull_spheres(centers: numpy.ndarray, radii: numpy.ndarray) numpy.ndarray

Vectorized frustum cull for many bounding spheres.

Args: centers: (N, 3) array of sphere centers. radii: (N,) array of radii.

Returns: boolean mask (N,): True = visible.