17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-29 01:07:28 +01: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

@@ -204,6 +204,27 @@ class editor_track
static std::optional<straight_axis> main_axis(TTrack const &Switch);
static std::vector<segment_data> slid(TTrack const &Switch, double const Distance);
struct branch_end
{
glm::dvec3 position{0.0};
glm::dvec2 direction{0.0, 1.0};
double grade{0.0};
double roll{0.0};
};
struct branch_link
{
bool valid{false};
double shift{0.0};
double trim{0.0};
double radius{0.0};
double before{0.0};
double after{0.0};
double shortfall{0.0};
std::vector<segment_data> pieces;
};
static double branch_radius(segment_data const &Diverging);
static branch_link link_branch(branch_end const &From, glm::dvec3 const &Slide, double const Radius, branch_end const &To, double const Kink);
struct snap_target
{
TTrack *track{nullptr};