mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-20 17:25:00 +01:00
fix(editor): a road point picked on the screen only when nothing is under the cursor, and not through it; Alt+drag dropped with Esc, the work area or the window, no undo in the middle of it
The click takes the point by the ground clicked, then the piece or the junction under the cursor; the point nearest on the screen only when there's none, no farther than what is under the cursor and a bit beyond it, by whole pixels first and the range then, so the order of the roads doesn't decide. The ends of the pieces are gone through without looking for the repeated ones (editor_road::each_joint), joints() isn't needed. Esc, the road window closed, another tool or the track work area drop the drag; Ctrl+Z and Ctrl+Y wait for its end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ
This commit is contained in:
@@ -1621,22 +1621,15 @@ bool editor_road::nearest_joint(glm::dvec3 const &Point, double const Radius, gl
|
||||
return found;
|
||||
}
|
||||
|
||||
std::vector<glm::dvec3> editor_road::joints()
|
||||
void editor_road::each_joint(std::function<void(glm::dvec3 const &)> const &Visit)
|
||||
{
|
||||
std::vector<glm::dvec3> result;
|
||||
for (auto const *road : simulation::Roads.sequence())
|
||||
{
|
||||
if (road == nullptr || road->m_editorremoved)
|
||||
continue;
|
||||
for (auto const atend : {false, true})
|
||||
{
|
||||
auto const position{axis_end(road->definition(), atend)};
|
||||
auto const same = [&position](glm::dvec3 const &Listed) { return glm::distance(Listed, position) < kSamePoint; };
|
||||
if (std::none_of(result.begin(), result.end(), same))
|
||||
result.push_back(position);
|
||||
}
|
||||
Visit(axis_end(road->definition(), false));
|
||||
Visit(axis_end(road->definition(), true));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<editor_road::piece_end> editor_road::ends_at(glm::dvec3 const &Point)
|
||||
|
||||
@@ -128,8 +128,8 @@ class editor_road
|
||||
static junction_node *nearest_junction(glm::dvec3 const &Point);
|
||||
// the point where pieces meet or end which is nearest to specified one, within specified distance from it. returns: false if there's none
|
||||
static bool nearest_joint(glm::dvec3 const &Point, double const Radius, glm::dvec3 &Joint);
|
||||
// every point where pieces meet or end, each once
|
||||
static std::vector<glm::dvec3> joints();
|
||||
// Visit called for the ends of every piece, a point where several meet as many times (no search for the repeated ones)
|
||||
static void each_joint(std::function<void(glm::dvec3 const &)> const &Visit);
|
||||
// ends of the pieces which meet at specified point
|
||||
static std::vector<piece_end> ends_at(glm::dvec3 const &Point);
|
||||
// junctions with an arm at specified point, each with the number of that arm
|
||||
|
||||
Reference in New Issue
Block a user