From 84d6db3ce7843d087022a5ce5745e9469a3bcd09 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 12 Mar 2021 14:33:08 +1100 Subject: [PATCH] Add more simplification to fog shapes --- src/components/map/MapFog.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/components/map/MapFog.js b/src/components/map/MapFog.js index 116cc49..f90ff86 100644 --- a/src/components/map/MapFog.js +++ b/src/components/map/MapFog.js @@ -170,11 +170,16 @@ function MapFog({ ) { return prevShape; } + const simplified = simplifyPoints( + [...prevPoints, brushPosition], + gridCellNormalizedSize, + stageScale / 4 + ); return { ...prevShape, data: { ...prevShape.data, - points: [...prevPoints, brushPosition], + points: simplified, }, }; }); @@ -205,27 +210,14 @@ function MapFog({ drawingShape ) { const cut = toolSettings.useFogCut; - - let simplifiedShape = { - ...drawingShape, - data: { - ...drawingShape.data, - points: simplifyPoints( - drawingShape.data.points, - gridCellNormalizedSize, - Math.max(stageScale, 1) - ), - }, - }; - - let drawingShapes = [simplifiedShape]; + let drawingShapes = [drawingShape]; if (!toolSettings.multilayer) { const shapesToSubtract = shapes.filter((shape) => cut ? !shape.visible : shape.visible ); const subtractAction = new SubtractShapeAction(shapesToSubtract); const state = subtractAction.execute({ - [simplifiedShape.id]: simplifiedShape, + [drawingShape.id]: drawingShape, }); drawingShapes = Object.values(state) .filter((shape) => shape.data.points.length > 2)