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

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) #1920

Open
janriemer opened this issue Dec 29, 2024 · 0 comments

Comments

@janriemer
Copy link

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, 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, 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, while referencing the other changes regarding ComputedNode:

0.14:

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:

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());
    }
}
@janriemer janriemer changed the title 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)) 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) Dec 29, 2024
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

No branches or pull requests

1 participant