๐ Support Field#
Collision detection for convex shapes in Genesis relies heavily on support functions. Every iteration of the Minkowski Portal Refinement (MPR) algorithm asks questions of the form:
โGiven a direction d, which vertex of the shape has the maximum dot-product vยทd?โ
A naรฏve implementation has to iterate over all vertices every time โ wasteful for models containing thousands of points. To avoid this, Genesis pre-computes a Support Field for every convex geometry during scene initialisation. The implementation lives in genesis/engine/solvers/rigid/support_field_decomp.py.
How It Works#
Uniform Direction Grid โ The sphere is discretised into
support_res ร support_resdirections using longitude/latitude (ฮธ,ฯ). By defaultsupport_res = 180, giving โ32 k sample directions.Offline Projection โ For each direction we project all vertices and remember the index with the largest dot-product. The resulting arrays are:
support_v โ โ^{N_dirร3}โ the actual vertex positions in object space.support_vid โ โ^{N_dir}โ original vertex indices (useful to warm-start SDF queries).support_cell_start[i_g]โ prefix-sum offset into the flattened arrays per geometry.
Taichi Fields โ The arrays are copied into GPU-resident Taichi fields so that kernels can access them without host round-trips.
v_ws, idx = support_field._func_support_world(dir_ws, i_geom, i_batch)
The above gives you the extreme point in world-space for any query direction in O(1).
Data Layout#
Field |
Shape |
Description |
|---|---|---|
|
|
vertex positions (float32/64) |
|
|
corresponding vertex index (int32) |
|
|
offset into flattened arrays |
!!! info โMemory footprintโ With the default resolution each convex shape uses โ 32 k ร (3 ร 4 + 4) = 416 kB. For collections of small primitives this is significantly cheaper than building a BVH per shape.
Advantages#
Constant-time look-ups during MPR โ fewer diverging branches on the GPU.
GPU friendly โ the support field is a simple SOA array, no complex pointer chasing.
Works for any convex mesh โ no need for canonical-axes or bounding boxes.
Limitations & Future Work#
The direction grid is isotropic but not adaptive โ features smaller than the angular cell size may map to the wrong vertex.
Preprocessing and memory consumption would be expensive if the number of geometry is large in a scene.
API Summary#
from genesis.engine.solvers.rigid.rigid_solver_decomp import RigidSolver
solver = RigidSolver(...)
s_field = solver.collider._mpr._support # internal handle
v_ws, idx = s_field._func_support_world(dir_ws, i_geom, i_env)
v_ws is the world-space support point while idx is the vertex ID in the original mesh (global index).
Relation to Collision Pipeline#
The Support Field is an acceleration structure exclusively used by the convexโconvex narrow phase. Other collision paths โ SDF, terrain, planeโbox โ bypass it because they either rely on analytical support functions or distance fields.
For details on how MPR integrates this structure see Collision, Contacts & Forces.