Skip to content

Commit

Permalink
Restore circular "unlimited" vision for grid sights
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kwvanderlinde committed Jan 13, 2025
1 parent be26a55 commit 9f12d4e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/main/java/net/rptools/maptool/model/Grid.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/net/rptools/maptool/model/GridlessGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenFootprint> footprintList;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9f12d4e

Please sign in to comment.