Skip to content

Commit

Permalink
Merge branch 'release/0.8.6' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
caewok committed Feb 16, 2024
2 parents 35e1244 + d7c17fd commit ed26398
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.8.6
Fix for pathfinding slipping through small cracks between walls. Unless the wall is a door, the path should be limited to half the token min(width, height).

# 0.8.5

## New Features
Expand Down
8 changes: 5 additions & 3 deletions scripts/pathfinding/BorderTriangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ export class BorderEdge {

/**
* Determine if this is an open door with nothing else blocking.
* @returns {boolean}
* @type {boolean}
*/
isOpenDoor() {
get isOpenDoor() {
if ( !this.objects.size ) return false;
const { moveToken, tokenBlockType } = this.constructor;
return this.objects.every(obj =>
(obj instanceof Wall) ? obj.isOpen
: (obj instanceof Token ) ? !this._tokenEdgeBlocks(obj)
: (obj instanceof Token ) ? !WallTracerEdge.tokenEdgeBlocks(obj, moveToken, tokenBlockType)
: true);
}

Expand Down
16 changes: 15 additions & 1 deletion scripts/pathfinding/pathfinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class Pathfinder {
_spacer = 0;

get spacer() {
return this._spacer || (this.token.w * 0.5) || (canvas.dimensions.size * 0.5);
return this._spacer || (Math.min(this.token.w, this.token.h) * 0.5) || (canvas.dimensions.size * 0.5);
}

/** @enum {BreadthFirstPathSearch} */
Expand Down Expand Up @@ -343,6 +343,20 @@ export class Pathfinder {
return pts.reverse();
}

/**
* Identify triangles for a path in order.
* @returns {BorderTriangle[]}
*/
static getPathTriangles(pathMap) {
let curr = pathMap.goal;
const tri = [];
while ( curr && tri.length < 1000 ) {
tri.push(curr);
curr = pathMap.get(curr.key);
}
return tri.reverse();
}

drawPath(pathPoints, opts) {
const nPts = pathPoints.length;
let prior = pathPoints[0];
Expand Down

0 comments on commit ed26398

Please sign in to comment.