Skip to content

Culling

John Chapman edited this page Jan 14, 2018 · 2 revisions

Culling permits optimization by skipping work for objects which lie outside the view volume and are therefore not visible.

Im3d provides two optional internal culling methods, plus helper functions which allow external culling by the application. In both cases the application is required to fill AppData::m_cullFrustum to define the view volume.

Internal Culling

Internal culling is disabled by default. There are two options for internal culling, enabled via the following defines in im3d_config.h:

  • IM3D_CULL_PRIMITIVES culls primitives during End(). This is generally not as efficient as simply allowing primitives to be drawn, except for a large number of primitives with sorting enabled. In practice this should only used where it isn't practical to skip Im3d calls by culling on the application side.
  • IM3D_CULL_GIZMOS allows Gizmo*() calls to exit early if the gizmo is outside the view volume. This is more practical than IM3D_CULL_PRIMITIVES because gizmos always have a higher computational cost than performing the culling operation.

External Culling

External culling is simply a case of skipping calls to Im3d on the application side. The following helper functions are available:

  • bool IsVisible(const Vec3& _origin, float _radius) - sphere-frustum intersection test.
  • bool IsVisible(const Vec3& _minExtents, const Vec3& _maxExtents) - AABB-frustum intersection test.

These helper functions use the culling planes set by the application.

Clone this wiki locally