mirror of
https://github.com/bevyengine/bevy
synced 2025-01-04 17:28:56 +00:00
38 lines
922 B
Rust
38 lines
922 B
Rust
|
use bevy_math::{Affine3A, Mat4, Vec3};
|
||
|
|
||
|
use crate::prelude::{GlobalTransform, Transform};
|
||
|
|
||
|
/// A trait for point transformation methods.
|
||
|
pub trait TransformPoint {
|
||
|
/// Transform a point.
|
||
|
fn transform_point(&self, point: impl Into<Vec3>) -> Vec3;
|
||
|
}
|
||
|
|
||
|
impl TransformPoint for Transform {
|
||
|
#[inline]
|
||
|
fn transform_point(&self, point: impl Into<Vec3>) -> Vec3 {
|
||
|
self.transform_point(point.into())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl TransformPoint for GlobalTransform {
|
||
|
#[inline]
|
||
|
fn transform_point(&self, point: impl Into<Vec3>) -> Vec3 {
|
||
|
self.transform_point(point.into())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl TransformPoint for Mat4 {
|
||
|
#[inline]
|
||
|
fn transform_point(&self, point: impl Into<Vec3>) -> Vec3 {
|
||
|
self.transform_point3(point.into())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl TransformPoint for Affine3A {
|
||
|
#[inline]
|
||
|
fn transform_point(&self, point: impl Into<Vec3>) -> Vec3 {
|
||
|
self.transform_point3(point.into())
|
||
|
}
|
||
|
}
|