Commit dffa2d6a authored by Christian Winter's avatar Christian Winter

removed pointWithinCircle. now using Vector2.equals

parent 3ebae366
Pipeline #5143631 passed with stage
in 53 seconds
......@@ -230,13 +230,6 @@ Utilities = new class {
Application.currentView.logic.setState(new MoveLinesState());
}
pointWithinCircle(p, center, radius) {
if (p instanceof LineEnding)
return Vector2.distance(p.position, center) <= radius + (p.line.thickness * 0.5);
return Vector2.distance(p, center) <= radius;
}
fill(points) {
if (points.length > 20)
if (!confirm("Are you sure you want to contine with the fill operation with " + points.length + " points. This could take a while to compute."))
......
......@@ -588,14 +588,14 @@
let allSelectedPoints = [];
for (let i = 0; i < selectedPoints.length; ++i)
allSelectedPoints = allSelectedPoints.concat(this.getAllLineEndingsAt(selectedPoints[i].position, 0.1)); // TODO magic number, should use Vector2.Equals-epsilon?
allSelectedPoints = allSelectedPoints.concat(this.getAllLineEndingsAt(selectedPoints[i].position));
for (let i = 0; i < allSelectedPoints.length; ++i)
this.selection.data.addPoint(allSelectedPoints[i]);
for (let i = 0; i < allSelectedPoints.length; ++i) {
let p = allSelectedPoints[i].opposite;
let pArray = this.getAllLineEndingsAt(p.position, 0);
let pArray = this.getAllLineEndingsAt(p.position);
for (let j = 0; j < pArray.length; ++j)
this.selection.data.addPoint(pArray[j]);
......@@ -629,14 +629,14 @@
// TODO extract one part into data class? and other into selection-data?
// TODO withinRadius, magic number? use epsilon?
getAllLineEndingsAt(clickPoint, withinRadius) {
getAllLineEndingsAt(position) {
let points = [];
let lines = this.data.lines.concat(this.selection.data.partialLines);
for (let i = 0; i < lines.length; ++i) {
if (Utilities.pointWithinCircle(lines[i].start.position, clickPoint, withinRadius))
if (lines[i].start.position.equals(position))
points.push(lines[i].start);
if (Utilities.pointWithinCircle(lines[i].end.position, clickPoint, withinRadius))
if (lines[i].end.position.equals(position))
points.push(lines[i].end);
}
return points;
......
......@@ -125,7 +125,6 @@ class Vector2 {
);
}
// TODO static?
equals(other) {
let epsilon = 0.01; // TODO STATIC??
return Vector2.sqrDistance(this, other) <= (epsilon * epsilon);
......
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