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

Global to Local methods for transforms #5500

Closed
ottworks opened this issue Jul 30, 2022 · 1 comment
Closed

Global to Local methods for transforms #5500

ottworks opened this issue Jul 30, 2022 · 1 comment
Labels
A-Transform Translations, rotations and scales C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@ottworks
Copy link

What problem does this solve or what need does it fill?

I want to take a global position, and convert it to a position local to my input Transform.

What solution would you like?

Each Transform keeps track of the total transformation of all its parent transforms. Alternatively, GlobalTransform keeps track of this.

What alternative(s) have you considered?

Kerbiter on Discord:
if you only need to change the position, then you basically just do vector algebra and add all the local transforms for every entity in the hierarchy to get a global transform, so just subtract all local transforms except one you need from the global one

This seems like it could end up being a lot of operations for something that could be cached.

@ottworks ottworks added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jul 30, 2022
@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Transform Translations, rotations and scales and removed C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jul 30, 2022
@mockersf
Copy link
Member

mockersf commented Jul 30, 2022

I'm not sure I understand the issue, it seems it's already what GlobalTransform is doing.

For each element, its GlobalTransform is its parent GlobalTransform multiplied by its own local Transform (through mul_transform).

You don't need to traverse hierarchy at all.

@bors bors bot closed this as completed in 9423cb6 Oct 10, 2022
james7132 pushed a commit to james7132/bevy that referenced this issue Oct 19, 2022
…evyengine#6132)

The docs ended up quite verbose :v

Also added a missing `#[inline]` to `GlobalTransform::mul_transform`.

I'd say this resolves bevyengine#5500

# Migration Guide
`Transform::mul_vec3` has been renamed to `transform_point`.

Co-authored-by: devil-ira <justthecooldude@gmail.com>
james7132 pushed a commit to james7132/bevy that referenced this issue Oct 28, 2022
…evyengine#6132)

The docs ended up quite verbose :v

Also added a missing `#[inline]` to `GlobalTransform::mul_transform`.

I'd say this resolves bevyengine#5500

# Migration Guide
`Transform::mul_vec3` has been renamed to `transform_point`.

Co-authored-by: devil-ira <justthecooldude@gmail.com>
Pietrek14 pushed a commit to Pietrek14/bevy that referenced this issue Dec 17, 2022
…evyengine#6132)

The docs ended up quite verbose :v

Also added a missing `#[inline]` to `GlobalTransform::mul_transform`.

I'd say this resolves bevyengine#5500

# Migration Guide
`Transform::mul_vec3` has been renamed to `transform_point`.

Co-authored-by: devil-ira <justthecooldude@gmail.com>
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
…evyengine#6132)

The docs ended up quite verbose :v

Also added a missing `#[inline]` to `GlobalTransform::mul_transform`.

I'd say this resolves bevyengine#5500

# Migration Guide
`Transform::mul_vec3` has been renamed to `transform_point`.

Co-authored-by: devil-ira <justthecooldude@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Transform Translations, rotations and scales C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants