newton.geometry.DeformableVisuals#

class newton.geometry.DeformableVisuals(model)[source]#

Bases: object

Current evaluated geometry for a model’s deformable visual meshes.

Allocate one per model with DeformableVisuals(model) and fill it with update(). One result can be reused across states and ordered graph replays. Update or replay before consumption; the output does not track its source State or freshness. Finish consumption before overwriting the buffers, and allocate separate results for simultaneous snapshots or concurrent updates. Skinning is not differentiable.

Experimental

Experimental feature. API, behavior, defaults, and supported use cases may change without prior notice.

__init__(model)#

Allocate fixed visual output buffers for a model.

Parameters:

model (Model) – Model whose visual meshes define the output layout.

get_normals(mesh)#

Return the current unit-normal view for one deformable visual mesh.

Parameters:

mesh (DeformableVisualMesh | SupportsIndex) – Mesh object or invariant index in newton.Model.deformable_visual_meshes.

Returns:

Zero-copy view of unit normals, shape [mesh.vertex_count, 3].

Raises:
  • RuntimeError – If the output has not been updated.

  • TypeError – If mesh is not a visual mesh or integer index.

  • IndexError – If the index is out of range.

  • ValueError – If the mesh belongs to another model.

Return type:

wp.array[wp.vec3f]

get_points(mesh)#

Return the current point view for one deformable visual mesh.

Parameters:

mesh (DeformableVisualMesh | SupportsIndex) – Mesh object or invariant index in newton.Model.deformable_visual_meshes.

Returns:

Zero-copy view of current points [m], shape [mesh.vertex_count, 3].

Raises:
  • RuntimeError – If the output has not been updated.

  • TypeError – If mesh is not a visual mesh or integer index.

  • IndexError – If the index is out of range.

  • ValueError – If the mesh belongs to another model.

Return type:

wp.array[wp.vec3f]

update(state)#

Evaluate the current points and normals from a simulation state.

This reuses the buffers allocated at construction and allocates nothing, so it can be captured in a CUDA graph; a warm-up call before capture is recommended to load the kernels. Keep captured arrays alive and change their contents, not their storage, between replays.

Parameters:

state (newton.State) – Simulation state containing current particle positions and body transforms.

Returns:

This object.

Raises:

ValueError – If the required state arrays are missing, too short, or on another device.

Return type:

DeformableVisuals

wait(stream=None)#

Make a device stream wait for the most recent update().

This is the ordering half of the capture contract: launch any captured update before calling it. The wait does not prevent another update from overwriting buffers still in use by a consumer.

Parameters:

stream (Stream | None) – Consumer stream. Uses the current stream on device when omitted. This method is a no-op on CPU.

Raises:

RuntimeError – If the output has not been updated.

device#

Device containing points and normals.

mesh_ranges#

Stable [start, end) vertex range for each visual mesh.

property model: Model#

Model whose visual mesh layout this result uses.

normals#

Current unit normals, shape [vertex_count, 3]. Zero for a vertex that no non-degenerate triangle references.

points#

Current skinned visual points [m], shape [vertex_count, 3].

vertex_count#

Total number of current visual vertices.