Remove redundant first waypoint from path generated by pathfinder

This fixes a bug where gridless snapping would snap slightly below the target range
This commit is contained in:
Manuel Vögele
2022-05-07 08:12:30 +02:00
parent d325f8acee
commit 5904efbdd5
+3 -1
View File
@@ -175,7 +175,9 @@ export function measure(destination, options={}) {
const from = getGridPositionFromPixelsObj(this.waypoints[this.waypoints.length - 1]); const from = getGridPositionFromPixelsObj(this.waypoints[this.waypoints.length - 1]);
const to = getGridPositionFromPixelsObj(destination); const to = getGridPositionFromPixelsObj(destination);
let path = findPath(from, to, this.draggedEntity, this.waypoints); let path = findPath(from, to, this.draggedEntity, this.waypoints);
if (path) { if (path)
path.shift();
if (path && path.length > 0) {
path = path.map(point => getSnapPointForTokenObj(getPixelsFromGridPositionObj(point), this.draggedEntity)); path = path.map(point => getSnapPointForTokenObj(getPixelsFromGridPositionObj(point), this.draggedEntity));
// If the token is snapped to the grid, the first point of the path is already handled by the ruler // If the token is snapped to the grid, the first point of the path is already handled by the ruler