Merge pull request #903 from dimforge/glam-conversion-bug

Fix bug in the glam conversion Vec2 -> Isometry2
This commit is contained in:
Sébastien Crozet 2021-06-04 11:06:50 +02:00 committed by GitHub
commit 51312d1d54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
use super::glam::{DMat3, DMat4, DQuat, DVec2, DVec3, Mat3, Mat4, Quat, Vec2, Vec3};
use crate::{Isometry2, Isometry3, Matrix3, Matrix4};
use crate::{Isometry2, Isometry3, Matrix3, Matrix4, Translation3, UnitQuaternion, Vector2};
use std::convert::TryFrom;
impl From<Isometry2<f32>> for Mat3 {
@ -102,61 +102,61 @@ impl From<(DVec2, f64)> for Isometry2<f64> {
impl From<Quat> for Isometry3<f32> {
fn from(rot: Quat) -> Self {
Isometry3::from_parts(crate::one(), rot.into())
Isometry3::from_parts(Translation3::identity(), rot.into())
}
}
impl From<DQuat> for Isometry3<f64> {
fn from(rot: DQuat) -> Self {
Isometry3::from_parts(crate::one(), rot.into())
Isometry3::from_parts(Translation3::identity(), rot.into())
}
}
impl From<Quat> for Isometry2<f32> {
fn from(rot: Quat) -> Self {
Isometry2::new(crate::zero(), rot.to_axis_angle().1)
Isometry2::new(Vector2::zeros(), rot.to_axis_angle().1)
}
}
impl From<DQuat> for Isometry2<f64> {
fn from(rot: DQuat) -> Self {
Isometry2::new(crate::zero(), rot.to_axis_angle().1)
Isometry2::new(Vector2::zeros(), rot.to_axis_angle().1)
}
}
impl From<Vec3> for Isometry3<f32> {
fn from(tra: Vec3) -> Self {
Isometry3::from_parts(tra.into(), crate::one())
Isometry3::from_parts(tra.into(), UnitQuaternion::identity())
}
}
impl From<DVec3> for Isometry3<f64> {
fn from(tra: DVec3) -> Self {
Isometry3::from_parts(tra.into(), crate::one())
Isometry3::from_parts(tra.into(), UnitQuaternion::identity())
}
}
impl From<Vec2> for Isometry2<f32> {
fn from(tra: Vec2) -> Self {
Isometry2::new(tra.into(), crate::one())
Isometry2::new(tra.into(), 0.0)
}
}
impl From<DVec2> for Isometry2<f64> {
fn from(tra: DVec2) -> Self {
Isometry2::new(tra.into(), crate::one())
Isometry2::new(tra.into(), 0.0)
}
}
impl From<Vec3> for Isometry2<f32> {
fn from(tra: Vec3) -> Self {
Isometry2::new([tra.x, tra.y].into(), crate::one())
Isometry2::new([tra.x, tra.y].into(), 0.0)
}
}
impl From<DVec3> for Isometry2<f64> {
fn from(tra: DVec3) -> Self {
Isometry2::new([tra.x, tra.y].into(), crate::one())
Isometry2::new([tra.x, tra.y].into(), 0.0)
}
}