Skip to content

Commit 62b78ea

Browse files
committed
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.
1 parent be26a55 commit 62b78ea

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/main/java/net/rptools/maptool/model/Grid.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,7 @@ protected int getTokenFacingAngleRelativeToGridAxis(Token token) {
537537
double arcAngle,
538538
int offsetAngle,
539539
boolean scaleWithToken) {
540-
if (range == 0) {
541-
range = zone.getTokenVisionDistance();
542-
}
543-
double visionRange = range * getSize() / zone.getUnitsPerCell();
540+
double visionRange = ((range == 0) ? zone.getTokenVisionDistance() : range) * getSize() / zone.getUnitsPerCell();
544541

545542
Rectangle footprint = token.getFootprint(this).getBounds(this);
546543

@@ -852,7 +849,8 @@ private void oneThird(Rectangle regionToDivide, int column, int row, Rectangle d
852849
* Returns an Area with a given radius that is shaped and aligned to the current grid
853850
*
854851
* @param token token which to center the grid area on
855-
* @param range range in units grid area extends out to
852+
* @param range range in units grid area extends out to. if set to {@code 0}, the result will be a
853+
* circular area extending out to {@code visionRange}.
856854
* @param scaleWithToken whether grid area should expand by the size of the token
857855
* @param visionRange token's vision in pixels
858856
* @return the {@link Area} conforming to the current grid layout

src/main/java/net/rptools/maptool/model/GridlessGrid.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import net.rptools.maptool.client.walker.WalkerMetric;
3030
import net.rptools.maptool.server.proto.GridDto;
3131
import net.rptools.maptool.server.proto.GridlessGridDto;
32-
import net.rptools.maptool.util.GraphicsUtil;
3332

3433
public class GridlessGrid extends Grid {
3534
private static List<TokenFootprint> footprintList;
@@ -198,8 +197,7 @@ public Point2D.Double getCenterOffset() {
198197
protected Area getGridArea(
199198
Token token, double range, boolean scaleWithToken, double visionRange) {
200199
// A grid area isn't well-defined when there is no grid, so fall back to a circle.
201-
return GraphicsUtil.createLineSegmentEllipse(
202-
-visionRange, -visionRange, visionRange, visionRange, CIRCLE_SEGMENTS);
200+
return super.getGridArea(token, 0, scaleWithToken, visionRange);
203201
}
204202

205203
@Override

0 commit comments

Comments
 (0)