newton.SDF#
- class newton.SDF(*, data, sparse_volume=None, coarse_volume=None, block_coords=None, _internal=False)[source]#
Bases:
objectOpaque SDF container owning kernel payload and runtime references.
- static create_from_data(*, sparse_volume=None, coarse_volume=None, block_coords=None, center=None, half_extents=None, background_value=MAXVAL, scale_baked=False)#
Create an SDF from precomputed runtime resources.
- static create_from_mesh(mesh, *, device=None, narrow_band_range=(-0.1, 0.1), target_voxel_size=None, max_resolution=None, margin=0.05, shape_margin=0.0, scale=None)#
Create an SDF from a mesh in local mesh coordinates.
- Parameters:
mesh (Mesh) – Source mesh geometry.
device (Device | str | None) – CUDA device for SDF allocation. When
None, uses the currentwp.ScopedDeviceor the Warp default device.narrow_band_range (tuple[float, float]) – Signed narrow-band distance range [m] as
(inner, outer).target_voxel_size (float | None) – Target sparse-grid voxel size [m]. If provided, takes precedence over
max_resolution.max_resolution (int | None) – Maximum sparse-grid dimension [voxel]. Used when
target_voxel_sizeis not provided.margin (float) – Extra AABB padding [m] added before discretization.
shape_margin (float) – Shape margin offset [m] to subtract from SDF values. When non-zero, the SDF surface is effectively shrunk inward by this amount. Useful for modeling compliant layers in hydroelastic collision. Defaults to
0.0.scale (tuple[float, float, float] | None) – Scale factors
(sx, sy, sz)[unitless] to bake into the SDF. When provided, mesh vertices are scaled before SDF generation andscale_bakedis set toTruein the resulting SDF. Required for hydroelastic collision with non-unit shape scale. Defaults toNone(no scale baking; scale applied at runtime).
- Returns:
A validated
SDFruntime handle with sparse/coarse volumes.- Return type:
- static create_from_points(points, indices, *, device=None, narrow_band_range=(-0.1, 0.1), target_voxel_size=None, max_resolution=None, margin=0.05, shape_margin=0.0, scale=None)#
Create an SDF from triangle mesh points and indices.
- Parameters:
points (ndarray[Any, dtype[Any]] | Sequence[Sequence[float]]) – Vertex positions [m], shape
(N, 3).indices (ndarray[Any, dtype[Any]] | Sequence[int]) – Triangle vertex indices [index], flattened or shape
(M, 3).device (Device | str | None) – CUDA device for SDF allocation. When
None, uses the currentwp.ScopedDeviceor the Warp default device.narrow_band_range (tuple[float, float]) – Signed narrow-band distance range [m] as
(inner, outer).target_voxel_size (float | None) – Target sparse-grid voxel size [m]. If provided, takes precedence over
max_resolution.max_resolution (int | None) – Maximum sparse-grid dimension [voxel]. Used when
target_voxel_sizeis not provided.margin (float) – Extra AABB padding [m] added before discretization.
shape_margin (float) – Shape margin offset [m] to subtract from SDF values.
scale (tuple[float, float, float] | None) – Scale factors
(sx, sy, sz)to bake into the SDF.
- Returns:
A validated
SDFruntime handle with sparse/coarse volumes.- Return type:
- __init__(*, data, sparse_volume=None, coarse_volume=None, block_coords=None, _internal=False)#
- is_empty()#
Return True when this SDF has no sparse/coarse payload.
- to_kernel_data()#
Return kernel-facing SDF payload.
- validate()#
Validate consistency of kernel pointers and owned volumes.