Skip to content

Commit c6f4583

Browse files
Add geometric primitives to bevy_math::prelude (#11432)
# Objective Currently, the `primitives` module is inside of the prelude for `bevy_math`, but the actual primitives are not. This requires either importing the shapes everywhere that uses them, or adding the `primitives::` prefix: ```rust let rectangle = meshes.add(primitives::Rectangle::new(5.0, 2.5)); ``` (Note: meshing isn't actually implemented yet, but it's in #11431) The primitives are meant to be used for a variety of tasks across several crates, like for meshing, bounding volumes, gizmos, colliders, and so on, so I think having them in the prelude is justified. It would make several common tasks a lot more ergonomic. ```rust let rectangle = meshes.add(Rectangle::new(5.0, 2.5)); ``` ## Solution Add `primitives::*` to `bevy_math::prelude`. --------- Co-authored-by: Alice Cecile <[email protected]>
1 parent c31f3aa commit c6f4583

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/bevy_math/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ pub mod prelude {
2727
CubicBSpline, CubicBezier, CubicCardinalSpline, CubicGenerator, CubicHermite,
2828
CubicSegment,
2929
},
30-
primitives, BVec2, BVec3, BVec4, EulerRot, FloatExt, IRect, IVec2, IVec3, IVec4, Mat2,
31-
Mat3, Mat4, Quat, Ray2d, Ray3d, Rect, URect, UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3,
30+
primitives::*,
31+
BVec2, BVec3, BVec4, EulerRot, FloatExt, IRect, IVec2, IVec3, IVec4, Mat2, Mat3, Mat4,
32+
Quat, Ray2d, Ray3d, Rect, URect, UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3,
3233
Vec3Swizzles, Vec4, Vec4Swizzles,
3334
};
3435
}

examples/3d/3d_viewport_to_world.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ fn draw_cursor(
2929
};
3030

3131
// Calculate if and where the ray is hitting the ground plane.
32-
let Some(distance) =
33-
ray.intersect_plane(ground.translation(), primitives::Plane3d::new(ground.up()))
32+
let Some(distance) = ray.intersect_plane(ground.translation(), Plane3d::new(ground.up()))
3433
else {
3534
return;
3635
};

0 commit comments

Comments
 (0)