Function meshopt::ffi::meshopt_computeClusterBounds [−][src]
pub unsafe extern "C" fn meshopt_computeClusterBounds(
indices: *const c_uint,
index_count: usize,
vertex_positions: *const f32,
vertex_count: usize,
vertex_positions_stride: usize
) -> meshopt_Bounds
Experimental: Cluster bounds generator Creates bounding volumes that can be used for frustum, backface and occlusion culling.
For backface culling with orthographic projection, use the following formula to reject backfacing clusters: dot(view, cone_axis) >= cone_cutoff
For perspective projection, you can the formula that needs cone apex in addition to axis & cutoff: dot(normalize(cone_apex - camera_position), cone_axis) >= cone_cutoff
Alternatively, you can use the formula that doesn’t need cone apex and uses bounding sphere instead: dot(normalize(center - camera_position), cone_axis) >= cone_cutoff + radius / length(center - camera_position) or an equivalent formula that doesn’t have a singularity at center = camera_position: dot(center - camera_position, cone_axis) >= cone_cutoff * length(center - camera_position) + radius
The formula that uses the apex is slightly more accurate but needs the apex; if you are already using bounding sphere to do frustum/occlusion culling, the formula that doesn’t use the apex may be preferable.
vertex_positions should have float3 position in the first 12 bytes of each vertex - similar to glVertexPointer index_count should be less than or equal to 256*3 (the function assumes clusters of limited size)