Cutting volumes?

JohnFalcon posted this 05 October 2016

Hi, recently purchased and I'm looking through. It looks like a great tool.

I'm wondering about whether I can cut volumes in half at runtime. Would there be a way to detect whether a volume contains a separation and then create another volume of these separated voxels?

For example, I take a thin volume and start chipping a canal in it. Eventually the canal will be all the way across. I want to be able to separate the two sides of the canal and create a new volume. Would this be possible?

Last edited 05 October 2016

Order By: Standard | Newest | Votes
GarethIW posted this 05 October 2016

PicaVoxel doesn't have anything to do this currently. It's something I really want to do, but it won't be any time soon.

I've thought about it a lot, but I'm still not entirely sure how one would do this efficiently. Essentially, every time a volume is changed you'd need to scan the entire voxel array to find contiguous areas that are not connected to other contiguous areas. Once you have that information it would be easy to create a new Volume with that data.

JohnFalcon posted this 05 October 2016

Thanks for the reply.

What if the cut itself didn't actually destroy any voxels... If we know the cut is going to be made across the volume somewhere - but it's infinite - what about using Unity.Plane.GetSide to check which voxels were opposite to the cut, cut them and create a new volume? This wouldn't work for concave volumes without some interesting maths.


Last edited 05 October 2016

GarethIW posted this 05 October 2016

Something like that would be okay for cuts that went all the way through the volume non-diagonally, sure. You could simply make a copy of the volume and erase the voxels that fall either side of the plane on the original volume and the copied volume.

That would also require half of the chunks in each volume to be recalculated and re-meshed which may cause frame hitching depending on the size of the volume.

JohnFalcon posted this 05 October 2016

Absolutely, we're hoping not to have too big a volume to work with anyway, so hopefully it won't be too slow.

Thanks fella, I'll give it a go and let you know.

ttuzun posted this 19 October 2017

Hi there,

I hate to review a dead post however, I have the EXACT same question. Has there been any update on this?

Thanks a lot beforehand

GarethIW posted this 19 October 2017

Kind of:

The volume splitting in the above video was just an experiment and isn't part of the main PicaVoxel package because it's probably not performant enough to use in production games. Your mileage may vary, though, so feel free to give it a try:!AhdchalVsPvXnMk861F6BPKYeCbr0w

One thing it doesn't do which it probably should is destroy splits when there are no voxels left active, which would require a count of active voxels after a split takes place.

ttuzun posted this 20 October 2017

Thanks for the quick response

I will take a look. The video look pretty nice tbh If I can come up with an idea for improvement or implementation for my Project I will let you know (I want to blow things apart after certain voxel destruction) I am not a programming expert so if I ask something stupid please bear with me :D

I really appreciate your help.


ttuzun posted this 21 October 2017

Hi Gareth

I am trying to improve on your prototype. Even though your prototype work pretty nicely when splittin in half, if something is "exploded" and needs to be split, it creates TONS of copies not just the needed amount. Copies over copies of the same volumes. I am looking into that but may I ask a quick explanation of your "VolumeSplitter" script

Thanks Tolga

GarethIW posted this 22 October 2017

So splitting a volume involves:

  1. Identifying "islands" of voxels in the volume - that is; groups of voxels that are completely surrounded by inactive voxels (blank space)
  2. Where two or more islands are detected, we split them apart into new Volumes and deactivate the original volume.

In the script, the "islands" are called "splits". The scripts iterates over the volume until it finds an active voxel that isn't already part of a previous split, and then it starts a new split.

It then adds all the active voxels surrounding the first voxel to a queue to check. Then, for each voxel in the queue it will again check for surrounding active voxels and add them to the queue, until there are no more voxels left in the queue. We now have a split that is completely surrounded by inactive voxels (or is at the edge of the volume).

As long as there is an active voxel in the volume, there will always be one split. We only want to actually divide the volume into new ones if there is more than one split. That's the last bit of the script. For each split it copies the entire volume gameobject, and then activates only the voxels that are part of the split.

So yeah, that's a general explanation. The script will split your original volume into as many "islands" as you create when you do whatever it is you're doing to "explode" the volume.

Our 127 members have posted 466 times in 112 discussions