Add more simplification to fog shapes

This commit is contained in:
Mitchell McCaffrey 2021-03-12 14:33:08 +11:00
parent 8148e5c52c
commit 84d6db3ce7

View File

@ -170,11 +170,16 @@ function MapFog({
) { ) {
return prevShape; return prevShape;
} }
const simplified = simplifyPoints(
[...prevPoints, brushPosition],
gridCellNormalizedSize,
stageScale / 4
);
return { return {
...prevShape, ...prevShape,
data: { data: {
...prevShape.data, ...prevShape.data,
points: [...prevPoints, brushPosition], points: simplified,
}, },
}; };
}); });
@ -205,27 +210,14 @@ function MapFog({
drawingShape drawingShape
) { ) {
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({
[simplifiedShape.id]: simplifiedShape, [drawingShape.id]: drawingShape,
}); });
drawingShapes = Object.values(state) drawingShapes = Object.values(state)
.filter((shape) => shape.data.points.length > 2) .filter((shape) => shape.data.points.length > 2)