Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.72k stars 251 forks source link

Getting Data on Modified Voxels #591

Open JohnDoneth opened 10 months ago

JohnDoneth commented 10 months ago

I'm working on a project where I'm attempting to have mine-able terrain that can be gathered based on the texture ID using the smooth voxel terrain however I'm not certain how to figure out what and what amount of voxels have been gathered.

It would be nice if the do_sphere or other modification functions could return a diff of some sort of the voxel buffer before and after being modified so I can see what materials (just voxels with a specific texture in my case) have been removed or changed. That way once my player has gathered a certain amount of material they can receive an item.

I have considered taking a snapshot of the area before and after using voxel buffers and creating the diff myself but since it would have to be iterated in GDScript I figured that might not be ideal and could warrant some discussion here where it could be implemented more efficiently in C++ where the diff information could be gathered while performing the voxel modification. Maybe I'm missing another way it could be done already as well.

Zylann commented 10 months ago

I thought of that a few times and I plan to add something to do this, I just didn't come to do it yet.