warp.Mesh#
- class warp.Mesh(
- points,
- indices,
- velocities=None,
- support_winding_number=False,
- bvh_constructor=None,
- bvh_leaf_size=None,
- groups=None,
Triangle mesh for collision detection, ray casting, and spatial queries.
Class representing a triangle mesh.
- id#
Object ID to pass to kernel parameters and struct fields of type
warp.handle. Keep this mesh alive while its ID is in use.
- 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 supportwarp.mesh_query_point_sign_winding_number()queries.bvh_constructor (BvhConstructor | str | None) – The construction algorithm for the underlying BVH (see the docstring of
Bvhfor explanation). Valid choices are"sah","median","lbvh","cubql", orNone. When"cubql"is selected (experimental), cuBQL is used to build the underlying BVH in Warp’s native layout. Grouped meshes andsupport_winding_number=Trueare not supported with this constructor.bvh_leaf_size (int | None) – The number of primitives (AABBs) stored in each leaf node (see the docstring of
Bvhfor more details). IfNonethe default value based on thebvh_constructorwill 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).
- Raises:
NotImplementedError – If called during CPU graph capture, which cannot record the build. Build the mesh before capture and update it with
refit()or by assigningpointsinstead.
Methods
refit()Refit the BVH to points.
Attributes
The array of mesh's vertex positions of type
warp.vec3.The array of mesh's velocities of type
warp.vec3.Whether the mesh was built with the data structures that
warp.mesh_query_point_sign_winding_number()requires.- vars: ClassVar[dict[str, _Var]] = {'indices': <warp._src.codegen.Var object>, 'points': <warp._src.codegen.Var object>, 'velocities': <warp._src.codegen.Var object>}#
- support_winding_number#
Whether the mesh was built with the data structures that
warp.mesh_query_point_sign_winding_number()requires.
- refit()[source]#
Refit the BVH to points.
This should be called after users modify the
pointsdata.Note
Under a CPU graph capture the refit is recorded and re-run on replay against the current
points. Such a graph is replay-only and cannot be serialized withwarp.capture_save().
- 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, TheMeshwill automatically perform a refit operation based on the new vertex positions.Under a CPU graph capture, an assignment is recorded and applied on each replay, in capture order, followed by the refit. The property returns the new array immediately, but kernels see it only once the graph is launched. Such a graph is replay-only and cannot be serialized with
warp.capture_save().
- 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.
Under a CPU graph capture, an assignment is recorded and applied on each replay, in capture order. The property returns the new array immediately, but kernels see it only once the graph is launched. Such a graph is replay-only and cannot be serialized with
warp.capture_save().