From 82f2a885fbee3311aed8c8efb63d46f5a1aa8f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Tue, 8 Mar 2022 23:09:06 +0100 Subject: [PATCH] `getSnappedPosition` cannot be used on gridless to calculate the snap point for measured templates --- js/util.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/util.js b/js/util.js index eb6e3cb..c2406e2 100644 --- a/js/util.js +++ b/js/util.js @@ -90,12 +90,19 @@ export function getSnapPointForTokenObj(pos, token) { return getSnapPointForToken(pos.x, pos.y, token); } +export function getSnapPointForMeasuredTemplate(x, y) { + if (canvas.grid.type === CONST.GRID_TYPES.GRIDLESS) { + return new PIXI.Point(x, y); + } + return canvas.grid.grid.getSnappedPosition(x, y, canvas.templates.gridPosition); +} + export function getSnapPointForEntity(x, y, entity) { const isToken = entity instanceof Token; if (isToken) return getSnapPointForToken(x, y, entity); else - return canvas.grid.grid.getSnappedPosition(x, y, canvas.templates.gridPosition); + return getSnapPointForMeasuredTemplate(x, y); } export function highlightTokenShape(position, shape, color, alpha) {