Soft Bodies & Cloth

World supports deformable meshes and cloth via Jolt’s SoftBodySharedSettings / SoftBodyCreationSettings.

Creating a Soft Body

import numpy as np
import joltsim

w = joltsim.World()
w.add_ground_plane(z=0.0)

sb = joltsim.SoftBodyDesc()
sb.name = "cloth"
sb.pos = [0.0, 0.0, 1.0]
sb.vertices = [...]          # flat xyz float list (3 * V)
sb.faces = [...]             # flat triangle indices (3 * F)
sb.inv_masses = [...]        # optional per-vertex 1/mass (0.0 = pinned)
sb.compliance = 1e-4
sb.shear_compliance = 1e-4
sb.bend_compliance = 1e-3
sb.bend_type = joltsim.SoftBendType.Distance  # None | Distance | Dihedral
sb.num_iterations = 8
sb.pressure = 0.0

sb_idx = w.add_soft_body(sb)

Runtime Views & Mutation

  • w.num_soft_bodies: Total number of soft bodies in the World.

  • w.soft_body_vertices(sb_idx): Zero-copy (V, 3) float32 view of world-space vertex positions, updated in-place on step().

  • w.soft_body_faces(sb_idx): Zero-copy (F, 3) uint32 triangle index view.

  • w.set_soft_body_vertex_inv_mass(sb_idx, vert_idx, inv_mass): Pin (0.0) or unpin vertices at runtime.

  • w.set_soft_body_pressure(sb_idx, pressure): Adjust internal pressure at runtime (e.g., for pneumatic soft bodies).