From 9f12d4e698a4b8d25429db384e5110d674b34fae Mon Sep 17 00:00:00 2001 From: Kenneth VanderLinde Date: Mon, 13 Jan 2025 11:11:44 -0800 Subject: [PATCH] Restore circular "unlimited" vision for grid sights Grid shapes are not nearly performant enough yet to support this case. The special `range == 0` case is now documented, and the `GridlessGrid.getGridArea()` override relies on it now instead of duplicating the case. --- src/main/java/net/rptools/maptool/model/Grid.java | 9 ++++----- .../java/net/rptools/maptool/model/GridlessGrid.java | 4 +--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/rptools/maptool/model/Grid.java b/src/main/java/net/rptools/maptool/model/Grid.java index 73ef155227..e54e7c4dda 100644 --- a/src/main/java/net/rptools/maptool/model/Grid.java +++ b/src/main/java/net/rptools/maptool/model/Grid.java @@ -537,10 +537,8 @@ protected int getTokenFacingAngleRelativeToGridAxis(Token token) { double arcAngle, int offsetAngle, boolean scaleWithToken) { - if (range == 0) { - range = zone.getTokenVisionDistance(); - } - double visionRange = range * getSize() / zone.getUnitsPerCell(); + double visionRange = + ((range == 0) ? zone.getTokenVisionDistance() : range) * getSize() / zone.getUnitsPerCell(); Rectangle footprint = token.getFootprint(this).getBounds(this); @@ -852,7 +850,8 @@ private void oneThird(Rectangle regionToDivide, int column, int row, Rectangle d * Returns an Area with a given radius that is shaped and aligned to the current grid * * @param token token which to center the grid area on - * @param range range in units grid area extends out to + * @param range range in units grid area extends out to. if set to {@code 0}, the result will be a + * circular area extending out to {@code visionRange}. * @param scaleWithToken whether grid area should expand by the size of the token * @param visionRange token's vision in pixels * @return the {@link Area} conforming to the current grid layout diff --git a/src/main/java/net/rptools/maptool/model/GridlessGrid.java b/src/main/java/net/rptools/maptool/model/GridlessGrid.java index 7df41a0c98..9bdb353d35 100644 --- a/src/main/java/net/rptools/maptool/model/GridlessGrid.java +++ b/src/main/java/net/rptools/maptool/model/GridlessGrid.java @@ -29,7 +29,6 @@ import net.rptools.maptool.client.walker.WalkerMetric; import net.rptools.maptool.server.proto.GridDto; import net.rptools.maptool.server.proto.GridlessGridDto; -import net.rptools.maptool.util.GraphicsUtil; public class GridlessGrid extends Grid { private static List footprintList; @@ -198,8 +197,7 @@ public Point2D.Double getCenterOffset() { protected Area getGridArea( Token token, double range, boolean scaleWithToken, double visionRange) { // A grid area isn't well-defined when there is no grid, so fall back to a circle. - return GraphicsUtil.createLineSegmentEllipse( - -visionRange, -visionRange, visionRange, visionRange, CIRCLE_SEGMENTS); + return super.getGridArea(token, 0, scaleWithToken, visionRange); } @Override