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() and volume_lookup_index() support volumes with at most 2**31 - 1 indexable voxels. This function is not differentiable.

Parameters:

id – The id of a warp.Volume.

Returns:

The number of indexable voxels. This is the required size of a per-voxel voxel_data array (as used by volume_sample_index()) and the exclusive upper bound of indices returned by volume_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