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

NaN when looking_at is called with Transform's origin as target #3736

Closed
elfeiin opened this issue Jan 21, 2022 · 3 comments · Fixed by #7817
Closed

NaN when looking_at is called with Transform's origin as target #3736

elfeiin opened this issue Jan 21, 2022 · 3 comments · Fixed by #7817
Labels
A-Math Fundamental domain-agnostic mathematical operations C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@elfeiin
Copy link

elfeiin commented Jan 21, 2022

Bevy version

0.5 and 0.6

Operating system & version

Linux Mint 20.2

What you did

I modified the 3D Scene example so line 42 read as,
transform: Transform::from_xyz(0.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),

As you can see, the origin of the transform is the same as where it's set to look.

What you expected to happen

Default to either current Quat or the unit matrix.

What actually happened

Printing the debug value of that particular transform produced,
Mut(Transform { translation: Vec3(NaN, NaN, NaN), rotation: Quat(NaN, NaN, NaN, NaN), scale: Vec3(1.0, 1.0, 1.0) })

and attempting to further modify it resulted in no change (as expected, given what's happening).

Additional information

@elfeiin elfeiin added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jan 21, 2022
@alice-i-cecile alice-i-cecile added A-Math Fundamental domain-agnostic mathematical operations C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jan 21, 2022
@HackerFoo
Copy link
Contributor

Why should this be defined?

Using the current or identity rotation is not correct if the up vectors don't match, such as:

Transform::identity().looking_at(Vec3::ZERO, Vec::Z)

@elfeiin
Copy link
Author

elfeiin commented Jan 21, 2022

You're right, there are an unlimited number of rotations that satisfy those constraints. Perhaps a bit of documentation for those who aren't aware of the effect and what the proper method for doing what they want is (they might just want a default Transform)?

@rparrett
Copy link
Contributor

rparrett commented Jan 21, 2022

While we're here, is this also expected?

[examples/3d/lighting.rs:32] Transform::from_xyz(0.0, 5.5, 0.0).looking_at(Vec3::ZERO, Vec3::Y) = Transform {
    translation: Vec3(
        0.0,
        5.5,
        0.0,
    ),
    rotation: Quat(
        NaN,
        NaN,
        NaN,
        NaN,
    ),
    scale: Vec3(
        1.0,
        1.0,
        1.0,
    ),
}

edit: yes, of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Math Fundamental domain-agnostic mathematical operations C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants