Fix remainging errors from merge
This commit is contained in:
+2
-2
@@ -2,7 +2,7 @@ import {getCenterFromGridPositionObj, getGridPositionFromPixelsObj, getPixelsFro
|
|||||||
import {moveWithoutAnimation, togglePathfinding} from "./keybindings.js";
|
import {moveWithoutAnimation, togglePathfinding} from "./keybindings.js";
|
||||||
import {debugGraphics} from "./main.js";
|
import {debugGraphics} from "./main.js";
|
||||||
import {settingsKey} from "./settings.js";
|
import {settingsKey} from "./settings.js";
|
||||||
import {buildSnapPointTokenData, getSnapPointForTokenDataObj, isModuleActive, iterPairs} from "./util.js";
|
import {buildSnapPointTokenData, getSnapPointForTokenDataObj, getTokenShape, getTokenShapeForTokenData, isModuleActive, iterPairs} from "./util.js";
|
||||||
|
|
||||||
import * as GridlessPathfinding from "../wasm/gridless_pathfinding.js";
|
import * as GridlessPathfinding from "../wasm/gridless_pathfinding.js";
|
||||||
import {PriorityQueueSet, ProcessOnceQueue} from "./data_structures.js";
|
import {PriorityQueueSet, ProcessOnceQueue} from "./data_structures.js";
|
||||||
@@ -322,7 +322,7 @@ function getNode(pos, cacheLayer, initialize = true) {
|
|||||||
let edgeCost;
|
let edgeCost;
|
||||||
if (window.terrainRuler) {
|
if (window.terrainRuler) {
|
||||||
let ray = new Ray(getCenterFromGridPositionObj(neighborPos), getCenterFromGridPositionObj(pos));
|
let ray = new Ray(getCenterFromGridPositionObj(neighborPos), getCenterFromGridPositionObj(pos));
|
||||||
let measuredDistance = terrainRuler.measureDistances([{ray}], {costFunction: buildCostFunction(token, getTokenShape(token))})[0];
|
let measuredDistance = terrainRuler.measureDistances([{ray}], {costFunction: buildCostFunction(cacheLayer.tokenData, getTokenShapeForTokenData(cacheLayer.tokenData))})[0];
|
||||||
edgeCost = Math.round(measuredDistance / canvas.dimensions.distance);
|
edgeCost = Math.round(measuredDistance / canvas.dimensions.distance);
|
||||||
if (ray.terrainRulerFinalState?.noDiagonals === 1) {
|
if (ray.terrainRulerFinalState?.noDiagonals === 1) {
|
||||||
edgeCost = 1.5;
|
edgeCost = 1.5;
|
||||||
|
|||||||
+13
-9
@@ -167,15 +167,19 @@ export function getAreaFromPositionAndShape(position, shape) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getTokenShape(token) {
|
export function getTokenShape(token) {
|
||||||
if (token.scene.data.gridType === CONST.GRID_TYPES.GRIDLESS) {
|
return getTokenShapeForTokenData(buildSnapPointTokenData(token), token.scene);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getTokenShapeForTokenData(tokenData, scene=canvas.scene) {
|
||||||
|
if (scene.data.gridType === CONST.GRID_TYPES.GRIDLESS) {
|
||||||
return [{x: 0, y: 0}]
|
return [{x: 0, y: 0}]
|
||||||
}
|
}
|
||||||
else if (token.scene.data.gridType === CONST.GRID_TYPES.SQUARE) {
|
else if (scene.data.gridType === CONST.GRID_TYPES.SQUARE) {
|
||||||
const topOffset = -Math.floor(token.data.height / 2)
|
const topOffset = -Math.floor(tokenData.height / 2)
|
||||||
const leftOffset = -Math.floor(token.data.width / 2)
|
const leftOffset = -Math.floor(tokenData.width / 2)
|
||||||
const shape = []
|
const shape = []
|
||||||
for (let y = 0;y < token.data.height;y++) {
|
for (let y = 0;y < tokenData.height;y++) {
|
||||||
for (let x = 0;x < token.data.width;x++) {
|
for (let x = 0;x < tokenData.width;x++) {
|
||||||
shape.push({x: x + leftOffset, y: y + topOffset})
|
shape.push({x: x + leftOffset, y: y + topOffset})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,8 +187,8 @@ export function getTokenShape(token) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Hex grids
|
// Hex grids
|
||||||
if (game.modules.get("hex-size-support")?.active && CONFIG.hexSizeSupport.getAltSnappingFlag(token)) {
|
if (game.modules.get("hex-size-support")?.active && tokenData.hexSizeSupport.altSnappingFlag) {
|
||||||
const borderSize = token.data.flags["hex-size-support"].borderSize;
|
const borderSize = tokenData.hexSizeSupport.borderSize;
|
||||||
let shape = [{x: 0, y: 0}];
|
let shape = [{x: 0, y: 0}];
|
||||||
if (borderSize >= 2)
|
if (borderSize >= 2)
|
||||||
shape = shape.concat([{x: 0, y: -1}, {x: -1, y: -1}]);
|
shape = shape.concat([{x: 0, y: -1}, {x: -1, y: -1}]);
|
||||||
@@ -193,7 +197,7 @@ export function getTokenShape(token) {
|
|||||||
if (borderSize >= 4)
|
if (borderSize >= 4)
|
||||||
shape = shape.concat([{x: -2, y: -1}, {x: 1, y: -1}, {x: -1, y: -2}, {x: 0, y: -2}, {x: 1, y: -2}])
|
shape = shape.concat([{x: -2, y: -1}, {x: 1, y: -1}, {x: -1, y: -2}, {x: 0, y: -2}, {x: 1, y: -2}])
|
||||||
|
|
||||||
if (Boolean(CONFIG.hexSizeSupport.getAltOrientationFlag(token)) !== canvas.grid.grid.options.columns)
|
if (Boolean(tokenData.hexSizeSupport.altOrientationFlag) !== canvas.grid.grid.options.columns)
|
||||||
shape.forEach(space => space.y *= -1);
|
shape.forEach(space => space.y *= -1);
|
||||||
if (canvas.grid.grid.options.columns)
|
if (canvas.grid.grid.options.columns)
|
||||||
shape = shape.map(space => {return {x: space.y, y: space.x}});
|
shape = shape.map(space => {return {x: space.y, y: space.x}});
|
||||||
|
|||||||
Reference in New Issue
Block a user