Now generating roads on terrain. Still some trouble left.

This commit is contained in:
Segey Lapin
2021-10-13 20:09:02 +03:00
parent 1b244e80ef
commit 2c7a6af437
6 changed files with 52 additions and 12 deletions

View File

@@ -52,7 +52,7 @@ private:
static void _bind_methods();
protected:
template <typename Height_F>
void generate(VoxelBuffer &out_buffer, Height_F height_func, Vector3i origin, int lod) {
Result generate(VoxelBufferInternal &out_buffer, Height_F height_func, Vector3i origin, int lod) {
const int channel = _channel;
const Vector3i bs = out_buffer.get_size();
@@ -60,12 +60,16 @@ protected:
if (origin.y > get_height_start() + get_height_range()) {
// The bottom of the block is above the highest ground can go (default is air)
return;
Result result;
result.max_lod_hint = true;
return result;
}
if (origin.y + (bs.y << lod) < get_height_start()) {
// The top of the block is below the lowest ground can go
out_buffer.clear_channel(_channel, use_sdf ? 0 : _matter_type);
return;
Result result;
result.max_lod_hint = true;
return result;
}
const int stride = 1 << lod;
@@ -111,6 +115,8 @@ protected:
} // for x
} // for z
} // use_sdf
return Result();
}
private: