feat: implemented chunking
This commit is contained in:
parent
823d70a93c
commit
f5a78e10c7
6 changed files with 188 additions and 45 deletions
|
|
@ -5,15 +5,22 @@
|
|||
#include "core/variant/callable.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/resources/gradient.h"
|
||||
#include "scene/resources/material.h"
|
||||
#include "scene/resources/mesh.h"
|
||||
#include "scene/resources/surface_tool.h"
|
||||
#include "terrain_editor/terrain_chunk.h"
|
||||
#include "terrain_editor/terrain_primitive.h"
|
||||
|
||||
class TerrainMeshGenerator : public Node {
|
||||
GDCLASS(TerrainMeshGenerator, Node);
|
||||
static void _bind_methods();
|
||||
void ready();
|
||||
void on_configuration_changed();
|
||||
|
||||
protected:
|
||||
void _notification(int what);
|
||||
void rebuild_chunks();
|
||||
|
||||
public:
|
||||
Color color_at_height(float height) const;
|
||||
float evaluate_point(Vector2 at) const;
|
||||
|
|
@ -26,6 +33,14 @@ public:
|
|||
float get_color_gradient_start_height() const;
|
||||
void set_color_gradient_end_height(float value);
|
||||
float get_color_gradient_end_height() const;
|
||||
void set_chunk_size(float size);
|
||||
float get_chunk_size() const;
|
||||
void set_lod1_detail(int detail);
|
||||
int get_lod1_detail() const;
|
||||
void set_chunk_count(int num);
|
||||
int get_chunk_count() const;
|
||||
void set_material(Ref<Material> material);
|
||||
Ref<Material> get_material() const;
|
||||
|
||||
private:
|
||||
Vector<Ref<TerrainPrimitive>> primitives{};
|
||||
|
|
@ -33,6 +48,11 @@ private:
|
|||
Ref<Gradient> vertex_color_gradient{};
|
||||
float color_gradient_start_height{ 0.f };
|
||||
float color_gradient_end_height{ 10.f };
|
||||
float chunk_size{ 100.f };
|
||||
int lod1_detail{ 25 };
|
||||
int chunks_per_side{ 10 };
|
||||
Vector<TerrainChunk *> chunks{};
|
||||
Ref<Material> material{};
|
||||
|
||||
private:
|
||||
Callable generation_changed{ callable_mp(this, &self_type::on_configuration_changed) };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue