|
1 |
| -use bevy_math::{Affine3A, Isometry3d, Mat4, Vec3}; |
| 1 | +use bevy_math::{Affine2, Affine3A, Isometry2d, Isometry3d, Mat3, Mat3A, Mat4, Vec2, Vec3}; |
2 | 2 |
|
3 |
| -use crate::prelude::{GlobalTransform, Transform3d}; |
| 3 | +use crate::prelude::{GlobalTransform, Transform2d, Transform3d}; |
4 | 4 |
|
5 | 5 | /// A trait for point transformation methods.
|
6 |
| -pub trait TransformPoint { |
| 6 | +pub trait TransformPoint<T = Vec3> { |
7 | 7 | /// Transform a point.
|
8 |
| - fn transform_point(&self, point: impl Into<Vec3>) -> Vec3; |
| 8 | + fn transform_point(&self, point: impl Into<T>) -> T; |
9 | 9 | }
|
10 | 10 |
|
11 |
| -impl TransformPoint for Transform3d { |
| 11 | +impl TransformPoint<Vec3> for Transform3d { |
12 | 12 | #[inline]
|
13 | 13 | fn transform_point(&self, point: impl Into<Vec3>) -> Vec3 {
|
14 | 14 | self.transform_point(point.into())
|
15 | 15 | }
|
16 | 16 | }
|
17 | 17 |
|
18 |
| -impl TransformPoint for GlobalTransform { |
| 18 | +impl TransformPoint<Vec3> for GlobalTransform { |
19 | 19 | #[inline]
|
20 | 20 | fn transform_point(&self, point: impl Into<Vec3>) -> Vec3 {
|
21 | 21 | self.transform_point(point.into())
|
22 | 22 | }
|
23 | 23 | }
|
24 | 24 |
|
25 |
| -impl TransformPoint for Mat4 { |
| 25 | +impl TransformPoint<Vec3> for Mat4 { |
26 | 26 | #[inline]
|
27 | 27 | fn transform_point(&self, point: impl Into<Vec3>) -> Vec3 {
|
28 | 28 | self.transform_point3(point.into())
|
29 | 29 | }
|
30 | 30 | }
|
31 | 31 |
|
32 |
| -impl TransformPoint for Affine3A { |
| 32 | +impl TransformPoint<Vec3> for Affine3A { |
33 | 33 | #[inline]
|
34 | 34 | fn transform_point(&self, point: impl Into<Vec3>) -> Vec3 {
|
35 | 35 | self.transform_point3(point.into())
|
36 | 36 | }
|
37 | 37 | }
|
38 | 38 |
|
39 |
| -impl TransformPoint for Isometry3d { |
| 39 | +impl TransformPoint<Vec3> for Isometry3d { |
40 | 40 | #[inline]
|
41 | 41 | fn transform_point(&self, point: impl Into<Vec3>) -> Vec3 {
|
42 | 42 | self.transform_point(point.into()).into()
|
43 | 43 | }
|
44 | 44 | }
|
| 45 | + |
| 46 | +impl TransformPoint<Vec2> for Transform2d { |
| 47 | + #[inline] |
| 48 | + fn transform_point(&self, point: impl Into<Vec2>) -> Vec2 { |
| 49 | + self.transform_point(point.into()) |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +impl TransformPoint<Vec2> for Mat3 { |
| 54 | + #[inline] |
| 55 | + fn transform_point(&self, point: impl Into<Vec2>) -> Vec2 { |
| 56 | + self.transform_point2(point.into()) |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +impl TransformPoint<Vec2> for Mat3A { |
| 61 | + #[inline] |
| 62 | + fn transform_point(&self, point: impl Into<Vec2>) -> Vec2 { |
| 63 | + self.transform_point2(point.into()) |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +impl TransformPoint<Vec2> for Affine2 { |
| 68 | + #[inline] |
| 69 | + fn transform_point(&self, point: impl Into<Vec2>) -> Vec2 { |
| 70 | + self.transform_point2(point.into()) |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +impl TransformPoint<Vec2> for Isometry2d { |
| 75 | + #[inline] |
| 76 | + fn transform_point(&self, point: impl Into<Vec2>) -> Vec2 { |
| 77 | + self.transform_point(point.into()) |
| 78 | + } |
| 79 | +} |
0 commit comments