Skip to content

Commit

Permalink
Add default behaviour for zero-width beams
Browse files Browse the repository at this point in the history
When getting its shaped area, the width will be forced to be at least one pixel wide.
  • Loading branch information
kwvanderlinde committed Dec 16, 2023
1 parent 89498c2 commit 374af69
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/net/rptools/maptool/model/Grid.java
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ public Area getShapedArea(
if (token.getFacing() == null) {
token.setFacing(0);
}
var pixelWidth = width * getSize() / zone.getUnitsPerCell();
// Make at least 1 pixel on each side, so it's at least visible at 100% zoom.
var pixelWidth = Math.max(2, width * getSize() / zone.getUnitsPerCell());
Shape lineShape = new Rectangle2D.Double(0, -pixelWidth / 2, visionRange, pixelWidth);
Shape visibleShape = new GeneralPath(lineShape);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/rptools/maptool/model/IsometricGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public Area getShapedArea(
if (token.getFacing() == null) {
token.setFacing(0);
}
var pixelWidth = width * getSize() / getZone().getUnitsPerCell();
var pixelWidth = Math.max(2, width * getSize() / getZone().getUnitsPerCell());
Shape visibleShape = new Rectangle2D.Double(0, -pixelWidth / 2, visionRange, pixelWidth);

// new angle, corrected for isometric view
Expand Down

0 comments on commit 374af69

Please sign in to comment.