diff --git a/crates/bevy_math/src/bounding/bounded2d/mod.rs b/crates/bevy_math/src/bounding/bounded2d/mod.rs index 7555b6ef6fb13..7c0b00cf47e41 100644 --- a/crates/bevy_math/src/bounding/bounded2d/mod.rs +++ b/crates/bevy_math/src/bounding/bounded2d/mod.rs @@ -290,12 +290,12 @@ mod aabb2d_tests { #[test] fn scale_around_center() { let a = Aabb2d { - min: Vec2::new(-1., -1.), - max: Vec2::new(1., 1.), + min: Vec2::NEG_ONE, + max: Vec2::ONE, }; - let scaled = a.scale_around_center(Vec2::new(2., 2.)); - assert!((scaled.min - Vec2::new(-2., -2.)).length() < std::f32::EPSILON); - assert!((scaled.max - Vec2::new(2., 2.)).length() < std::f32::EPSILON); + let scaled = a.scale_around_center(Vec2::splat(2.)); + assert!((scaled.min - Vec2::splat(-2.)).length() < std::f32::EPSILON); + assert!((scaled.max - Vec2::splat(2.)).length() < std::f32::EPSILON); assert!(!a.contains(&scaled)); assert!(scaled.contains(&a)); } diff --git a/crates/bevy_math/src/bounding/bounded3d/mod.rs b/crates/bevy_math/src/bounding/bounded3d/mod.rs index ba6c4a42d43da..2e8b22e279acc 100644 --- a/crates/bevy_math/src/bounding/bounded3d/mod.rs +++ b/crates/bevy_math/src/bounding/bounded3d/mod.rs @@ -286,12 +286,12 @@ mod aabb3d_tests { #[test] fn scale_around_center() { let a = Aabb3d { - min: Vec3::new(-1., -1., -1.), - max: Vec3::new(1., 1., 1.), + min: Vec3::NEG_ONE, + max: Vec3::ONE, }; - let scaled = a.scale_around_center(Vec3::new(2., 2., 2.)); - assert!((scaled.min - Vec3::new(-2., -2., -2.)).length() < std::f32::EPSILON); - assert!((scaled.max - Vec3::new(2., 2., 2.)).length() < std::f32::EPSILON); + let scaled = a.scale_around_center(Vec3::splat(2.)); + assert!((scaled.min - Vec3::splat(-2.)).length() < std::f32::EPSILON); + assert!((scaled.max - Vec3::splat(2.)).length() < std::f32::EPSILON); assert!(!a.contains(&scaled)); assert!(scaled.contains(&a)); } @@ -478,12 +478,7 @@ impl BoundingVolume for BoundingSphere { #[inline(always)] fn scale_around_center(&self, scale: Self::HalfSize) -> Self { debug_assert!(scale >= 0.); - Self { - center: self.center, - sphere: Sphere { - radius: self.radius() * scale, - }, - } + Self::new(self.center, self.radius() * scale) } }