getSnappedPosition cannot be used on gridless to calculate the snap point for measured templates

This commit is contained in:
Manuel Vögele
2022-03-08 23:09:06 +01:00
parent 5add0be393
commit 82f2a885fb
+8 -1
View File
@@ -90,12 +90,19 @@ export function getSnapPointForTokenObj(pos, token) {
return getSnapPointForToken(pos.x, pos.y, 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) { export function getSnapPointForEntity(x, y, entity) {
const isToken = entity instanceof Token; const isToken = entity instanceof Token;
if (isToken) if (isToken)
return getSnapPointForToken(x, y, entity); return getSnapPointForToken(x, y, entity);
else else
return canvas.grid.grid.getSnappedPosition(x, y, canvas.templates.gridPosition); return getSnapPointForMeasuredTemplate(x, y);
} }
export function highlightTokenShape(position, shape, color, alpha) { export function highlightTokenShape(position, shape, color, alpha) {