warp.mesh_get_velocity#

warp.mesh_get_velocity(id: uint64, index: int32) vec3f#
  • Kernel

Look up the velocity of a face’s vertex in the warp.Mesh.

Like mesh_get_point(), index is a face-vertex index in [0, 3 * number_of_faces); returns the velocity of the vertex referenced there, i.e. velocities[indices[index]]. Requires the mesh to have been constructed with a velocities array; returns a zero vector otherwise.

Parameters:
  • id – The mesh identifier

  • index – A face-vertex index, in [0, 3 * number_of_faces)

Returns:

The referenced vertex’s velocity, or a zero vector if the mesh has no velocities.

Example

@wp.kernel
def slot0(mesh_id: wp.uint64, out: wp.array[wp.vec3]):
    out[0] = wp.mesh_get_velocity(mesh_id, 0)

points = wp.array([[0,0,0],[1,0,0],[1,1,0],[0,1,0],[0,0,1],[1,0,1],[1,1,1],[0,1,1]], dtype=wp.vec3)
indices = wp.array([0,3,2, 0,2,1,  4,5,6, 4,6,7,  0,1,5, 0,5,4,
                    2,3,7, 2,7,6,  0,4,7, 0,7,3,  1,2,6, 1,6,5], dtype=wp.int32)
velocities = wp.array(np.tile([0.0, 0.0, 1.0], (8, 1)), dtype=wp.vec3)
mesh = wp.Mesh(points=points, indices=indices, velocities=velocities)

out = wp.zeros(1, dtype=wp.vec3)
wp.launch(slot0, dim=1, inputs=[mesh.id], outputs=[out])
print(out.numpy()[0])
[0. 0. 1.]