From 8148e5c52cd571e46ca1a5880e63c31075fe47c1 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 12 Mar 2021 14:15:29 +1100 Subject: [PATCH] Simplify fog points more --- src/components/map/MapFog.js | 37 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/components/map/MapFog.js b/src/components/map/MapFog.js index d36f767..116cc49 100644 --- a/src/components/map/MapFog.js +++ b/src/components/map/MapFog.js @@ -206,14 +206,26 @@ function MapFog({ ) { const cut = toolSettings.useFogCut; - let drawingShapes = [drawingShape]; + let simplifiedShape = { + ...drawingShape, + data: { + ...drawingShape.data, + points: simplifyPoints( + drawingShape.data.points, + gridCellNormalizedSize, + Math.max(stageScale, 1) + ), + }, + }; + + let drawingShapes = [simplifiedShape]; if (!toolSettings.multilayer) { const shapesToSubtract = shapes.filter((shape) => cut ? !shape.visible : shape.visible ); const subtractAction = new SubtractShapeAction(shapesToSubtract); const state = subtractAction.execute({ - [drawingShape.id]: drawingShape, + [simplifiedShape.id]: simplifiedShape, }); drawingShapes = Object.values(state) .filter((shape) => shape.data.points.length > 2) @@ -222,24 +234,15 @@ function MapFog({ if (drawingShapes.length > 0) { drawingShapes = drawingShapes.map((shape) => { - let shapeData = {}; if (cut) { - shapeData = { id: shape.id, type: shape.type }; + return { + id: shape.id, + type: shape.type, + data: shape.data, + }; } else { - shapeData = { ...shape, color: "black" }; + return { ...shape, color: "black" }; } - return { - ...shapeData, - data: { - ...shape.data, - points: simplifyPoints( - shape.data.points, - gridCellNormalizedSize, - // Downscale fog as smoothing doesn't currently work with edge snapping - Math.max(stageScale, 1) / 2 - ), - }, - }; }); if (cut) {