Added bounding box check to fog edge snapping

This commit is contained in:
Mitchell McCaffrey 2021-02-13 10:20:55 +11:00
parent c6d87baf99
commit ed605fe55b

View File

@ -484,10 +484,19 @@ export function getSnappingVertex(
let closestDistance = Number.MAX_VALUE;
let closestPosition;
for (let i = 0; i < shapes.length; i++) {
// TODO: Check bounds before checking all points
// const bounds = boundingBoxes[i];
// Check bounds before checking all points
const bounds = boundingBoxes[i];
const offsetMin = Vector2.subtract(bounds.min, gridCellSize);
const offsetMax = Vector2.add(bounds.max, gridCellSize);
if (
brushPosition.x < offsetMin.x ||
brushPosition.x > offsetMax.x ||
brushPosition.y < offsetMin.y ||
brushPosition.y > offsetMax.y
) {
continue;
}
const shape = shapes[i];
// Include shape points and holes
let pointArray = [shape.data.points, ...shape.data.holes];