#pragma once #include "core/math/rect2.h" #include "macros.h" #include "scene/3d/mesh_instance_3d.h" #include "scene/resources/mesh.h" #include "scene/resources/surface_tool.h" class Terrain; class TerrainChunkMesh : public MeshInstance3D { GDCLASS(TerrainChunkMesh, MeshInstance3D); static void _bind_methods(); void generate_vertices(); void generate_faces(); protected: void _notification(int what); public: void apply_new_mesh(); void update_mesh(); size_t points_per_side() const; private: Mutex lock{}; Vector3 safe_position{}; Ref surface{}; Ref new_mesh{}; Terrain *terrain{ nullptr }; size_t detail{ 1 }; size_t size{ 1 }; Rect2 bounds{}; public: GET_SET_FNS(Rect2, bounds); GET_SET_FNS(Terrain *, terrain); GET_SET_FNS(size_t, detail); GET_SET_FNS(size_t, size); };