Skip to content

Commit

Permalink
Merge pull request #5135 from RPTools/bugfix/4980-large-grid-vision
Browse files Browse the repository at this point in the history
Restore circular "unlimited" vision for grid sights
  • Loading branch information
cwisniew authored Jan 14, 2025
2 parents be26a55 + 9f12d4e commit be8ee85
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 be8ee85

Please sign in to comment.