bevyengine / bevyengine/bevy-website

0.15 Migration Guide: Provide examples for creating `Rect` with logical values (missing `logical_rect` method on `Node` - also see PR 15163 and PR 16375)

Open
#1,920 0 comments 0 reactions 0 assignees View on GitHub
A-Migration Guides C-Content S-Ready-For-Implementation
Dominant language
JavaScript
Stars
249
Forks
450
Avg merge
16h 20m
Merged PRs (30d)
6

Description

## Problem

From 0.14 -> 015 there are two changes that have led to my (toy) project being broken and I couldn't figure out for a while why it broke (⚠ I'm very new to GameDev and Bevy).

- the first change, introduced in [PR 16375](https://github.com/bevyengine/bevy/pull/16375), states that `ComputedNode`’s fields and methods now use __physical coordinates__, instead of logical coordinates and by multiplying the physical coordinates by the `inverse_scale_factor` will give the logical values.
- the second change introduced in [PR 15163](https://github.com/bevyengine/bevy/pull/15163), states that methods `logical_rect` and `physical_rect` have been removed from `Node`

IMHO, we should __provide examples__ on how to reimplement `logical_rect` for oneself, if one decides that it is a useful method to have (I've done this now after migrating from 0.12. -> 0.15 by implementing an extension trait on `Node`).

Also both changes mentioned above should reference each other, because one change alone would probably have a small breaking impact, but in combination they have high potential for "invisibly" breaking apps (aka no compile errors, but wrong logic).

## Proposed solution

An example that we should provide in [migration guide for PR 15163](https://github.com/bevyengine/bevy-website/blob/5115c66f937a306996de3b4fb9c53c03e7219e76/release-content/0.15/migration-guides/15163_use_precomputed_border_values.md?plain=1), while referencing the [other changes regarding `ComputedNode`](https://github.com/bevyengine/bevy-website/blob/5115c66f937a306996de3b4fb9c53c03e7219e76/release-content/0.15/migration-guides/16375_Only_use_physical_coords_internally_in_bevy_ui.md?plain=1#L2):

0.14:
```rust
fn my_system(q_nodes: Query<&Node, &GlobalTransform>) {
for (node, g_trans) in &q_nodes {
let logical_rect = node.logical_rect(g_trans);
}
}
```
0.15:
```rust
fn my_system(q_nodes: Query<&Node, &ComputedNode, &GlobalTransform>) {
for (node, comp_node, g_trans) in &q_nodes {
let logical_rect = Rect::from_center_size(
// we convert both values to their logical values
g_trans.translation.xy() * comp_node.inverse_scale_factor(),
comp_node.size() * comp_node.inverse_scale_factor());
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start with release-content/0.15/migration-guides/15163_use_precomputed_border_values.md and review the linked 16375_Only_use_physical_coords_internally_in_bevy_ui.md guide. Add the requested 0.14 and 0.15 Rect examples and cross-reference the two migration changes. Done means the guide explains how to recreate logical values after the Node methods were removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.