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 #12255 Updating TargetCamera on multi camera scenes not allowing layout to be calculated #12268

Merged
merged 7 commits into from
Mar 4, 2024

Conversation

StrikeForceZero
Copy link
Contributor

@StrikeForceZero StrikeForceZero commented Mar 3, 2024

Objective

Still needs confirming what the consequences are from having camera viewport nodes live on the root of the taffy tree.

Solution

To fix calculating the layouts for UI nodes we need to cleanup the children previously set whenever TargetCamera is updated. This also maintains a list of taffy camera nodes and cleans them up when removed.


Changelog

Fixed #12255

Migration Guide

changes affect private structs/members so shouldn't need actions by engine users.

Check to make sure the layout is getting calculated when TargetCamera is being updated on a node.
Copy link
Contributor

github-actions bot commented Mar 3, 2024

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@TrialDragon TrialDragon added A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior labels Mar 3, 2024
Make sure the children are being cleaned up and maintain taffy references to camera nodes
@StrikeForceZero StrikeForceZero marked this pull request as ready for review March 3, 2024 04:04
@alice-i-cecile alice-i-cecile added this to the 0.13.1 milestone Mar 3, 2024
Copy link
Member

@aevyrie aevyrie left a comment

Choose a reason for hiding this comment

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

I don't have enough experience in this area of code to do much other than a rubber stamp. The only things I noticed were some very tiny nits, non blocking. This adds a regression test, which is great. The only thing I'm uncertain of is if this breaks some untested invariant about taffy nodes somewhere else.

crates/bevy_ui/src/layout/mod.rs Outdated Show resolved Hide resolved
crates/bevy_ui/src/layout/mod.rs Outdated Show resolved Hide resolved
crates/bevy_ui/src/layout/mod.rs Show resolved Hide resolved
crates/bevy_ui/src/layout/mod.rs Outdated Show resolved Hide resolved
crates/bevy_ui/src/layout/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

I'm happy with this fix. Thanks a ton for the regression test! I think we should make the UI camera association explicit rather than the complex somewhat magical approach currently used, but that's another PR.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Mar 4, 2024
@alice-i-cecile alice-i-cecile enabled auto-merge March 4, 2024 19:19
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 4, 2024
Merged via the queue into bevyengine:main with commit b02a2ef Mar 4, 2024
26 checks passed
mockersf pushed a commit that referenced this pull request Mar 5, 2024
…layout to be calculated (#12268)

# Objective

- Fixes #12255

Still needs confirming what the consequences are from having camera
viewport nodes live on the root of the taffy tree.

## Solution

To fix calculating the layouts for UI nodes we need to cleanup the
children previously set whenever `TargetCamera` is updated. This also
maintains a list of taffy camera nodes and cleans them up when removed.

---

## Changelog

Fixed #12255

## Migration Guide

changes affect private structs/members so shouldn't need actions by
engine users.
spectria-limina pushed a commit to spectria-limina/bevy that referenced this pull request Mar 9, 2024
… allowing layout to be calculated (bevyengine#12268)

# Objective

- Fixes bevyengine#12255

Still needs confirming what the consequences are from having camera
viewport nodes live on the root of the taffy tree.

## Solution

To fix calculating the layouts for UI nodes we need to cleanup the
children previously set whenever `TargetCamera` is updated. This also
maintains a list of taffy camera nodes and cleans them up when removed.

---

## Changelog

Fixed bevyengine#12255

## Migration Guide

changes affect private structs/members so shouldn't need actions by
engine users.
mtsr pushed a commit to mtsr/bevy that referenced this pull request Mar 15, 2024
… allowing layout to be calculated (bevyengine#12268)

# Objective

- Fixes bevyengine#12255

Still needs confirming what the consequences are from having camera
viewport nodes live on the root of the taffy tree.

## Solution

To fix calculating the layouts for UI nodes we need to cleanup the
children previously set whenever `TargetCamera` is updated. This also
maintains a list of taffy camera nodes and cleans them up when removed.

---

## Changelog

Fixed bevyengine#12255

## Migration Guide

changes affect private structs/members so shouldn't need actions by
engine users.
github-merge-queue bot pushed a commit that referenced this pull request Mar 25, 2024
# Objective

Fix the regression for Root Node's Layout behavior introduced in
#12268

- Add regression test for Root Node Layout's behaving as they did before
0.13.1
- Restore pre 0.13.1 Root Node Layout behavior (fixes
#12624)

## Solution

This implements [@nicoburns suggestion
](https://discord.com/channels/691052431525675048/743663673393938453/1221593626476548146),
where instead of adding the camera to the taffy node tree, we revert
back to adding a new "parent" node for each root node while maintaining
their relationship with the camera.

> If you can do the ecs change detection to move the node to the correct
Taffy instance for the camera then you should also be able to move it to
a `Vec` of root nodes for that camera.

---

## Changelog

Fixed #12624 - Restores pre
0.13.1 Root Node Layout behavior

## Migration Guide

If you were affected by the 0.13.1 regression and added `position_type:
Absolute` to all your root nodes you might be able to reclaim some LOC
by removing them now that the 0.13 behavior is restored.
@StrikeForceZero StrikeForceZero deleted the fix/12255 branch March 25, 2024 23:06
StrikeForceZero added a commit to StrikeForceZero/bevy that referenced this pull request Mar 30, 2024
StrikeForceZero added a commit to StrikeForceZero/bevy that referenced this pull request Mar 30, 2024
mockersf pushed a commit that referenced this pull request Apr 1, 2024
# Objective

Fix the regression for Root Node's Layout behavior introduced in
#12268

- Add regression test for Root Node Layout's behaving as they did before
0.13.1
- Restore pre 0.13.1 Root Node Layout behavior (fixes
#12624)

## Solution

This implements [@nicoburns suggestion
](https://discord.com/channels/691052431525675048/743663673393938453/1221593626476548146),
where instead of adding the camera to the taffy node tree, we revert
back to adding a new "parent" node for each root node while maintaining
their relationship with the camera.

> If you can do the ecs change detection to move the node to the correct
Taffy instance for the camera then you should also be able to move it to
a `Vec` of root nodes for that camera.

---

## Changelog

Fixed #12624 - Restores pre
0.13.1 Root Node Layout behavior

## Migration Guide

If you were affected by the 0.13.1 regression and added `position_type:
Absolute` to all your root nodes you might be able to reclaim some LOC
by removing them now that the 0.13 behavior is restored.
StrikeForceZero added a commit to StrikeForceZero/bevy that referenced this pull request Apr 3, 2024
StrikeForceZero added a commit to StrikeForceZero/bevy that referenced this pull request Apr 30, 2024
StrikeForceZero added a commit to StrikeForceZero/bevy that referenced this pull request May 19, 2024
Apply rustfmt
Move test_initialization next to other tests
Add doc comment to is_root_node_pair_valid
Move helper methods into the single test case where they are used
Add tests for helper methods
Remove trait helpers to reduce complexity of tests
Mark specific test functions as unreachable
Move ui_surface test only methods into mod tests as trait
Fix tests after rebase
Add tests for bevy_ui/layout/ui_surface
Widen type for parameter children in UiSurface::update_children
Add missing asserts and Debug fields in UiSurface from bevyengine#12268 and bevyengine#12698
StrikeForceZero added a commit to StrikeForceZero/bevy that referenced this pull request Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI element positioning bug updating TargetCamera on cursor transition between Viewports in multi-camera setup
4 participants