Simplify fog points more

This commit is contained in:
Mitchell McCaffrey 2021-03-12 14:15:29 +11:00
parent 506ec25a72
commit 8148e5c52c

View File

@ -206,14 +206,26 @@ function MapFog({
) { ) {
const cut = toolSettings.useFogCut; 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) { if (!toolSettings.multilayer) {
const shapesToSubtract = shapes.filter((shape) => const shapesToSubtract = shapes.filter((shape) =>
cut ? !shape.visible : shape.visible cut ? !shape.visible : shape.visible
); );
const subtractAction = new SubtractShapeAction(shapesToSubtract); const subtractAction = new SubtractShapeAction(shapesToSubtract);
const state = subtractAction.execute({ const state = subtractAction.execute({
[drawingShape.id]: drawingShape, [simplifiedShape.id]: simplifiedShape,
}); });
drawingShapes = Object.values(state) drawingShapes = Object.values(state)
.filter((shape) => shape.data.points.length > 2) .filter((shape) => shape.data.points.length > 2)
@ -222,24 +234,15 @@ function MapFog({
if (drawingShapes.length > 0) { if (drawingShapes.length > 0) {
drawingShapes = drawingShapes.map((shape) => { drawingShapes = drawingShapes.map((shape) => {
let shapeData = {};
if (cut) { if (cut) {
shapeData = { id: shape.id, type: shape.type }; return {
id: shape.id,
type: shape.type,
data: shape.data,
};
} else { } 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) { if (cut) {