Work towards gridless difficult terrain pathfinding

This commit is contained in:
Manuel Vögele
2022-06-10 16:52:44 +02:00
parent 445c03d29a
commit c08d65ffad
7 changed files with 333 additions and 43 deletions
+10 -1
View File
@@ -253,7 +253,10 @@ export function findPath(from, to, token, previousWaypoints) {
let pathfinder = gridlessPathfinders.get(tokenSize);
if (!pathfinder) {
let radiusMultiplier = game.settings.get(settingsKey, "pathfindingRadius");
pathfinder = GridlessPathfinding.initialize(canvas.walls.placeables, tokenSize * radiusMultiplier, token.data.elevation, Boolean(game.modules.get("wall-height")?.active));
// TODO Pass proper options to listAllTerrain
// TODO Wipe caches when they become invalid
// TODO Multiple caches, analog to gridded pathfinding
pathfinder = GridlessPathfinding.initialize(canvas.walls.placeables, canvas.terrain.listAllTerrain(), tokenSize * radiusMultiplier, token.data.elevation, Boolean(game.modules.get("wall-height")?.active));
gridlessPathfinders.set(tokenSize, pathfinder);
}
paintGridlessPathfindingDebug(pathfinder);
@@ -304,6 +307,12 @@ export function findPath(from, to, token, previousWaypoints) {
}
}
export function terrainRulerWrapper(from, to) {
// TODO Send list of terrain to terrain layer
const ray = new Ray(from, to);
return terrainRuler.measureDistances([{ray}])[0] / canvas.dimensions.distance * canvas.dimensions.size;
}
function buildTokenData(token) {
// Almost all the information we need is for calculating the snap point
const tokenData = buildSnapPointTokenData(token);