17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-05 13:14:50 +01:00

fix(editor): an arc and a straight laid to a point on the circle of the radius aren't refused

This commit is contained in:
maj00r
2026-10-21 13:20:47 +02:00
parent a39a3d4dbe
commit eea0900928

View File

@@ -81,15 +81,17 @@ std::vector<segment_data> arc_then_straight(glm::dvec3 const &Point, glm::dvec2
turn += 2.0 * glm::pi<double>(); turn += 2.0 * glm::pi<double>();
auto const heading{turned(Direction, Side * turn)}; auto const heading{turned(Direction, Side * turn)};
auto const remaining{glm::dot(plan_of(Target) - centre - radial, heading)}; auto const remaining{glm::dot(plan_of(Target) - centre - radial, heading)};
if (remaining > 0.0 && (rest < 0.0 || turn < angle)) if (remaining > -1e-3 && (rest < 0.0 || turn < angle))
{ {
rest = remaining; rest = std::max(0.0, remaining);
angle = turn; angle = turn;
} }
} }
if (rest < 0.0 || angle > glm::pi<double>()) if (rest < 0.0 || angle > glm::pi<double>())
return {}; return {};
auto pieces{arc_pieces(Point, Direction, Grade, Radius, angle, Side)}; auto pieces{arc_pieces(Point, Direction, Grade, Radius, angle, Side)};
if (rest < 0.01)
return pieces;
auto const tail{straight_piece(pieces.back().points[segment_data::point::end], turned(Direction, Side * angle), Grade, rest)}; auto const tail{straight_piece(pieces.back().points[segment_data::point::end], turned(Direction, Side * angle), Grade, rest)};
pieces.insert(pieces.end(), tail.begin(), tail.end()); pieces.insert(pieces.end(), tail.begin(), tail.end());
return pieces; return pieces;