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 assigning site IDs to new lanes in lifts #226

Merged
merged 2 commits into from
Jun 19, 2024
Merged

Conversation

luca-della-vedova
Copy link
Member

Bug fix

Fixed bug

Fixes #224

Fix applied

The function to assign site IDs to new entities was not being called for anchors that were children of lifts, hence the subsequent query to save the site would not find the anchor (its ID would be missing).
The fix is to make sure we assign a site ID to anchors that are children of the lift cabin.

To test:

  • Create a new site.
  • Create a lift.
  • Add a lane that goes into the lift.
  • Save the site.

Without this PR you should get this error:

ERROR librmf_site_editor::site::save: Unable to compile site: an object has a reference to an anchor that does not exist

With this PR it should save successfully.

if let Ok(anchor_group) = cabin_anchor_groups.get(*site_child) {
if let Ok(anchor_children) = children.get(**anchor_group) {
for anchor_child in anchor_children {
if let Ok(e) = level_children.get(*anchor_child) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the best naming, I reused the level_children query that already queries for anchors, but I can create a duplicated anchors query if we want the cleanliness

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

level_children queries for a lot more things than just anchors, so I definitely think we should not be using it for this. As an example of why.. It's plausible that at some point we'd implement animated lift doors by recycling the DoorType component inside a child of the lift. However we don't necessarily want that child entity to have its own SiteID since it's really part of the same "site element" as the lift. If we assign SiteIDs to all these different child types without considering whether it's really an element that gets saved, then we'll be contaminating the SiteIDs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the previously existing implementation, I'm realizing that we were already assigning SiteIDs to level_children entities within lifts. Now I'm conflicted and wondering if there was a reason we were doing this previously, e.g. to allow walls and models to be placed inside of lifts.

Copy link
Collaborator

@mxgrey mxgrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for figuring out the problem and getting it fixed so quickly. I'm just going to tweak one detail of the implementation and then approve.

if let Ok(anchor_group) = cabin_anchor_groups.get(*site_child) {
if let Ok(anchor_children) = children.get(**anchor_group) {
for anchor_child in anchor_children {
if let Ok(e) = level_children.get(*anchor_child) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

level_children queries for a lot more things than just anchors, so I definitely think we should not be using it for this. As an example of why.. It's plausible that at some point we'd implement animated lift doors by recycling the DoorType component inside a child of the lift. However we don't necessarily want that child entity to have its own SiteID since it's really part of the same "site element" as the lift. If we assign SiteIDs to all these different child types without considering whether it's really an element that gets saved, then we'll be contaminating the SiteIDs.

@mxgrey mxgrey merged commit 74d861b into main Jun 19, 2024
5 checks passed
@mxgrey mxgrey deleted the luca/fix_new_lift_save branch June 19, 2024 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Not able to add the waypoint inside the lift and door of lift
2 participants