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

Add a Facing enum to make facing of topology blocking segments easier to reason about #4484

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Nov 23, 2023

Identify the Bug or Feature request

Fixes #4469

Also catches a backwards case in Cover VBL, which resulted in surrounding Cover VBL to have no effect.

Description of the Change

We used to use a boolean to indicate whether segments on the front side of a container should be returned. This was
ambiguous for several reasons:

  1. "front side" actually means more than the nearest side.
  2. The interpretation of "front side" inverts when the origin is inside the container. In that case it actually means "back side", it just happens to work out that it's the correct thing in all our cases.
  3. It was based on a boolean faceAway in AreaMeta which was unclear for other reasons. For one, we aren't talking about whether the line segment itself points toward or away from the origin, but rather whether an imaginary orientation normal vector would point toward or away from the origin. And more importantly, the programmer had to remember the arbitrary choice of which direction (clockwise, counterclockwise) would give the expected orientation.

Now we have a Facing enum that can be used by all components involved, and which has decsriptive names. Since each line segment will have an island on one side and an ocean on the other, the names reflect that the origin might be on the island side of the line, or the ocean side of the line, without any need to remember orientation conventions.

It's a lot easier now to see how each type of VBL works:

  • Wall VBL and Cover VBL consistently want the origin on the ocean side of the segment.
  • Hill VBL and Pit VBL consistently want the origin on the island side of the segment.

As for the Hill VBL bug fix, the new phrasing made it clear that that we should not be skipping the parent ocean when finding blocking segments for the grandparent island. As this was the only case where we did that, the logic for skipping oceans like that has been removed.

Possible Drawbacks

Should be none.

Documentation Notes

N/A

Release Notes

  • Fixed a bug where Hill VBL peninsulas would not block vision.
  • Fixed a bug where surrounding Cover VBL would not block vision.

This change is Reviewable

Instead of an ambiguous boolean to indicate "front side", or elsewhere "facing away", we now indicate facing using the
`Facing` enum. This enum is based on the fact that each line segment will have an island on one side and an ocean on the
other side, thus allowing names that indicate the position of the origin point as being either on the island side or the
ocean side.
- Fix RPTools#4437 more directly by not excluding the current island while iterating over siblings.
- Fix facing of current ocean, while removing redundant null check against the parent.
- Fix RPTools#4469 by not excluding the parent ocean from blocking
- Remove `excludeChildOcean` parameter as no one uses it anymore
@kwvanderlinde kwvanderlinde force-pushed the bugfix/4469-hill-vbl-grandparent-peninsula branch from 19e7baa to ee9df5c Compare November 23, 2023 16:30
@cwisniew cwisniew added this pull request to the merge queue Nov 23, 2023
Merged via the queue into RPTools:develop with commit c7d901a Nov 23, 2023
4 checks passed
@kwvanderlinde kwvanderlinde deleted the bugfix/4469-hill-vbl-grandparent-peninsula branch November 24, 2023 01:18
@cwisniew cwisniew added the code-maintenance Adding/editing javadocs, unit tests, formatting. label Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-maintenance Adding/editing javadocs, unit tests, formatting.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Hill VBL "peninsulas" do not always block vision.
2 participants