18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 01:17:23 +01:00

fix(editor): any radius of a compound curve changed lays it at the speed of the line

A curve a trace laid slower than the line kept that speed with its vertex until its radius was changed, but only the R1
field and the arc handle cleared it. The other radii of a compound curve (their fields, a radius added or taken out, the
curve made compound or plain) changed the curve and left it at the speed of the radii it was fitted with. They now clear
it too.
This commit is contained in:
maj00r
2026-11-30 20:44:37 +01:00
parent ea118af410
commit 889f550eca
+11 -2
View File
@@ -2223,6 +2223,8 @@ bool editor_mode::render_route_vertex(int const Index)
if (false == vertex.spirals && ImGui::Checkbox(STR_C("Compound curve (several radii)"), &vertex.compound))
{
changed = true;
// the radii change: the speed a trace laid the curve slower for was of the ones it fitted
vertex.speed = 0.0;
if (vertex.compound && vertex.arcs.empty())
vertex.arcs.push_back({std::max(10.0, std::round(vertex.radius * 0.6 / 10.0) * 10.0), 0.0, 1.0});
}
@@ -2262,12 +2264,13 @@ bool editor_mode::render_route_vertex(int const Index)
ImGui::TextDisabled("%.0f%%", percent(vertex.share));
changed |= arc_cant(0, vertex.first_cant);
int removed{-1};
bool radiichanged{false};
for (int k = 0; k < static_cast<int>(vertex.arcs.size()); ++k)
{
auto &arc{vertex.arcs[k]};
ImGui::PushID(k);
ImGui::Separator();
changed |= ImGui::DragScalar(format(STR_C("Radius R%d (m)"), k + 2).c_str(), ImGuiDataType_Double, &arc.radius, 5.0f, nullptr, nullptr, "%.0f");
radiichanged |= ImGui::DragScalar(format(STR_C("Radius R%d (m)"), k + 2).c_str(), ImGuiDataType_Double, &arc.radius, 5.0f, nullptr, nullptr, "%.0f");
mark(part::arc, k + 1);
ImGui::SameLine();
if (ImGui::SmallButton("x"))
@@ -2293,13 +2296,19 @@ bool editor_mode::render_route_vertex(int const Index)
vertex.arcs.erase(vertex.arcs.begin() + removed);
if (vertex.arcs.empty())
vertex.compound = false;
changed = true;
radiichanged = true;
}
if (ImGui::SmallButton(STR_C("Add a radius")))
{
auto const last{vertex.arcs.empty() ? vertex.radius : vertex.arcs.back().radius};
vertex.arcs.push_back({std::max(10.0, std::round(last * 0.8 / 10.0) * 10.0), 0.0, 1.0});
radiichanged = true;
}
// any of the radii changed, as R1: the curve laid at the speed of the line again
if (radiichanged)
{
changed = true;
vertex.speed = 0.0;
}
item_tooltip("Another arc after the last one, the angle of the curve is shared out by the shares");
ImGui::Separator();