mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-20 13:54:58 +01:00
* 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>
148 lines
6.1 KiB
C++
148 lines
6.1 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
class editorSettings
|
|
{
|
|
public:
|
|
// camera movement key scheme in the editor
|
|
enum class movement_scheme
|
|
{
|
|
wsad, // new default: W/S/A/D + E/Q
|
|
legacy // old scheme: arrows + Page Up/Down
|
|
};
|
|
|
|
editorSettings() = default;
|
|
|
|
bool load();
|
|
bool save();
|
|
|
|
movement_scheme movement() const { return m_movement; }
|
|
void movement(movement_scheme scheme) { m_movement = scheme; }
|
|
|
|
// geoportal orthophoto layer (editor_orthophoto), how it's shown and whether it's on; the origin is kept per scenery, and the
|
|
// scenery keeps it too
|
|
struct orthophoto_settings
|
|
{
|
|
int radius{2};
|
|
float height{0.0f};
|
|
float opacity{0.6f};
|
|
int year{0};
|
|
bool hires{false};
|
|
bool drape{true};
|
|
float lift{0.05f};
|
|
bool in_scene{false};
|
|
// turned on or off by the user, for every scenery; none chosen yet: as the scenery keeps it, or the terrain model turns it on
|
|
std::optional<bool> on;
|
|
};
|
|
orthophoto_settings &orthophoto() { return m_orthophoto; }
|
|
// PUWG 1992 northing/easting of the scenery's (0,0,0) point; false when none was stored
|
|
bool orthophoto_origin(std::string const &Scenery, double &North, double &East) const;
|
|
void orthophoto_origin(std::string const &Scenery, double North, double East);
|
|
// the WMS layers the user added under the scenery, over the orthophoto, the top one first: the address of the service, the
|
|
// layers asked of it, its title and terms as its capabilities gave them. Kept with the editor, not with the scenery
|
|
struct wms_layer
|
|
{
|
|
std::string url;
|
|
std::string layers;
|
|
std::string title;
|
|
std::string terms;
|
|
float opacity{0.8f};
|
|
bool visible{true};
|
|
};
|
|
std::vector<wms_layer> &wms_layers() { return m_wms_layers; }
|
|
|
|
double platform_edge() const { return m_platform_edge; }
|
|
void platform_edge(double Distance) { m_platform_edge = Distance; }
|
|
double signal_offset() const { return m_signal_offset; }
|
|
void signal_offset(double Distance) { m_signal_offset = Distance; }
|
|
// look of the plates drawn for the signals: 0 plain, 1 toned, 2 aged
|
|
int signal_plate_look() const { return m_signal_plate_look; }
|
|
void signal_plate_look(int Look) { m_signal_plate_look = Look; }
|
|
|
|
// node bank: cards with the previews of the models or a list, and the size of the cards in pixels
|
|
bool nodebank_previews() const { return m_nodebank_previews; }
|
|
void nodebank_previews(bool Previews) { m_nodebank_previews = Previews; }
|
|
int nodebank_card() const { return m_nodebank_card; }
|
|
void nodebank_card(int Size) { m_nodebank_card = Size; }
|
|
|
|
// colours of the editor: 0 green, as the rest of the simulator; 1 amber
|
|
int palette() const { return m_palette; }
|
|
void palette(int Palette) { m_palette = Palette; }
|
|
|
|
// the tutorial (Help > Tutorial) opens by itself when an editor session starts
|
|
bool first_steps() const { return m_first_steps; }
|
|
void first_steps(bool Show) { m_first_steps = Show; }
|
|
// a scenery begun with no terrain is offered the terrain model as the first track is laid
|
|
bool terrain_offer() const { return m_terrain_offer; }
|
|
void terrain_offer(bool Offer) { m_terrain_offer = Offer; }
|
|
// a track laid and hidden in the ground is told of, with the way to fit the ground to it
|
|
bool terrain_buried_ask() const { return m_terrain_buried_ask; }
|
|
void terrain_buried_ask(bool Ask) { m_terrain_buried_ask = Ask; }
|
|
// the terrain of the terrain model made under the tracks as they're laid, around the cursor from the first point placed
|
|
bool terrain_while_laying() const { return m_terrain_while_laying; }
|
|
void terrain_while_laying(bool const Make) { m_terrain_while_laying = Make; }
|
|
// the terrain model in the terrain panel: the band along the tracks it's loaded in, m; the chunks along a side of the square
|
|
// made around the camera; the formation and the slopes made along the tracks; the terrain following the tracks edited; the
|
|
// terrain made from the model around the camera within the download area, in the background
|
|
struct terrain_model_settings
|
|
{
|
|
double band{300.0};
|
|
int around{4};
|
|
bool shape{true};
|
|
bool follow{true};
|
|
bool area{true};
|
|
};
|
|
terrain_model_settings &terrain_model() { return m_terrain_model; }
|
|
// the height offset of the terrain model to the tracks of the scenery, and whether it was fitted to them; false when none was stored
|
|
bool terrain_model_offset(std::string const &Scenery, double &Offset, bool &Fitted) const;
|
|
void terrain_model_offset(std::string const &Scenery, double Offset, bool Fitted);
|
|
bool track_tools_more() const { return m_track_tools_more; }
|
|
void track_tools_more(bool Show) { m_track_tools_more = Show; }
|
|
// the ballast of the railway drawn in the top view
|
|
int top_tracks() const { return m_top_tracks; }
|
|
void top_tracks(int const Tracks) { m_top_tracks = Tracks; }
|
|
std::uint32_t top_rails() const { return m_top_rails; }
|
|
void top_rails(std::uint32_t const Colour) { m_top_rails = Colour; }
|
|
// the heights of the tracks laid on the ground: fitted to it as the tracks go onto the terrain, the points clicked on it with
|
|
// even grades between them, level
|
|
enum class lay_heights
|
|
{
|
|
fitted,
|
|
points,
|
|
level
|
|
};
|
|
lay_heights heights() const { return m_heights; }
|
|
void heights(lay_heights Heights) { m_heights = Heights; }
|
|
|
|
private:
|
|
movement_scheme m_movement{movement_scheme::wsad};
|
|
orthophoto_settings m_orthophoto;
|
|
std::map<std::string, std::pair<double, double>> m_orthophoto_origins;
|
|
std::vector<wms_layer> m_wms_layers;
|
|
double m_platform_edge{1.725};
|
|
double m_signal_offset{2.25};
|
|
int m_signal_plate_look{1};
|
|
bool m_nodebank_previews{true};
|
|
int m_nodebank_card{96};
|
|
int m_palette{0};
|
|
bool m_first_steps{true};
|
|
bool m_terrain_offer{true};
|
|
bool m_terrain_buried_ask{true};
|
|
bool m_track_tools_more{false};
|
|
bool m_terrain_while_laying{true};
|
|
terrain_model_settings m_terrain_model;
|
|
std::map<std::string, std::pair<double, bool>> m_terrain_model_offsets;
|
|
int m_top_tracks{0}; // the railway in the top view: whole, without the ballast, the rails alone
|
|
std::uint32_t m_top_rails{0xffff6e28}; // colour of the rails alone, as ImGui keeps it: ABGR
|
|
lay_heights m_heights{lay_heights::points};
|
|
};
|
|
|
|
// global editor settings instance
|
|
extern editorSettings EditorSettings;
|