17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-20 21:04:37 +02:00

fix(editor): a slip goes to the crossing under the cursor or nowhere, shown before the click

A slip went to the crossing of the selected straight with another straight within 40 m of the click. When the track under the cursor wasn't taken as a straight (a slight curve, a switch), the slip silently went to another crossing up to 40 m away. A double slip within 25 m of the click was replaced, even when the click was on a free crossing.

- The crossing nearest the cursor, within 12 m, is found among all the rail tracks. A slip goes only there; when that track is a curve or a switch, the tool says so.
- A double slip is replaced only when it is nearer the cursor than any crossing.
- The cursor is taken at the height of the straight under it, so on a grade the 3D view doesn't put the click metres away from the track.
- Before the click, the view marks the crossing the slip goes to, with its two straights, or the reason it can't go there.
This commit is contained in:
maj00r
2026-10-19 18:20:41 +02:00
parent 59ee32da58
commit 93a45fb632
5 changed files with 204 additions and 53 deletions

View File

@@ -1432,6 +1432,26 @@ class editor_mode : public application_mode, private editor_track::observer
bool stretchable(editor_track::snap_target const &Target) const;
std::vector<TTrack *> link_tracks(editor_track::snap_target const &Target, editor_track::branch_link const &Link, TTrack const &Style, std::vector<std::pair<TTrack *, editor_track::state>> &States, std::vector<TTrack *> &Created);
bool cut_straight(editor_track::straight const &Line, double const From, double const To, std::vector<std::pair<TTrack *, editor_track::state>> &States, std::vector<TTrack *> &Created, std::vector<TTrack *> &Removed, TTrack **Style);
// where a slip or a crossing goes for the cursor at Point on the straight Line: the crossing of Line with the rail track
// nearest the cursor, or the double slip there to be replaced
struct slip_plan
{
std::string problem;
std::string note;
TTrack *replaces{nullptr};
TTrack *other{nullptr};
glm::dvec2 crossing{0.0};
glm::dvec2 first{0.0, 1.0};
glm::dvec2 direction{0.0, 1.0};
double angle{0.0};
double alongfirst{0.0};
double half{0.0};
editor_track::slip_curve curve;
std::array<glm::dvec3, 4> points{};
};
bool plan_double_slip(editor_track::straight const &Line, glm::dvec3 const &Point, editor_track::switch_template const &Shape, slip_plan &Plan) const;
// the cursor where it points at the straight, at the height of the straight there
glm::dvec3 cursor_on_straight(editor_track::straight const &Line) const;
bool insert_double_slip(editor_track::straight const &Line, glm::dvec3 const &Point, editor_track::switch_template const &Shape);
bool replace_double_slip(TTrack &Part, editor_track::switch_template const &Shape);
std::vector<TTrack *> build_double_slip(glm::dvec3 const &PointA, glm::dvec3 const &PointB, glm::dvec3 const &PointC, glm::dvec3 const &PointD, glm::dvec2 const &Crossing, double const Height, glm::dvec2 const &First, glm::dvec2 const &Second, double const Angle, editor_track::slip_curve const &Curve, TTrack &Style, std::string const &Type = "Rkpd");