warp.volume_lookup_index#
- warp.volume_lookup_index( ) int32#
Kernel
Python
Return the linear index associated with integer index-space coordinates
i,j,k.On NanoVDB
OnIndexandOnIndexMaskgrids, active voxels have zero-based indices and inactive voxels return-1. OnIndexandIndexMaskgrids and on classical value grids, every slot in an allocated leaf has an index regardless of its active mask; coordinates outside allocated leaves return-1. For volumes whose indexable count fits inint32, nonnegative indices lie in[0, volume_voxel_count(id)). Guard against-1before gathering from a per-voxel array. 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, or
-1when the coordinate is not indexable.
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