Getting Voxel Count

ttuzun posted this 21 October 2017

Hi There

I was wondering if there is a way to get a voxel count of a volüme. Both in editör and in runtime.


Order By: Standard | Newest | Votes
GarethIW posted this 22 October 2017

Sure, all you have to do is count how many voxels in teh voxel array have a State of VoxelState.Active. The voxel array is on the Frame, so you'll need a reference to the current animation Frame first.

If you have a reference to the volume, you can get the current Frame with volume.GetCurrentFrame().

After that, you just need to loop through Frame.Voxels and count where Voxel.State == VoxelState.Active.

Here's an example script that you can attach to a Volume to get a count:

It has two counting methods, one that uses LINQ and one that does a simple loop. The loop would be better for runtime as it won't create any garbage.

Our 116 members have posted 443 times in 105 discussions