Skip to content

Expose marching cubes lookup tables for custom implementations #1151

Closed

Description

@shi-eric

Description

Problem

Projects implementing custom marching cubes variants need access to the fundamental lookup tables (case-to-triangle mappings, corner offsets, etc.), but these are currently private in warp.marching_cubes.

For example, Newton implements a specialized MC variant for SDF isosurface extraction in hydroelastic contact. It works with wp.Volume data and computes physics properties per-triangle in GPU kernels. This requires the lookup tables but not Warp's extraction functions.

Currently, Newton accesses private internals:

tri_range_table = wp.marching_cubes._get_mc_case_to_tri_range_table(device)
tri_local_inds_table = wp.marching_cubes._get_mc_tri_local_inds_table(device)
corner_offsets_table = wp.array(wp.marching_cubes.mc_cube_corner_offsets, ...)

Proposed Solution

Expose the lookup tables as public constants using native Python lists:

from warp.marching_cubes import (
    MC_CUBE_CORNER_OFFSETS,   # 8 corners: [[0,0,0], [1,0,0], ...]
    MC_EDGE_TO_CORNERS,       # 12 edges: [[0,1], [1,2], ...] (NEW)
    MC_CASE_TO_TRI_RANGE,     # 257 ints
    MC_TRI_LOCAL_INDICES,     # 820 ints
)

# Users create wp.array with desired dtype/device
corner_offsets = wp.array(MC_CUBE_CORNER_OFFSETS, dtype=wp.vec3ub, device=device)

Tables to Expose

Constant Size Description
MC_CUBE_CORNER_OFFSETS 8×3 3D offsets for cube corners
MC_EDGE_TO_CORNERS 12×2 Corner pairs for each edge (new)
MC_CASE_TO_TRI_RANGE 257 Case → triangle range indices
MC_TRI_LOCAL_INDICES 820 Edge indices for triangle vertices

Why Python Lists?

  • wp.array() accepts lists directly
  • Users can work with the data using their preferred framework without converting from numpy
  • Consistent with existing mc_cube_corner_offsets which is already a list

What NOT to Expose

The caching functions (_get_mc_*_table), extraction functions, and kernels should remain private—they're implementation details.


Additional Context

  • MC_EDGE_TO_CORNERS doesn't currently exist in Warp; Newton manually recreates it

Activity

  1. added this to the 1.12.0 milestone on Jan 6, 2026
  2. added theissue type on Jan 6, 2026
  3. self-assigned this
    on Jan 14, 2026
  4. shi-eric commented on Feb 3, 2026

    @shi-eric
    ContributorAuthor

    This was added in 0b57781. The change to Newton will not be made for some time to avoid unnecessarily restricting Newton to Warp 1.12.0 and higher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions