From 00422a81135bf234750798de142efa376538a869 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Mon, 25 Jan 2021 13:38:37 +1100 Subject: [PATCH] Added extra logging to fog cut --- src/helpers/drawing.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/helpers/drawing.js b/src/helpers/drawing.js index a88123b..c454ead 100644 --- a/src/helpers/drawing.js +++ b/src/helpers/drawing.js @@ -3,6 +3,7 @@ import polygonClipping from "polygon-clipping"; import * as Vector2 from "./vector2"; import { toDegrees, omit } from "./shared"; +import { logError } from "./logging"; const snappingThreshold = 1 / 5; export function getBrushPositionForTool( @@ -251,13 +252,23 @@ export function drawActionsToShapes(actions, actionIndex) { hole.map(({ x, y }) => [x, y]) ); let shapeGeom = [[shapePoints, ...shapeHoles]]; - const difference = polygonClipping.difference(shapeGeom, actionGeom); - const intersection = polygonClipping.intersection( - shapeGeom, - actionGeom - ); - addPolygonDifferenceToShapes(shape, difference, cutShapes); - addPolygonIntersectionToShapes(shape, intersection, cutShapes); + try { + const difference = polygonClipping.difference(shapeGeom, actionGeom); + const intersection = polygonClipping.intersection( + shapeGeom, + actionGeom + ); + addPolygonDifferenceToShapes(shape, difference, cutShapes); + addPolygonIntersectionToShapes(shape, intersection, cutShapes); + } catch { + logError( + new Error( + `Unable to find segment for shapes ${JSON.stringify( + shape + )} and ${JSON.stringify(action)}` + ) + ); + } } shapesById = cutShapes; }