17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-18 14:59:19 +02:00

feat(editor): the branch of a switch leads into the free end of a track: when the angles match the switch slides so its branch lies on the track's line, otherwise an arc of the switch radius right after the switch turns into it (with a straight between for a parallel track); works while placing a switch (drag toward the end) and when dragging from the branch end of a placed one, the track is shortened when it reaches past the branch; self-test switchlink / branchlink

This commit is contained in:
maj00r
2026-10-11 23:53:18 +02:00
parent f1a3bde00f
commit 0a73550c8d
6 changed files with 522 additions and 2 deletions

View File

@@ -1072,6 +1072,10 @@ class editor_mode : public application_mode, private editor_track::observer
editor_track::snap_target origin;
editor_track::snap_target snap;
glm::vec2 pressed{0.f};
bool slides{false};
double slide_low{0.0};
double slide_high{0.0};
std::vector<TTrack *> line;
};
extend_tool m_extend;
// lays new track through the clicked points, with no path needed to start from
@@ -1124,6 +1128,22 @@ class editor_mode : public application_mode, private editor_track::observer
std::vector<segment_data> paths;
};
bool plan_crossover(crossover_plan &Plan) const;
struct switch_link
{
editor_track::snap_target target;
editor_track::branch_link link;
double along{0.0};
int forward{1};
int side{1};
std::vector<segment_data> paths;
std::string reason;
};
bool plan_switch_link(switch_link &Plan) const;
void insert_linked_switch(switch_link const &Plan);
bool plan_branch_link(editor_track::branch_link &Link, std::string &Reason) const;
void finish_branch_link(editor_track::branch_link const &Link);
std::string link_problem(editor_track::snap_target const &Target, editor_track::branch_link const &Link) const;
std::vector<TTrack *> link_tracks(editor_track::snap_target const &Target, editor_track::branch_link const &Link, 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);
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);