warp.volume_voxel_count#
- warp.volume_voxel_count(id: uint64) int32#
Kernel
Python
Return the number of indexable voxels in the volume given by
id.volume_voxel_count()andvolume_lookup_index()support volumes with at most2**31 - 1indexable voxels. This function is not differentiable.- Parameters:
id – The
idof awarp.Volume.- Returns:
The number of indexable voxels. This is the required size of a per-voxel
voxel_dataarray (as used byvolume_sample_index()) and the exclusive upper bound of indices returned byvolume_lookup_index().
Example
@wp.kernel def count(vid: wp.uint64, out: wp.array[wp.int32]): out[0] = wp.volume_voxel_count(vid) 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(count, dim=1, inputs=[volume.id], outputs=[out]) print(int(out.numpy()[0]))
2