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
Circle rotation results in invisible entity #5
Comments
I think this is because What I think would work in your case is a custom lens where you interpolate the angle first, then build the rotation from it second. Something like (untested): struct RotationLens {
start_angle: f32,
end_angle: f32,
}
impl Lens<Transform> for RotationLens {
fn lerp(&mut self, target: &mut Transform, ratio: f32) {
let angle = self.start_angle.lerp(self.end_angle, ratio);
target.rotation = Quat::from_rotation_z(angle);
} then use as: RotationLens {
start_angle: 0.,
end_angle: std::f32::consts::TAU,
} |
I tried using
Yes, this works for me. |
Add more predefined rotation lenses interpolating the angle of rotation instead of the `Quat` itself directly. Document at the `lens` module level the difference between the shortest-path lens and the angle-focused ones. Bug: #5
Add more predefined rotation lenses interpolating the angle of rotation instead of the `Quat` itself directly. Document at the `lens` module level the difference between the shortest-path lens and the angle-focused ones. Bug: #5
@Shatur I've just merged some changes that add some new angle-based rotation lenses, and document in the |
Thanks! But isn't it strange that Could you also draft a new release? |
Right, let's leave that issue open until we root caused that one. I didn't have time to look at it yet. I missed to update the README too with the new lenses, I'll make a release after that. |
Actually just a note for self, I've been reminded looking at tests that |
Root-caused as expected to conjugate quaternions producing a divide-by-zero, which with the SSE2 implementation (default on Windows for example) yields all NaNs, so an invalid rotation that when applied to a vector probably moves the sprites to infinity and makes them invisible. Filled a bug with glam : bitshifter/glam-rs#276 I propose we close this bug because there's not much else I can do here I think. We just need to wait for a fix to be written and trickle down to Bevy itself. |
Maybe glam-rs will fix |
The new lenses are still needed, because The glam bug is only to fix the sprite disappearing. But even fixed, you would see no rotation at all, which I don't think is very useful 😊 |
Oh, understand, thank you for looking into it! |
Here is the code:
It works correctly, sprite rotates. But if you replace
std::f32::consts::PI
withstd::f32::consts::TAU
the sprite becomes invisible.The text was updated successfully, but these errors were encountered: