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

feat(editor): two free ends joined without loops or forced curves, the shape from a free end on the wheel

- the join of two free ends (a drag from one onto the other, or a click of the lay tool on it) tries in turn: a straight when the joints check can't see the kinks (half its angle), one circular arc through both ends (a piece cut out of a curve comes back as it was, its cant kept), a curve with straights where the tangents meet, a reverse curve, and only then a free Bezier curve; a curve turning more than it needs to, sharper than 10 m or longer than three chords is never taken
- the transition curves eased out of a curved neighbour only when there's room for them between the ends, never crossing each other into a loop
- cant and transition curves recommended for the radius the curve really gets, at the speed of the joined track or of the tool and never above what the radius allows; the circular arc keeps at least max(20 m, 0.4 V) between the transitions, the cant lowered to what the shortened transitions can ramp, transitions under 1 m left out
- shapes from a free end: arc then straight, straight then arc, arc through the cursor, straight; Ctrl+wheel steps the radius, Shift+wheel the shape (at a free end: the other joins), the plain wheel still zooms; a click of the lay tool from a free end lays the shape and goes on from its end
- self-test commands join, layto and joints; Polish translation
This commit is contained in:
maj00r
2026-10-11 11:11:21 +02:00
parent 3ed864812f
commit 16c1ac4c7b
8 changed files with 860 additions and 76 deletions

View File

@@ -731,7 +731,7 @@ char const *editor_mode::typed_meaning() const
{
auto const &straights{m_straights};
if (m_extend.active)
return m_extend_freehand && false == ImGui::GetIO().KeyCtrl ? "type the radius, a space, the length" : "type the length";
return m_track_layout == track_layout::straight || shift_straight() ? "type the length" : m_track_layout == track_layout::arc ? "type the radius, a space, the length" : "type the radius";
if (straights.dragging)
return straights.handle == 2 ? "type the shift, + to the right" : "type the length";
if (straights.tool == 1 && (straights.tool_mouse || straights.tool_dragging))
@@ -800,7 +800,9 @@ void editor_mode::typed_extend()
return;
auto &tool{m_extend};
auto const &direction{tool.direction};
if (false == m_extend_freehand || ImGui::GetIO().KeyCtrl)
if (m_track_layout != track_layout::straight && m_track_layout != track_layout::arc && false == shift_straight())
return;
if (m_track_layout == track_layout::straight || shift_straight())
{
auto const length{std::max(0.0, values[0])};
tool.mouse = {tool.point.x + direction.x * length, tool.mouse.y, tool.point.z + direction.y * length};
@@ -817,7 +819,7 @@ void editor_mode::typed_extend()
auto angle{values.size() > 1 ? std::abs(values[1]) / radius : side * geometry::signed_angle(radial, glm::dvec2{tool.mouse.x, tool.mouse.z} - centre)};
if (angle < 0.0)
angle += 2.0 * glm::pi<double>();
angle = std::clamp(angle, 1e-3, 2.0 * glm::pi<double>() - 0.1);
angle = std::clamp(angle, 1e-3, glm::pi<double>());
auto const end{centre + geometry::turned(radial, side * angle)};
tool.mouse = {end.x, tool.mouse.y, end.y};
}