starandserpent / Voxel-demo

Demo implementation of Terra using Weltschmerz and Foreman
https://discord.starandserpent.com/
2 stars 1 forks source link

Picker #18

Open Pawlost opened 4 years ago

Pawlost commented 4 years ago

We should implement picker for picking and placing blocks. This requires working octree so there arent bugs.

Pawlost commented 4 years ago

This issue is closely related to this https://github.com/starandserpent/Rituals-Godot/issues/24, I probably also need C# camera script for this.

Pawlost commented 4 years ago

Picking is not working but we have to make faster meshing before we can continue

Pawlost commented 4 years ago

Next goal is add placing blocks

Pawlost commented 4 years ago

I have to rewrite this for RLE

Pawlost commented 4 years ago

"So instead of iterating through the whole 32^3 you would use Morton + iterate from -> to when you hit the right section."

Pilvinen commented 4 years ago

1) Apply Z-order curve on the blocks of the uncompressed chunk. 2) Compress with RLE.

When searching for blocks, because the RLE data is compressed the data will have to be interated through each time and compression values calculated for each range of blocks to find the range where the targeted block is located at.

When you know you are in the right index range you can then find the precise coordinate (and thus neighbors) by the virtue of mathemagics.

If you want to do shit, you will then have to decompress that range of RLE compressed blocks as usual, apply changes, check the neighboring compressed ranges, and compress those sections again.

This approach simplifies the problem of finding a block inside a chunk container from: chunk size^3 - (chunk size^3-n)

to: (chunk size^3 - (chunk size^3-n)) / compression ratio

Where n is the location.

With the added benefit of being able to find all the neighbors due to Z-order curve.

However, if a lot of work is to be done inside one chunk, it will probably be cheaper to decompress the whole chunk, do the work, and then compress it again. This is likely to lead to faster processing times.