Skip to content

Commit

Permalink
Merge pull request #903 from dimforge/glam-conversion-bug
Browse files Browse the repository at this point in the history
Fix bug in the glam conversion Vec2 -> Isometry2
  • Loading branch information
sebcrozet committed Jun 4, 2021
2 parents dfc8ad3 + 7acd4ec commit 51312d1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/third_party/glam/common/glam_isometry.rs
@@ -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 {
Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 51312d1

Please sign in to comment.