warp.Mesh#

class warp.Mesh(*args, **kwargs)[source]#

Triangle mesh for collision detection, ray casting, and spatial queries.

__init__(
points,
indices,
velocities=None,
support_winding_number=False,
bvh_constructor=None,
bvh_leaf_size=None,
groups=None,
)[source]#

Class representing a triangle mesh.

id#

Unique identifier for this mesh object, can be passed to kernels.

device#

Device this object lives on, all buffers must live on the same device.

Parameters:
  • points (array) – Array of vertex positions of data type warp.vec3.

  • indices (array) – Array of triangle indices of data type warp.int32. Should be a 1D array with shape (num_tris * 3).

  • velocities (array | None) – Optional array of vertex velocities of data type warp.vec3.

  • support_winding_number (bool) – If True, the mesh will build additional data structures to support warp.mesh_query_point_sign_winding_number() queries.

  • bvh_constructor (BvhConstructor | str | None) – The construction algorithm for the underlying BVH (see the docstring of Bvh for explanation). Valid choices are "sah", "median", "lbvh", "cubql", or None. When "cubql" is selected (experimental), only ray query APIs are supported. All other queries will silently return no results.

  • bvh_leaf_size (int | None) – The number of primitives (AABBs) stored in each leaf node (see the docstring of Bvh for more details). If None the default value based on the bvh_constructor will be used.

  • groups (array | None) – Optional array of triangle group indices of data type warp.int32. Should be a 1D array with shape (num_tris).

Methods

__init__(points, indices[, velocities, ...])

Class representing a triangle mesh.

refit()

Refit the BVH to points.

Attributes

points

The array of mesh's vertex positions of type warp.vec3.

vars

velocities

The array of mesh's velocities of type warp.vec3.

vars: ClassVar[dict[str, _Var]] = {'indices': <warp._src.codegen.Var object>, 'points': <warp._src.codegen.Var object>, 'velocities': <warp._src.codegen.Var object>}#
refit()[source]#

Refit the BVH to points.

This should be called after users modify the points data.

property points[source]#

The array of mesh’s vertex positions of type warp.vec3.

The Mesh.points property has a custom setter method. Users can modify the vertex positions in-place, but refit() must be called manually after such modifications. Alternatively, assigning a new array to this property is also supported. The new array must have the same shape as the original, and once assigned, The Mesh will automatically perform a refit operation based on the new vertex positions.

property velocities[source]#

The array of mesh’s velocities of type warp.vec3.

This is a property with a custom setter method. Users can modify the velocities in-place, or assign a new array to this property. No refitting is needed for changing velocities.