๐Ÿš€ 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#

  1. Uniform Direction Grid โ€“ The sphere is discretised into support_res ร— support_res directions using longitude/latitude (ฮธ, ฯ•). By default support_res = 180, giving โ‰ˆ32 k sample directions.

  2. 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.

  3. 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

support_v

(N_cells, 3)

vertex positions (float32/64)

support_vid

(N_cells,)

corresponding vertex index (int32)

support_cell_start

(n_geoms,)

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.