-
Notifications
You must be signed in to change notification settings - Fork 52
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 growable structure grids for multiple children with negative coordinates #2127
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kostmo
force-pushed
the
testing/structure-expansion
branch
from
August 24, 2024 04:43
7bf111e
to
477b93d
Compare
kostmo
force-pushed
the
testing/structure-expansion
branch
from
August 25, 2024 00:21
477b93d
to
8df7dea
Compare
kostmo
added
the
T-Testing
Involves the testing suite - unit and integration tests, also benchmarks.
label
Sep 14, 2024
kostmo
force-pushed
the
testing/structure-expansion
branch
from
September 15, 2024 18:04
8df7dea
to
6e7278d
Compare
kostmo
force-pushed
the
testing/structure-expansion
branch
from
September 16, 2024 06:00
2cfc312
to
6c93e28
Compare
kostmo
changed the title
[WIP] another test case for structure placement
another test case for structure placement
Sep 16, 2024
kostmo
force-pushed
the
testing/structure-expansion
branch
from
September 16, 2024 06:12
6c93e28
to
f5b70f3
Compare
kostmo
changed the title
another test case for structure placement
Fix growable structure grids for multiple children with negative coordinates
Sep 16, 2024
kostmo
force-pushed
the
testing/structure-expansion
branch
from
September 16, 2024 06:29
f5b70f3
to
0443bc2
Compare
kostmo
force-pushed
the
testing/structure-expansion
branch
from
September 16, 2024 16:32
0443bc2
to
5455c99
Compare
byorgey
reviewed
Sep 16, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what exactly was the bug, and what was the fix? Can you add a summary to the PR description, so a high-level summary of the bug and the fix end up in the commit history once we merge?
byorgey
approved these changes
Sep 16, 2024
mergify bot
pushed a commit
that referenced
this pull request
Sep 23, 2024
Builds upon #2127 to fix the remaining issues with #1826. If a structure incorporates sub-placements entailing northwesterly offsets, its "coordinate origin" will be shifted relative to the top-left cell in the grid. This updated coordinate origin should be propagated to parent structures for use when placing it. This includes placement of the main "area" onto the toplevel world map. This is essential when composing a large scene that needs to line up with features generated by the DSL. Another bug fixed in this PR involved incorrect "area" computation within sibling placements when both a "northward" and "westward" offset were used; existing tests only covered each of these directions separately. ## Changes in this PR * Refactoring for readability * Improved naming * Fixed typo `padSouthwest` -> `padNorthwest` * Export some functions for unit tests * Utilize propagated coordinate offset in `WorldDescription` ## Testing ### Unit tests ``` scripts/test/run-tests.sh swarm-unit --test-options '--pattern "Overlay"' ``` ### Scenarios ``` scripts/play.sh -i data/scenarios/Testing/1780-structure-merge-expansion/coordinate-offset-propagation.yaml --hide-goal ``` | Before | After | | --- | --- | | ![Screenshot from 2024-09-22 19-54-13](https://github.com/user-attachments/assets/b7d79232-7435-4cdf-a586-4df4df5cd978) | ![Screenshot from 2024-09-22 19-50-10](https://github.com/user-attachments/assets/4c6a248c-153c-4461-9012-526f59d1ce35) | ``` scripts/play.sh -i data/scenarios/Testing/1780-structure-merge-expansion/simultaneous-north-and-west-offset.yaml --hide-goal ``` | Before | After | | --- | --- | | ![Screenshot from 2024-09-22 19-53-50](https://github.com/user-attachments/assets/2049c905-c283-4c43-adc2-f355ea055ada) | ![Screenshot from 2024-09-22 19-53-07](https://github.com/user-attachments/assets/d120d084-31c6-4a67-855d-e08043a93891) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a bug from #1826.
Background
Structure definitions can be nested, in that a structure can reference and place multiple "substructures", each with an "offset", to compose something more complicated. Each placement onto a particular "base" structure is a "child". Multiple child placements atop the same base structure are "siblings".
It so happened that if a child placement with a "negative" horizontal offset preceded a sibling with non-negative offset, this would result in miscalculated placements. This had to do with the fact that "growing" the "base grid" in the negative direction means that the original "origin" (that the "offset" of subsequent placements are made with respect to) of the base grid must be shifted further right (to somewhere in the middle of the grid), rather than lying on the left edge.
Conversely, if negative offsets occurred as later siblings, then the placement would be correct (the bug would not be triggered).
The fix
This fix ensures that sibling placements can be re-ordered without affecting the end result. There were actually two bugs:
foldlM
)originDelta
in theSemigroup
instance ofPositionedGrid
) was incorrect.Other changes
Also implements a
--refresh
option to thestandalone-topography
test for updating image-based test fixtures.Bug repro
Refreshing test images