18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-20 11:34:57 +01:00

fix(editor): the orthophoto shown one of three ways, the terrain made from the NMT under one rule and around the camera (#334)

* fix(editor): the orthophoto shown one of three ways, chosen in one place, and laid on the terrain without flicker

The settings of the orthophoto had two checkboxes ("Fit to terrain", "Covered by
objects and terrain") and three heights greyed out by turns, and the user couldn't
tell what they did. They're one choice now, each way told under it:

- over the view: drawn over everything, see-through, to compare with the map
- on the terrain, in the scene: tracks and models cover it, lit, the mouse
  places objects on it
- a flat sheet in the scene: for a scenery with no terrain yet

The lift is shown only where it matters (on the terrain, in the scene), the
height is named for what it is in each way ("where there's no ground"), and the
ways in the scene are greyed out with the Better Renderer, which doesn't show
them.

On the terrain in the scene the photos are a copy of the ground's triangles 5 cm
up, which the depth buffer lost further away: they flickered with the terrain
textures. Their shapes are decals now, drawn with a polygon offset towards the
camera (the depth is reversed, so a positive one) in every pass but the shadows.

The translations hold the strings of the terrain of the download area as well.

* fix(editor): the terrain made from the NMT under one rule, also around the camera within the download area

The download area didn't bring the terrain: the NMT squares in it were fetched
only once the model had been placed (its panel opened) and the scenery had
terrain open, and nothing told why. They're fetched from the area as it is now,
in PUWG 1992 already.

Where a chunk is made from the model where there's no terrain, the rule is one
for the track laid, the area and the buttons of the panel (nmt_chunk_offset):
beside terrain made from the model it goes on at its height over the model,
otherwise (terrain made by hand, or none) at the offset of the scenery; no chunk
is left out for what lies beside it. Before, the terrain under the track laid
needed terrain in the scenery and a chunk of it beside, gave up chunks for the
session otherwise, and the model was placed only by its panel.

The terrain of the area: "The terrain of the scenery around the camera" (on by
default, kept with the editor) makes the chunks missing in the area in a square
of 9 x 9 around the camera, the nearest first, as the camera goes. Light: a chunk
at most every 0.1 s and three times as long as it took left to the editor, after
the work with the model the user asked for; the step of the terrain history the
editor keeps open is closed around each chunk, as for the terrain grown while
laying. Not the whole area at once: the chunks made wait in memory to be saved.
The log tells what holds it.

The download of the area gives way to the squares asked for: a square of the
area being downloaded is broken off as one is asked for (the terrain under the
track laid) and taken up again later.

The map no longer covers the area with green over the tiles in the cache, only
the failed ones are red.

* fix(editor): the terrain under the tracks follows them again, a brush stroke keeps its undo, the area terrain timed

From the review of the terrain made from the NMT under one rule:

- The terrain drawn to the tracks place by place (under the tracks) took the
  height of the chunk beside it, carrying one offset along a run of chunks,
  metres off the tracks: nmt_chunk_offset gives the offsets of the tracks there
  again. The height the track laid goes on at (state.ahead) comes from the
  terrain grown under it only, not from the chunks of the buttons.
- A chunk of the area made during a stroke of the terrain brush closed the
  stroke's step of the history, and its undo lost the part brushed before: the
  area terrain waits for the stroke to end.
- In a scenery with no name yet the terrain under the track laid was asked for
  and dropped every half a second, the log filled: nothing is asked for there.

The log tells how long the chunks of the square around the camera took, and the
self-test sets the area terrain on or off for its run (nmtsettings area 0|1).
Measured on lukow.scn: 1.3-1.5 ms a chunk, 2.2 ms the longest; the longest frame
17 ms against 10 ms without it, none over 33 ms.

* fix(editor): the selftest turns the area terrain on or off for its run only, the setting kept

---------

Co-authored-by: maj00r <maj00r@host>
This commit is contained in:
maj00r
2026-11-12 05:04:14 +01:00
committed by GitHub
parent bac9954ad5
commit 39e8bcc59d
12 changed files with 390 additions and 93 deletions

View File

@@ -535,6 +535,9 @@ class editor_mode : public application_mode, private editor_track::observer, pri
std::optional<double> nmt_terrain_offset(std::vector<glm::dvec2> const &Points, bool &Foreign) const;
// the same along the edges the chunk shares with the chunks beside it in memory
std::optional<double> nmt_seam_offset(heightmap::chunk_key const &Key, bool &Foreign) const;
// the offset a chunk made from the model where there's no terrain gets: of the terrain made from the model beside it, empty
// (the offset of the scenery) beside terrain made by hand or none
std::optional<double> nmt_chunk_offset(heightmap::chunk_key const &Key) const;
// the terrain beside the formation of the track is the one made from the model; Waiting: its squares of the model aren't in yet
// the tracks changed by hand are told to the terrain: their formations laid anew, of the tracks removed taken away, a
// track laid onto the terrain of the model given its own, once the mouse lets go; in the step of the history of the change
@@ -552,6 +555,9 @@ class editor_mode : public application_mode, private editor_track::observer, pri
// of the modifiers laid
std::size_t nmt_shape_tracks(std::vector<TTrack *> const *Only = nullptr);
void nmt_update();
// the terrain of the scenery made from the model around the camera within the download area, a chunk at a time while nothing
// else is done with the model and the frames are quick: edited chunks wait in memory to be saved, so not the whole area at once
void nmt_area_terrain();
void nmt_grow();
void render_nmt_ui();
// where the scenery lies: the map to click on, the place typed; true once it's placed
@@ -919,6 +925,25 @@ class editor_mode : public application_mode, private editor_track::observer, pri
} m_area_drawing;
std::vector<glm::dvec2> m_nmt_prefetched; // the download area the terrain model was given
bool m_area_paused{false}; // the download of the area held by the button; out of the editor it's held anyway
// the terrain made around the camera within the area: the chunks there, nearest first, the next one looked at, when the next one
// may be made, those made (or left: the model has no data there, or the chunk is outside the region) since the scenery opened
struct area_terrain
{
std::vector<heightmap::chunk_key> keys;
std::size_t next{0};
heightmap::chunk_key centre{0, 0};
bool listed{false};
double resume{0.0};
std::size_t made{0};
std::size_t square_made{0}; // of them, in the square around the camera now
bool refit{false}; // chunks made since the photos were last laid onto the ground
double waiting{-1.0}; // since when the next chunk waits for its model; -1: it doesn't
std::string held{"-"}; // what held it last, as logged; empty: nothing
double took{0.0}; // s the chunks of the square around the camera took, all and the longest
double took_most{0.0};
std::set<heightmap::chunk_key> empty;
std::optional<bool> run_only; // the selftest turned it on or off for its run, the setting left as it is
} m_area_terrain;
int m_area_square{0}; // km, the side of the square around the camera waiting for its yes in place of the area there is
bool m_outside_area_closed{false}; // the note of the camera outside the area closed; open again once it's back inside
int m_empty_hint_frame{-10}; // the frame the panel of the empty scenery was last drawn in