Skip to content

Commit

Permalink
Merge branch 'feature/terrain-mapper-cutaway-updates' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
caewok committed Sep 17, 2024
2 parents 769bc69 + 061a7cd commit 5febb1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion scripts/geometry
14 changes: 10 additions & 4 deletions scripts/measurement/MovePenalty.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,10 @@ export class MovePenalty {
const bottomElevationFn = _pt => bottomZ;
const topElevationFn = _pt => MAX_ELEV;
const centeredShape = CONFIG.GeometryLib.utils.centeredPolygonFromDrawing(drawing);
return centeredShape.cutawayIntersections(start, end, { bottomElevationFn, topElevationFn });

// Multiple cutaways are possible for polygons.
const cutaways = centeredShape.cutaway(start, end, { bottomElevationFn, topElevationFn });
return cutaways.flatMap(cutaway => cutaway.intersectSegment3d(start, end));
}

/**
Expand All @@ -564,9 +567,12 @@ export class MovePenalty {
* @returns {PIXI.Polygon[]} Null if no intersection
*/
static tokenCutawayIntersections(start, end, token) {
const bottomElevationFn = _pt => token.bottomZ;
const topElevationFn = _pt => token.topZ;
return token.constrainedTokenBorder.cutawayIntersections(start, end, { bottomElevationFn, topElevationFn });
const bottomElevationFn = () => token.bottomZ;
const topElevationFn = () => token.topZ;

// Multiple cutaways are possible if the token is constrained (e.g., inset edge).
const cutaways = token.constrainedTokenBorder.cutaway(start, end, { bottomElevationFn, topElevationFn });
return cutaways.flatMap(cutaway => cutaway.intersectSegment3d(start, end));
}
}

Expand Down

0 comments on commit 5febb1f

Please sign in to comment.