warp.volume_lookup_index#
- warp.volume_lookup_index( ) int32#
Kernel
Python
Return the linear index associated with integer index-space coordinates
i,j,k.This function is not differentiable.
- Parameters:
id – The
idof awarp.Volume.i – Voxel coordinate along the first index-space axis.
j – Voxel coordinate along the second index-space axis.
k – Voxel coordinate along the third index-space axis.
- Returns:
The voxel’s linear index in
[0, volume_voxel_count(id)), or-1when the coordinate is not indexable. Guard against-1before gathering from a per-voxel array.
Example
@wp.kernel def lookup_index(vid: wp.uint64, out: wp.array[wp.int32]): out[0] = wp.volume_lookup_index(vid, 1, 0, 0) voxels = wp.array([[0, 0, 0], [1, 0, 0]], dtype=wp.vec3i) volume = wp.Volume.allocate_by_voxels(voxels, voxel_size=1.0) out = wp.zeros(1, dtype=wp.int32) wp.launch(lookup_index, dim=1, inputs=[volume.id], outputs=[out]) print(int(out.numpy()[0]))
1