#pragma once #include "core/os/mutex.h" #include "core/os/thread.h" #include "core/templates/vector.h" #include "macros.h" #include "scene/main/node.h" #include "scene/main/timer.h" class TerrainChunkMesh; class TerrainModifier; class Terrain : public Node { GDCLASS(Terrain, Node); static void _bind_methods(); void ready(); protected: void _notification(int what); static void generate_meshes_thread(void *terrain); public: void construct_chunk_grid(); void area_dirty(Vector2 from, Vector2 to); float height_at(Vector2 world_coordinate); private: Vector workload{}; Mutex workload_lock; bool threads_stop{ false }; Vector meshes{}; Vector modifiers{}; LocalVector threads{}; size_t side_length{ 200 }; size_t chunk_size{ 50 }; size_t detail{ 1 }; public: void set_side_length(size_t length); size_t get_side_length() const; void set_chunk_size(size_t size); size_t get_chunk_size() const; void set_detail(size_t detail); size_t get_detail() const; void set_thread_count(size_t num); size_t get_thread_count() const; };