1use super::ToRealPrecision;
2use crate::{math::DRot2, physics_transform::Rotation};
3use bevy_math::*;
4use glam_matrix_extras::*;
5
6pub type Real = f32;
11
12pub type RVec2 = Vec2;
17
18pub type RVec3 = Vec3;
23
24pub type RMat2 = Mat2;
29
30pub type RMat3 = Mat3;
35
36impl ToRealPrecision for f32 {
37 type Adjusted = Real;
38 fn real(&self) -> Self::Adjusted {
39 *self as Real
40 }
41}
42
43impl ToRealPrecision for f64 {
44 type Adjusted = Real;
45 fn real(&self) -> Self::Adjusted {
46 *self as Real
47 }
48}
49
50impl ToRealPrecision for Vec3 {
51 type Adjusted = Vec3;
52 fn real(&self) -> Self::Adjusted {
53 *self
54 }
55}
56
57impl ToRealPrecision for DVec3 {
58 type Adjusted = Vec3;
59 fn real(&self) -> Self::Adjusted {
60 self.as_vec3()
61 }
62}
63
64impl ToRealPrecision for Vec2 {
65 type Adjusted = Vec2;
66 fn real(&self) -> Self::Adjusted {
67 *self
68 }
69}
70
71impl ToRealPrecision for DVec2 {
72 type Adjusted = Vec2;
73 fn real(&self) -> Self::Adjusted {
74 self.as_vec2()
75 }
76}
77
78impl ToRealPrecision for Quat {
79 type Adjusted = Quat;
80 fn real(&self) -> Self::Adjusted {
81 *self
82 }
83}
84
85impl ToRealPrecision for DQuat {
86 type Adjusted = Quat;
87 fn real(&self) -> Self::Adjusted {
88 self.as_quat()
89 }
90}
91
92impl ToRealPrecision for Rot2 {
93 type Adjusted = Rot2;
94 fn real(&self) -> Self::Adjusted {
95 *self
96 }
97}
98
99impl ToRealPrecision for DRot2 {
100 type Adjusted = Rot2;
101 fn real(&self) -> Self::Adjusted {
102 Rot2::from_sin_cos(self.sin as f32, self.cos as f32)
103 }
104}
105
106#[cfg(feature = "2d")]
107impl ToRealPrecision for Rotation {
108 type Adjusted = Rot2;
109 fn real(&self) -> Self::Adjusted {
110 Rot2::from_sin_cos(self.sin, self.cos)
111 }
112}
113
114#[cfg(feature = "3d")]
115impl ToRealPrecision for Rotation {
116 type Adjusted = Quat;
117 fn real(&self) -> Self::Adjusted {
118 self.0
119 }
120}