Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with vision bounds not including the vision origin #4645

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public class EndpointSet {

private final int[] bucketSizes;

public EndpointSet(Coordinate origin, Envelope bounds) {
public EndpointSet(Coordinate origin) {
this.origin = origin;
this.envelope = new Envelope(bounds);
this.envelope = new Envelope();

this.buckets = new VisibilitySweepEndpoint[BUCKET_COUNT][];
Arrays.setAll(this.buckets, i -> new VisibilitySweepEndpoint[32]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ public class VisibilityProblem {
*/
private final EndpointSet endpointSet;

/**
* Bounds on the vision and origin.
*
* <p>This will be used to guarantee that we have endpoints in every direction around the origin,
* and that we avoid infinite results.
*/
private final Envelope bounds;

/**
* The set of walls that are intersected by the current event line.
*
Expand All @@ -66,7 +74,9 @@ public class VisibilityProblem {
*/
public VisibilityProblem(Coordinate origin, Envelope visionBounds) {
this.origin = origin;
this.endpointSet = new EndpointSet(origin, visionBounds);
this.endpointSet = new EndpointSet(origin);
this.bounds = new Envelope(visionBounds);
this.bounds.expandToInclude(origin);
this.openWalls = new TreeSet<>(this::compareOpenWalls);
}

Expand Down Expand Up @@ -145,6 +155,7 @@ public void add(List<Coordinate> string) {

timer.start("add bounds");
final var envelope = endpointSet.getBounds();
envelope.expandToInclude(this.bounds);
// Exact expansion distance doesn't matter, we just don't want the boundary walls to overlap
// endpoints from real walls.
envelope.expandBy(1.0);
Expand Down
Loading