From 355da5d012541e478725f6ab00870d20a0167e46 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 12 Mar 2021 13:16:27 +1100 Subject: [PATCH] Add max points to fog bounding box --- src/components/map/MapFog.js | 3 ++- src/helpers/drawing.js | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/map/MapFog.js b/src/components/map/MapFog.js index fa12e6c..8ae205e 100644 --- a/src/components/map/MapFog.js +++ b/src/components/map/MapFog.js @@ -284,6 +284,7 @@ function MapFog({ function handlePointerMove() { if ( + editable && active && (toolSettings.type === "polygon" || toolSettings.type === "rectangle") ) { @@ -572,7 +573,7 @@ function MapFog({ if (editable) { const visibleShapes = shapes.filter(shapeVisible); - setFogShapeBoundingBoxes(getFogShapesBoundingBoxes(visibleShapes)); + setFogShapeBoundingBoxes(getFogShapesBoundingBoxes(visibleShapes, 5)); setFogShapes(visibleShapes); } else { setFogShapes(mergeFogShapes(shapes)); diff --git a/src/helpers/drawing.js b/src/helpers/drawing.js index 9f3f595..4491d61 100644 --- a/src/helpers/drawing.js +++ b/src/helpers/drawing.js @@ -260,11 +260,15 @@ export function mergeFogShapes(shapes, ignoreHidden = true) { /** * @param {Fog[]} shapes + * @param {boolean} maxPoints Max amount of points per shape to get bounds for * @returns {Vector2.BoundingBox[]} */ -export function getFogShapesBoundingBoxes(shapes) { +export function getFogShapesBoundingBoxes(shapes, maxPoints = 0) { let boxes = []; for (let shape of shapes) { + if (maxPoints > 0 && shape.data.points.length > maxPoints) { + continue; + } boxes.push(Vector2.getBoundingBox(shape.data.points)); } return boxes;