-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propagate origin displacements of child structures to parent (#2150)
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) |
- Loading branch information
Showing
13 changed files
with
443 additions
and
69 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
data/scenarios/Testing/1780-structure-merge-expansion/00-ORDER.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
nonoverlapping-structure-merge.yaml | ||
root-map-expansion.yaml | ||
structure-composition.yaml | ||
sequential-placement.yaml | ||
sequential-placement.yaml | ||
coordinate-offset-propagation.yaml | ||
simultaneous-north-and-west-offset.yaml |
77 changes: 77 additions & 0 deletions
77
data/scenarios/Testing/1780-structure-merge-expansion/coordinate-offset-propagation.yaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
version: 1 | ||
name: Structure coordinate offset propagation | ||
author: Karl Ostmo | ||
description: | | ||
If a structure incorporates subplacements | ||
entailing negative offsets, its coordinate origin must be shifted. | ||
The updated coordinate origin should be propagated to parent structures | ||
and utilized to offset placement. | ||
robots: | ||
- name: base | ||
dir: north | ||
loc: [0, 3] | ||
objectives: | ||
- goal: | ||
- Enjoy the view. | ||
condition: | | ||
return true | ||
solution: | | ||
noop | ||
known: [boulder, log, pixel (R), pixel (G), pixel (B), gold] | ||
world: | ||
structures: | ||
- name: micro | ||
structure: | ||
mask: '.' | ||
palette: | ||
'x': [stone, gold] | ||
map: | | ||
xx | ||
- name: block | ||
structure: | ||
mask: '.' | ||
palette: | ||
'x': [stone, pixel (R)] | ||
map: | | ||
xx | ||
xx | ||
- name: master | ||
structure: | ||
mask: '.' | ||
palette: | ||
'x': [stone, pixel (B)] | ||
placements: | ||
- src: block | ||
offset: [0, 1] | ||
- src: micro | ||
offset: [-2, 0] | ||
map: | | ||
..x | ||
..x | ||
..x | ||
- name: final | ||
structure: | ||
mask: '.' | ||
palette: | ||
'x': [stone, pixel (G)] | ||
placements: | ||
- src: master | ||
map: | | ||
x | ||
x | ||
x | ||
x | ||
dsl: | | ||
overlay | ||
[ {grass} | ||
, mask (y > -4 && y < 4 || x > -4 && x < 4) {stone} | ||
, mask (y > -2 && y < 2 || x > -2 && x < 2) {ice} | ||
, mask (y > -1 && y < 1 || x > -1 && x < 1) {dirt} | ||
] | ||
mask: '.' | ||
placements: | ||
- src: final | ||
offset: [0, 0] | ||
upperleft: [0, 0] | ||
map: "" |
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
56 changes: 56 additions & 0 deletions
56
.../scenarios/Testing/1780-structure-merge-expansion/simultaneous-north-and-west-offset.yaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
version: 1 | ||
name: Northwest sibling structure coordinate offsets | ||
author: Karl Ostmo | ||
description: | | ||
Make sure that the second sibling is displayed correctly when there | ||
is a simultaneous negative-x and positive-y offset on the first sibling. | ||
robots: | ||
- name: base | ||
dir: north | ||
loc: [0, 2] | ||
objectives: | ||
- goal: | ||
- Enjoy the view. | ||
condition: | | ||
return true | ||
solution: | | ||
noop | ||
known: [pixel (R), gold] | ||
world: | ||
structures: | ||
- name: micro | ||
structure: | ||
mask: '.' | ||
palette: | ||
'x': [stone, gold] | ||
map: | | ||
x | ||
- name: block | ||
structure: | ||
mask: '.' | ||
palette: | ||
'x': [stone, pixel (R)] | ||
map: | | ||
xx | ||
xx | ||
- name: master | ||
structure: | ||
mask: '.' | ||
placements: | ||
- src: micro | ||
offset: [-1, 1] | ||
- src: block | ||
map: "" | ||
dsl: | | ||
overlay | ||
[ {grass} | ||
, mask (y > -4 && y < 4 || x > -4 && x < 4) {stone} | ||
, mask (y > -2 && y < 2 || x > -2 && x < 2) {ice} | ||
, mask (y > -1 && y < 1 || x > -1 && x < 1) {dirt} | ||
] | ||
mask: '.' | ||
placements: | ||
- src: master | ||
offset: [0, 0] | ||
upperleft: [0, 0] | ||
map: "" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,5 +55,5 @@ placements: | |
orient: | ||
up: west | ||
- src: disc | ||
offset: [8, -8] | ||
offset: [5, -8] | ||
map: "" |
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
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
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
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
Oops, something went wrong.