Soft Bodies and Particles#
Some objects change shape: a rubber toy squashes, cloth folds, and water flows. ovphysx simulates them with soft bodies and particles. Both run only on an NVIDIA GPU. On the CPU, ovphysx logs an error and leaves them out of the simulation.

Soft Bodies#
A soft body, also called a deformable body, is simulated on a mesh of points joined into small shapes. When the body hits something, its points move apart or together. Forces between them then pull the mesh back toward its rest shape, the shape it has when nothing pushes on it.
Kind |
Simulation Mesh |
Use It For |
|---|---|---|
Volume |
Tetrahedra, in a |
Solid objects that squash, such as rubber or flesh. |
Surface |
Triangles, in a |
Thin objects that bend, such as cloth or paper. |
A scene marks a soft body with these API schemas:
API Schema |
Applied To |
What It Does |
|---|---|---|
|
The body |
Makes the prim a soft body. |
|
The simulation mesh |
Marks the mesh to simulate and holds its rest shape. |
|
The collision mesh |
Marks the mesh the body collides with. A soft body needs one. |
|
A material bound to the body |
Sets how soft the body is. |
Assets often have no tetrahedral mesh. With PhysxAutoDeformableBodyAPI, ovphysx builds the
simulation mesh from a render mesh when it attaches the stage.
A Soft Cube#
The following program, soft_bodies_cube.py, drops a soft cube with 0.5 m sides and prints its height. Its simulation mesh is
also its collision mesh: the eight corners of the cube, joined into five tetrahedra. Real soft bodies
use many more points.
import ovstage
from ovphysx.population import physics_population_descs
from ovphysx import PhysX
from ovphysx.samples.python_samples.schema_support import physx_schema_paths
from ovphysx.types import SimObjectType
# A soft cube with 0.5 m sides, whose bottom starts 0.75 m above the ground.
# Its simulation mesh joins the 8 corners into 5 tetrahedra.
SCENE = """#usda 1.0
(
metersPerUnit = 1
kilogramsPerUnit = 1
upAxis = "Z"
)
def Xform "World"
{
def PhysicsScene "PhysicsScene" {}
def Plane "Ground" (
prepend apiSchemas = ["PhysicsCollisionAPI"]
)
{
uniform token axis = "Z"
}
def Material "SoftMaterial" (
prepend apiSchemas = ["OmniPhysicsDeformableMaterialAPI",
"PhysxDeformableMaterialAPI"]
)
{
float omniphysics:youngsModulus = 20000
float omniphysics:poissonsRatio = 0.45
float physxDeformableMaterial:elasticityDamping = 0.05
}
def TetMesh "SoftCube" (
prepend apiSchemas = ["OmniPhysicsDeformableBodyAPI",
"OmniPhysicsVolumeDeformableSimAPI",
"PhysicsCollisionAPI", "MaterialBindingAPI"]
)
{
point3f[] points = [
(0, 0, 0.75), (0.5, 0, 0.75), (0.5, 0.5, 0.75), (0, 0.5, 0.75),
(0, 0, 1.25), (0.5, 0, 1.25), (0.5, 0.5, 1.25), (0, 0.5, 1.25)
]
int4[] tetVertexIndices = [
(0, 1, 3, 4), (1, 2, 3, 6), (1, 4, 5, 6), (3, 4, 6, 7), (1, 3, 4, 6)
]
int3[] surfaceFaceVertexIndices = [
(0, 3, 1), (0, 1, 4), (0, 4, 3), (1, 3, 2), (1, 2, 6), (2, 3, 6),
(1, 5, 4), (1, 6, 5), (4, 5, 6), (3, 4, 7), (3, 7, 6), (4, 6, 7)
]
point3f[] omniphysics:restShapePoints = [
(0, 0, 0.75), (0.5, 0, 0.75), (0.5, 0.5, 0.75), (0, 0.5, 0.75),
(0, 0, 1.25), (0.5, 0, 1.25), (0.5, 0.5, 1.25), (0, 0.5, 1.25)
]
int4[] omniphysics:restTetVtxIndices = [
(0, 1, 3, 4), (1, 2, 3, 6), (1, 4, 5, 6), (3, 4, 6, 7), (1, 3, 4, 6)
]
rel material:binding:physics = </World/SoftMaterial>
}
}
"""
def cube_height(physx):
"""Read the points of every volume soft body and return the cube's height."""
with physx.read_sync(SimObjectType.DEFORMABLE_VOLUME, ["points"]) as result:
points = result.groups[0].tensors[0].numpy() # this body: one row per point
return float(points[:, 2].max() - points[:, 2].min())
ovstage.population.register_usd_schemas([str(p) for p in physx_schema_paths()])
stage = ovstage.Stage("soft_cube")
ovstage.population.open_usd_from_string_with_desc(
stage, SCENE, ordinal=1, time=ovstage.population.DEFAULT_TIME, descs=physics_population_descs(rendering=True)
)
stage.advance_write_floor(ordinal=1).wait()
physx = PhysX()
physx.wait_task(physx.attach_ovstage(stage, read_ordinal=1))
print(f"t=0.00 s height = {cube_height(physx):.3f} m")
for step in range(1, 91):
physx.step_sync(1.0 / 60.0)
if step % 15 == 0:
print(f"t={step / 60:.2f} s height = {cube_height(physx):.3f} m")
physx.wait_task(physx.detach_ovstage())
physx.destroy()
stage.destroy()
It prints:
t=0.00 s height = 0.500 m
t=0.25 s height = 0.500 m
t=0.50 s height = 0.363 m
t=0.75 s height = 0.504 m
t=1.00 s height = 0.468 m
t=1.25 s height = 0.453 m
t=1.50 s height = 0.460 m
Notice the following:
The cube settles at about 0.46 m, pressed down by its own weight. A rigid box would print 0.500 m on every line.
The material sets the softness.
youngsModulusis the stiffness in pascals, and a lower value is softer.poissonsRatiomakes the cube bulge sideways when it is squashed, andelasticityDampingmakes its wobbling die out.Here, the
pointsarrays are in GPU memory, andnumpy()copies them to the CPU.
Particles#
Particles simulate liquids and granular material such as sand. Each particle is a small sphere, and many of them together flow, splash, and settle:

A scene needs two parts:
Part |
What It Does |
|---|---|
A |
Holds settings that its particles share, such as their size, which |
A |
Makes each point a particle. Its |
On the particle set, set physxParticle:fluid to 1 for a liquid or to 0 for a granular
solid.
Reading Their State#
A read returns one array per object. Its points hold one row per mesh point or particle,
relative to the prim that holds them.
Object Type |
One Array Per |
|---|---|
|
Volume soft body |
|
Surface soft body |
|
Render mesh that follows a soft body. Its |
|
Particle set |
More Detail#
Deformable Bodies covers render meshes, automatic mesh generation, attachments, and limitations.
Particles (reference) explains particle size, spacing, mass, and density.
Deformable volume, Deformable surface, Particle set, and Deformable material list every readable and writable attribute.
OmniPhysicsDeformableBodyAPI, PhysxAutoDeformableBodyAPI, PhysxParticleSystem, and PhysxParticleSetAPI describe each scene setting.
Next: Selecting Objects shows how to pick the objects a read or write works on.