Change fog brush to simplify on pointer up instead of pointer move

This commit is contained in:
Mitchell McCaffrey 2021-08-21 17:09:32 +10:00
parent 91f44f9eda
commit c710096f8b

View File

@ -223,15 +223,11 @@ function FogTool({
) { ) {
return prevShape; return prevShape;
} }
const simplified = simplifyPoints(
[...prevPoints, brushPosition],
1 / 1000 / stageScale
);
return { return {
...prevShape, ...prevShape,
data: { data: {
...prevShape.data, ...prevShape.data,
points: simplified, points: [...prevPoints, brushPosition],
}, },
}; };
}); });
@ -267,8 +263,15 @@ function FogTool({
(toolSettings.type === "brush" || toolSettings.type === "rectangle") && (toolSettings.type === "brush" || toolSettings.type === "rectangle") &&
drawingShape drawingShape
) { ) {
let simplifiedShape = { ...drawingShape };
if (toolSettings.type === "brush") {
simplifiedShape.data.points = simplifyPoints(
simplifiedShape.data.points,
1 / 1000 / stageScale
);
}
const cut = toolSettings.useFogCut; const cut = toolSettings.useFogCut;
let drawingShapes = [drawingShape]; let drawingShapes = [simplifiedShape];
// Filter out hidden or visible shapes if single layer enabled // Filter out hidden or visible shapes if single layer enabled
if (!toolSettings.multilayer) { if (!toolSettings.multilayer) {
@ -277,7 +280,7 @@ function FogTool({
); );
const subtractAction = new SubtractFogAction(shapesToSubtract); const subtractAction = new SubtractFogAction(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)