18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-21 06:14:58 +01:00

feat(editor): area fill: Enter finishes an area, Esc drops the outline, a list of filled areas to change later (#241)

* feat(editor): fill_store, the filled areas kept in the scenery as //$f lines

* feat(editor): fill_store: reading and writing the filled areas

* build: editorFillStore.cpp

* feat(scene): //$f lines of the filled areas kept with the layer files

* feat(editor): area fill: the members of the list of filled areas

* lang(pl): area fill list

* feat(editor): area fill: Enter finishes an area, Esc drops the outline, filled areas listed to be changed later

* fix(editor): the filled areas kept as //$w lines, //$f being the fitted tracks of the profile tool

* fix(editor): a changed area keeps its own rotation and its layer; its models go to the layer of the area, on an undo as on a refill

Change + Enter took the rotation of the Functions panel instead of the area's own:
the area keeps it now, unless the rotation of the panel is changed while the area
is picked up.

The models of an area were made in the active layer, the area record stayed in its
own: on an undo of a change or a removal, with another layer active, they were
saved apart. create_model() takes the layer to put the model in (none: the active
one, as before), and the models of an area go to the layer of the area (the active
one if that's gone). The active layer isn't switched for it: Layers.active() also
shows and unlocks the layer it's given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ

* chore(editor): the seeded generator of the area fill marked as not security (Sonar cpp:S2245)

The fill must repeat from its seed (the same area filled again gets the
same objects), so a cryptographic generator is not wanted there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ

* ci(windows): build lua51.dll for the unit tests

(cherry picked from commit b3e6e02779)

* fix(editor): the filled areas kept under //$u, as //$w is the mark of the shared grade lines on master

After the review of jerrrrycho: on master //$w is the mark of the shared grade lines (scenelayers.cpp,
editormodegradeline.cpp), and both stores save through Layers.mark(Layer, Mark, Lines), which replaces the
lines of the mark. Once master reached this branch, a layer with a grade line and a filled area would have
kept only the lines of whichever store saved last; before that, a master build reads the lines of the areas
as grade lines it doesn't know.

The area fill takes //$u, free on master, on feat/gl46-migration and in the letters of the starters
(n d f i l a), and the same letter the ficzery2 builds the testers have already save the areas under, so
their sceneries keep their areas. A scenery saved by a build of this PR before this commit has its areas
under //$w: they are no longer read as areas; saved again, the editor keeps those lines as lines it doesn't
know.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QRgQ1K1Qu7TCsa74zsNURd

---------

Co-authored-by: miloszunio <miloszunio@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Hirek193 <polomarket73@gmail.com>
This commit is contained in:
pol102
2026-11-20 03:56:13 +01:00
committed by GitHub
parent 793ff968de
commit c9c390017a
11 changed files with 779 additions and 105 deletions

View File

@@ -38,6 +38,7 @@ http://mozilla.org/MPL/2.0/.
#include "editor/editorAlignment.hpp"
#include "editor/editorAlignmentStore.hpp"
#include "editor/editorSwitchStore.hpp"
#include "editor/editorFillStore.hpp"
#include "editor/editorSwitchCurve.hpp"
#include "editor/editorKilometrage.hpp"
#include "editor/editorSpeed.hpp"
@@ -1008,14 +1009,47 @@ class editor_mode : public application_mode, private editor_track::observer, pri
void render_change_history();
void render_settings();
// area fill: scatters models from a package over a polygon outlined in the viewport
// area fill: scatters models from a package over a polygon outlined in the viewport. a filled area goes on the list of the
// panel (fill_store, kept in the scenery), to be picked up again later: its outline and settings back in the tool, filled anew
void render_area_fill();
void render_fill_area_list();
void draw_area_fill_outline() const;
void add_area_fill_point();
void run_area_fill();
// Enter: the outline filled and put on the list, the tool ready for the next one
void finish_area_fill();
// Esc: the outline dropped; an area picked up for a change stays as it was
void cancel_area_fill();
void edit_fill_area(std::string const &Id);
void remove_fill_area(std::string const &Id);
void show_fill_area(std::string const &Id);
void undo_last_area_fill();
// the settings of the tool as an area, without its outline, id and label
fill_store::area fill_settings() const;
// the models the area is filled with, from its seed: the same each time for the same area. returns how many were placed
std::size_t place_fill_area(fill_store::area const &Area, std::size_t &Target, std::size_t &Unsupported);
std::vector<TAnimModel *> fill_area_models(std::string const &Id) const;
std::size_t erase_fill_area_models(std::string const &Id);
std::vector<glm::dvec3> m_fill_points; // outline vertices (world space) in click order
std::vector<TAnimModel *> m_fill_last; // instances created by the most recent fill, for "Undo last fill"
std::string m_fill_editing; // the listed area whose outline is in m_fill_points, empty for a new one
// the rotation of the area picked up and the one of the Functions panel then: the area keeps its own unless it's changed in the tool
float m_fill_editing_rotation{0.0f};
int m_fill_editing_panel_mode{-1};
float m_fill_editing_panel_value{0.0f};
std::string m_fill_hover; // the area under the cursor in the list, drawn brighter
// what "Undo last fill" takes back: the area filled, changed or removed last, and how it was before
struct fill_undo
{
enum class kind
{
added,
changed,
removed
};
kind what{kind::added};
std::string id;
fill_store::area before;
};
std::optional<fill_undo> m_fill_undo;
std::vector<std::string> m_fill_custom; // user-assembled package of node templates
int m_fill_custom_idx{-1};
model_set_ref m_fill_source; // manual = m_fill_custom, otherwise a user set or node bank group