Inspirateur / riverbed

A Minecraft-inspired Bevy game
MIT License
25 stars 1 forks source link

Add ores and harvesting #20

Open Inspirateur opened 2 months ago

Inspirateur commented 2 months ago

(Renewable) ores should spawn, and the player should be able to harvest them (which is not the same action as breaking).

A main issue is that spawning caves require 3D noise which is very expensive and will require moving terrain generation to the GPU, but we can get around that and generate simple rifts (which only require 2D noises) with ores in them for now.

To-do:

Inspirateur commented 1 week ago

Some thoughts about renewable ores

Renewable blocks will need to have some state that dictates when they will renew (could be a simple timestamp), but if we stored this state directly in the block it would blow up the palette and worsen chunk compression (because each renewable has a different state).

A smarter way to go about this would be to have a sparse storage alongside the dense block storage. For example, we could have a HashMap of position → block state (bevy entity maybe ?), with only positions containing renewable blocks being stored.

This implies that there can be 2 separate views for the same "block", the one in the palette (determining the texture to use), and another one for blocks with state.

We will also need a simple bevy entity for each renewable block to frequently check if the block should regenerate or not (we can make it a fixed time update with a low tick rate (like 1 per second) because resolution doesn't matter that much.