Skip to content

Commit 9bd6cc0

Browse files
Add Direction3dA and move direction types out of primitives (#12018)
# Objective Split up from #12017, add an aligned version of `Direction3d` for SIMD, and move direction types out of `primitives`. ## Solution Add `Direction3dA` and move direction types into a new `direction` module. --- ## Migration Guide The `Direction2d`, `Direction3d`, and `InvalidDirectionError` types have been moved out of `bevy::math::primitives`. Before: ```rust use bevy::math::primitives::Direction3d; ``` After: ```rust use bevy::math::Direction3d; ``` --------- Co-authored-by: Alice Cecile <[email protected]>
1 parent f939c09 commit 9bd6cc0

File tree

22 files changed

+598
-371
lines changed

22 files changed

+598
-371
lines changed

crates/bevy_gizmos/src/circles.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
use crate::prelude::{GizmoConfigGroup, Gizmos};
77
use bevy_math::Mat2;
8-
use bevy_math::{primitives::Direction3d, Quat, Vec2, Vec3};
8+
use bevy_math::{Direction3d, Quat, Vec2, Vec3};
99
use bevy_render::color::LegacyColor;
1010
use std::f32::consts::TAU;
1111

crates/bevy_gizmos/src/gizmos.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use bevy_ecs::{
88
system::{Deferred, ReadOnlySystemParam, Res, Resource, SystemBuffer, SystemMeta, SystemParam},
99
world::{unsafe_world_cell::UnsafeWorldCell, World},
1010
};
11-
use bevy_math::{primitives::Direction3d, Mat2, Quat, Vec2, Vec3};
11+
use bevy_math::{Direction3d, Mat2, Quat, Vec2, Vec3};
1212
use bevy_render::color::LegacyColor;
1313
use bevy_transform::TransformPoint;
1414

crates/bevy_gizmos/src/primitives/dim2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use std::f32::consts::PI;
55
use super::helpers::*;
66

77
use bevy_math::primitives::{
8-
BoxedPolygon, BoxedPolyline2d, Capsule2d, Circle, Direction2d, Ellipse, Line2d, Plane2d,
9-
Polygon, Polyline2d, Primitive2d, Rectangle, RegularPolygon, Segment2d, Triangle2d,
8+
BoxedPolygon, BoxedPolyline2d, Capsule2d, Circle, Ellipse, Line2d, Plane2d, Polygon,
9+
Polyline2d, Primitive2d, Rectangle, RegularPolygon, Segment2d, Triangle2d,
1010
};
11-
use bevy_math::{Mat2, Vec2};
11+
use bevy_math::{Direction2d, Mat2, Vec2};
1212
use bevy_render::color::LegacyColor;
1313

1414
use crate::prelude::{GizmoConfigGroup, Gizmos};

crates/bevy_gizmos/src/primitives/dim3.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use super::helpers::*;
44
use std::f32::consts::TAU;
55

66
use bevy_math::primitives::{
7-
BoxedPolyline3d, Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, Direction3d, Line3d,
8-
Plane3d, Polyline3d, Primitive3d, Segment3d, Sphere, Torus,
7+
BoxedPolyline3d, Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, Line3d, Plane3d,
8+
Polyline3d, Primitive3d, Segment3d, Sphere, Torus,
99
};
10-
use bevy_math::{Quat, Vec3};
10+
use bevy_math::{Direction3d, Quat, Vec3};
1111
use bevy_render::color::LegacyColor;
1212

1313
use crate::prelude::{GizmoConfigGroup, Gizmos};

crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//! Contains [`Bounded2d`] implementations for [geometric primitives](crate::primitives).
22
3-
use glam::{Mat2, Vec2};
4-
5-
use crate::primitives::{
6-
BoxedPolygon, BoxedPolyline2d, Capsule2d, Circle, Direction2d, Ellipse, Line2d, Plane2d,
7-
Polygon, Polyline2d, Rectangle, RegularPolygon, Segment2d, Triangle2d,
3+
use crate::{
4+
primitives::{
5+
BoxedPolygon, BoxedPolyline2d, Capsule2d, Circle, Ellipse, Line2d, Plane2d, Polygon,
6+
Polyline2d, Rectangle, RegularPolygon, Segment2d, Triangle2d,
7+
},
8+
Direction2d, Mat2, Vec2,
89
};
910

1011
use super::{Aabb2d, Bounded2d, BoundingCircle};
@@ -262,9 +263,10 @@ mod tests {
262263
use crate::{
263264
bounding::Bounded2d,
264265
primitives::{
265-
Capsule2d, Circle, Direction2d, Ellipse, Line2d, Plane2d, Polygon, Polyline2d,
266-
Rectangle, RegularPolygon, Segment2d, Triangle2d,
266+
Capsule2d, Circle, Ellipse, Line2d, Plane2d, Polygon, Polyline2d, Rectangle,
267+
RegularPolygon, Segment2d, Triangle2d,
267268
},
269+
Direction2d,
268270
};
269271

270272
#[test]

crates/bevy_math/src/bounding/bounded3d/primitive_impls.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
//! Contains [`Bounded3d`] implementations for [geometric primitives](crate::primitives).
22
3-
use glam::{Mat3, Quat, Vec2, Vec3};
4-
53
use crate::{
64
bounding::{Bounded2d, BoundingCircle},
75
primitives::{
8-
BoxedPolyline3d, Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, Direction3d, Line3d,
9-
Plane3d, Polyline3d, Segment3d, Sphere, Torus, Triangle2d,
6+
BoxedPolyline3d, Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, Line3d, Plane3d,
7+
Polyline3d, Segment3d, Sphere, Torus, Triangle2d,
108
},
9+
Direction3d, Mat3, Quat, Vec2, Vec3,
1110
};
1211

1312
use super::{Aabb3d, Bounded3d, BoundingSphere};
@@ -311,9 +310,10 @@ mod tests {
311310
use crate::{
312311
bounding::Bounded3d,
313312
primitives::{
314-
Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, Direction3d, Line3d, Plane3d,
315-
Polyline3d, Segment3d, Sphere, Torus,
313+
Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, Line3d, Plane3d, Polyline3d,
314+
Segment3d, Sphere, Torus,
316315
},
316+
Direction3d,
317317
};
318318

319319
#[test]

crates/bevy_math/src/bounding/raycast2d.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{Aabb2d, BoundingCircle, IntersectsVolume};
2-
use crate::{primitives::Direction2d, Ray2d, Vec2};
2+
use crate::{Direction2d, Ray2d, Vec2};
33

44
/// A raycast intersection test for 2D bounding volumes
55
#[derive(Clone, Debug)]

crates/bevy_math/src/bounding/raycast3d.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{Aabb3d, BoundingSphere, IntersectsVolume};
2-
use crate::{primitives::Direction3d, Ray3d, Vec3};
2+
use crate::{Direction3d, Ray3d, Vec3};
33

44
/// A raycast intersection test for 3D bounding volumes
55
#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)