Wipe gridless cache if the wall layout changes
This commit is contained in:
+8
-1
@@ -7,6 +7,7 @@ import {disableSnap, registerKeybindings} from "./keybindings.js";
|
|||||||
import {libWrapper} from "./libwrapper_shim.js";
|
import {libWrapper} from "./libwrapper_shim.js";
|
||||||
import {performMigrations} from "./migration.js"
|
import {performMigrations} from "./migration.js"
|
||||||
import {removeLastHistoryEntryIfAt, resetMovementHistory} from "./movement_tracking.js";
|
import {removeLastHistoryEntryIfAt, resetMovementHistory} from "./movement_tracking.js";
|
||||||
|
import {wipeGridlessPathfindingCache} from "./pathfinding.js";
|
||||||
import {extendRuler} from "./ruler.js";
|
import {extendRuler} from "./ruler.js";
|
||||||
import {registerSettings, RightClickAction, settingsKey} from "./settings.js"
|
import {registerSettings, RightClickAction, settingsKey} from "./settings.js"
|
||||||
import {recalculate} from "./socket.js";
|
import {recalculate} from "./socket.js";
|
||||||
@@ -18,7 +19,13 @@ import initGridlessPathfinding, * as GridlessPathfinding from "../wasm/gridless_
|
|||||||
CONFIG.debug.dragRuler = false;
|
CONFIG.debug.dragRuler = false;
|
||||||
export let debugGraphics = undefined;
|
export let debugGraphics = undefined;
|
||||||
|
|
||||||
initGridlessPathfinding();
|
initGridlessPathfinding().then(() => {
|
||||||
|
Hooks.on("canvasInit", wipeGridlessPathfindingCache);
|
||||||
|
Hooks.on("canvasReady", wipeGridlessPathfindingCache);
|
||||||
|
Hooks.on("createWall", wipeGridlessPathfindingCache);
|
||||||
|
Hooks.on("updateWall", wipeGridlessPathfindingCache);
|
||||||
|
Hooks.on("deleteWall", wipeGridlessPathfindingCache);
|
||||||
|
});
|
||||||
|
|
||||||
Hooks.once("init", () => {
|
Hooks.once("init", () => {
|
||||||
registerSettings()
|
registerSettings()
|
||||||
|
|||||||
+8
-1
@@ -47,10 +47,17 @@ export function findPath(from, to, token, previousWaypoints) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function wipePathfindingCache() {
|
export function wipeGriddedPathfindingCache() {
|
||||||
cachedNodes = undefined;
|
cachedNodes = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function wipeGridlessPathfindingCache() {
|
||||||
|
if (gridlessPathfinder) {
|
||||||
|
GridlessPathfinding.free(gridlessPathfinder);
|
||||||
|
gridlessPathfinder = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getNode(pos, token, initialize=true) {
|
function getNode(pos, token, initialize=true) {
|
||||||
pos = {layer: 0, ...pos}; // Copy pos and set pos.layer to the default value if it's unset
|
pos = {layer: 0, ...pos}; // Copy pos and set pos.layer to the default value if it's unset
|
||||||
if (!cachedNodes)
|
if (!cachedNodes)
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@ import {currentSpeedProvider, getColorForDistanceAndToken, getRangesFromSpeedPro
|
|||||||
import {getHexSizeSupportTokenGridCenter} from "./compatibility.js";
|
import {getHexSizeSupportTokenGridCenter} from "./compatibility.js";
|
||||||
import {cancelScheduledMeasurement, measure} from "./foundry_imports.js"
|
import {cancelScheduledMeasurement, measure} from "./foundry_imports.js"
|
||||||
import {getMovementHistory} from "./movement_tracking.js";
|
import {getMovementHistory} from "./movement_tracking.js";
|
||||||
import {wipePathfindingCache} from "./pathfinding.js";
|
import {wipeGriddedPathfindingCache} from "./pathfinding.js";
|
||||||
import {settingsKey} from "./settings.js";
|
import {settingsKey} from "./settings.js";
|
||||||
import {getSnapPointForEntity} from "./util.js";
|
import {getSnapPointForEntity} from "./util.js";
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ export function extendRuler() {
|
|||||||
return;
|
return;
|
||||||
const ruler = canvas.controls.ruler;
|
const ruler = canvas.controls.ruler;
|
||||||
ruler.clear();
|
ruler.clear();
|
||||||
wipePathfindingCache();
|
wipeGriddedPathfindingCache();
|
||||||
ruler._state = Ruler.STATES.STARTING;
|
ruler._state = Ruler.STATES.STARTING;
|
||||||
let entityCenter;
|
let entityCenter;
|
||||||
if (isToken && canvas.grid.isHex && game.modules.get("hex-size-support")?.active && CONFIG.hexSizeSupport.getAltSnappingFlag(entity))
|
if (isToken && canvas.grid.isHex && game.modules.get("hex-size-support")?.active && CONFIG.hexSizeSupport.getAltSnappingFlag(entity))
|
||||||
|
|||||||
Reference in New Issue
Block a user