mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 01:59:19 +02:00
World Streaming Part 1
This commit is contained in:
@@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "scene/sceneeditor.h"
|
||||
#include "scene/scenenode.h"
|
||||
#include "editor/editorTerrain.hpp"
|
||||
#include "editor/editorTerrainStreamer.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -146,14 +147,27 @@ class editor_mode : public application_mode
|
||||
void render_terrain_ui();
|
||||
// creates a large terrain as a grid of adjacent chunks (each its own editable patch)
|
||||
void create_chunked_terrain();
|
||||
// manual grid-aligned chunks: add/remove single chunks for fine control
|
||||
float chunk_grid_size() const { return m_terrain_cells * m_terrain_cellsize; }
|
||||
void add_grid_chunk(int Cx, int Cz);
|
||||
void remove_grid_chunk(int Cx, int Cz);
|
||||
// handles a click in chunk-edit mode (add a neighbour, or Shift = delete the clicked chunk)
|
||||
void handle_chunk_edit_click(bool DeleteMode);
|
||||
// commits authored terrain to disk, enables streaming, and exports the scenery (Ctrl+S)
|
||||
void save_scene_with_terrain();
|
||||
// raises/lowers terrain under the cursor while the left mouse button is held in sculpt mode
|
||||
void handle_terrain_sculpt(double Deltatime);
|
||||
// returns the terrain patch (if any) whose footprint covers the given world point
|
||||
editor_terrain *terrain_at(double X, double Z);
|
||||
// gathers every active terrain patch: manually-created ones plus streamed chunks
|
||||
std::vector<editor_terrain *> active_terrains();
|
||||
// samples the selected model instance's geometry into a new editable terrain patch, then removes it
|
||||
void capture_terrain();
|
||||
std::vector<std::unique_ptr<editor_terrain>> m_terrains;
|
||||
// grid-aligned manual chunks, keyed by (cx,cz) on the global chunk grid
|
||||
std::map<std::pair<int, int>, std::unique_ptr<editor_terrain>> m_grid_chunks;
|
||||
bool m_terrain_sculpt{false}; // when true, LMB sculpts terrain instead of picking
|
||||
bool m_chunk_edit{false}; // when true, LMB adds/removes whole chunks
|
||||
int m_terrain_cells{32}; // grid resolution (quads per side)
|
||||
int m_terrain_chunks{4}; // chunks per side for a chunked terrain
|
||||
float m_terrain_cellsize{2.0f}; // metres per quad
|
||||
@@ -161,8 +175,16 @@ class editor_mode : public application_mode
|
||||
float m_terrain_brush_radius{12.0f};
|
||||
float m_terrain_brush_strength{4.0f}; // metres per second while held (one-shot for the buttons)
|
||||
float m_terrain_simplify_error{0.5f}; // flatness tolerance (m) for mesh simplification
|
||||
bool m_terrain_auto_optimize{false}; // auto-simplify edited chunks after sculpting settles
|
||||
double m_terrain_idle{0.0}; // seconds since the last sculpt edit (debounce timer)
|
||||
char m_terrain_texture[128]{""}; // optional ground texture name
|
||||
|
||||
// streaming terrain that follows the camera (open-world); the editor shares the single
|
||||
// simulation-level instance so authored terrain also renders in the driver / other modes
|
||||
terrain_streamer &m_streamer{EditorTerrain};
|
||||
int m_stream_radius{2};
|
||||
bool m_stream_persist{true}; // save edited chunks to disk and load them back
|
||||
|
||||
// hierarchy management
|
||||
void add_to_hierarchy(scene::basic_node *node);
|
||||
void remove_from_hierarchy(scene::basic_node *node);
|
||||
|
||||
Reference in New Issue
Block a user