Wire selection fixes:

- Fixed MathUtils.LineToPointDistance returning NaN if both points of the line are at the same position, preventing from selecting some wire nodes in the wiring mode.
- Added an indicator that shows when a node is highlighted.
- Wire nodes a higher preference for being highlighted than wire sections. Makes it easier to select nodes that are on top of another wire.

Closes #215
This commit is contained in:
Joonas Rikkonen
2018-01-01 15:04:53 +02:00
parent 79f3f04c3b
commit 78c13ddb42
3 changed files with 38 additions and 23 deletions
@@ -336,6 +336,11 @@ namespace Barotrauma
float xDiff = lineB.X - lineA.X;
float yDiff = lineB.Y - lineA.Y;
if (xDiff == 0 && yDiff == 0)
{
return Vector2.Distance(lineA, point);
}
return (float)(Math.Abs(xDiff * (lineA.Y - point.Y) - yDiff * (lineA.X - point.X)) /
Math.Sqrt(xDiff * xDiff + yDiff * yDiff));
}