Skip to content

Convex decomposition for arbitrary geometry (automatic collision hulls) #187

Open

Description

@bdero

The analytic primitives expose a matching collisionShape, but arbitrary imported or generated meshes have no automatic hull. Add convex decomposition so any Geometry (or TriMeshShape) can produce an accurate CompoundShape of convex pieces.

Suggested approach. Expose parry's V-HACD through the flutter_scene_rapier FFI, which avoids porting the algorithm to Dart, with a Dart API such as decomposeToCompound(geometry, {params}). Because V-HACD is too slow to run per spawn, also support baking hulls ahead of time (decompose at asset-build time via the build hook and ship the result), with runtime decomposition as the convenience path.

Dynamic bodies need convex pieces, since a raw triangle-mesh collider is static-only, which is exactly what decomposition provides.

Context. The convention so far is that each analytic primitive returns its matching collisionShape (box, sphere, capsule, cylinder, convex hull, plus compound shapes for the torus and ring). Arbitrary geometry is the remaining gap.

Activity

  1. added
    roadmapPlanned long-horizon work owned by maintainers.
    on Jun 28, 2026
  2. hiSandog commented on Jul 11, 2026

    @hiSandog

    V-HACD through Rapier is a good backend, but the API should expose deterministic parameters, cancellation/progress, and limits on hull count/vertices because runtime decomposition can be expensive on mobile. Build-time baking should serialize a versioned hull asset keyed by source mesh plus parameters so stale results are invalidated. Tests should compare runtime and baked compounds, preserve transforms/winding, reject degenerate meshes, and verify FFI allocations are released on failure.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    roadmapPlanned long-horizon work owned by maintainers.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions