Add max points to fog bounding box

This commit is contained in:
Mitchell McCaffrey 2021-03-12 13:16:27 +11:00
parent c8e2707421
commit 355da5d012
2 changed files with 7 additions and 2 deletions

View File

@ -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));

View File

@ -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;