Commit 80b519b0 authored by Christian Winter's avatar Christian Winter

brush selection improved

parent 11affd46
Pipeline #4621254 passed with stage
in 48 seconds
......@@ -131,7 +131,7 @@ class MouseHandler {
pointsToChangeSelection.push(line.start);
else if (!s && !m && e)
pointsToChangeSelection.push(line.end);
else if (m || Utilities.distancePointToLine(mousePosition, line) <= cursorRange + line.thickness) {
else if (m || Utilities.distancePointToLine(mousePosition, line) <= cursorRange + (line.thickness * 0.5)) {
pointsToChangeSelection.push(line.start);
pointsToChangeSelection.push(line.end);
}
......
......@@ -12,22 +12,22 @@
let newSelPoints = [];
if (Preferences.selectVertices && Preferences.selectEdges) {
// TODO weird number but should be a third?
let limit = 0.25;
let s, e, m, _m;
for (let line of File.currentLayer.lines.concat(Selection.data.partialLines)) {
if (Utilities.distancePointToLine(mousePosition, line) <= cursorRange) {
// TODO PERFORMANCE
let startDist = line.start.position.subtractVector(mousePosition).sqrMagnitude();
let endDist = line.end.position.subtractVector(mousePosition).sqrMagnitude();
s = Utilities.pointWithinCircle(line.start, mousePosition, cursorRange);
e = Utilities.pointWithinCircle(line.end, mousePosition, cursorRange);
_m = line.start.position.addVector(line.end.position);
_m = _m.divide(2);
_m = new LineEnding(_m.x, _m.y, line);
m = Utilities.pointWithinCircle(_m, mousePosition, cursorRange);
if (startDist < endDist * limit)
newSelPoints.push(line.start);
else if (endDist < startDist * limit)
newSelPoints.push(line.end);
else {
newSelPoints.push(line.start);
newSelPoints.push(line.end);
}
if (s && !m && !e)
newSelPoints.push(line.start);
else if (!s && !m && e)
newSelPoints.push(line.end);
else if (m || Utilities.distancePointToLine(mousePosition, line) <= cursorRange + (line.thickness * 0.5)) {
newSelPoints.push(line.start);
newSelPoints.push(line.end);
}
}
} else if (Preferences.selectEdges) {
......@@ -58,22 +58,22 @@
let newUnselPoints = [];
if (Preferences.selectVertices && Preferences.selectEdges) {
// TODO weird number but should be a third?
let limit = 0.25;
let s, e, m, _m;
for (let line of Selection.data.lines.concat(Selection.data.partialLines)) {
if (Utilities.distancePointToLine(mousePosition, line) <= cursorRange) {
// TODO PERFORMANCE
let startDist = line.start.position.subtractVector(mousePosition).sqrMagnitude();
let endDist = line.end.position.subtractVector(mousePosition).sqrMagnitude();
s = Utilities.pointWithinCircle(line.start, mousePosition, cursorRange);
e = Utilities.pointWithinCircle(line.end, mousePosition, cursorRange);
_m = line.start.position.addVector(line.end.position);
_m = _m.divide(2);
_m = new LineEnding(_m.x, _m.y, line);
m = Utilities.pointWithinCircle(_m, mousePosition, cursorRange);
if (startDist < endDist * limit)
newUnselPoints.push(line.start);
else if (endDist < startDist * limit)
newUnselPoints.push(line.end);
else {
newUnselPoints.push(line.start);
newUnselPoints.push(line.end);
}
if (s && !m && !e)
newUnselPoints.push(line.start);
else if (!s && !m && e)
newUnselPoints.push(line.end);
else if (m || Utilities.distancePointToLine(mousePosition, line) <= cursorRange + (line.thickness * 0.5)) {
newUnselPoints.push(line.start);
newUnselPoints.push(line.end);
}
}
} else if (Preferences.selectEdges) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment