Skip to content

Commit 510723b

Browse files
committed
small fixes: derive Deref DerefMut, un-pub inactive_half_space
1 parent 87aa360 commit 510723b

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

crates/bevy_camera/src/primitives.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::borrow::Borrow;
2-
use core::ops::{Deref, DerefMut};
32

3+
use bevy_derive::{Deref, DerefMut};
44
use bevy_ecs::{component::Component, entity::EntityHashMap, reflect::ReflectComponent};
55
use bevy_math::{
66
bounding::{Aabb3d, BoundingVolume},
@@ -216,24 +216,10 @@ impl Sphere {
216216
/// [`GlobalTransform`]: bevy_transform::components::GlobalTransform
217217
/// [`Camera2d`]: crate::Camera2d
218218
/// [`Camera3d`]: crate::Camera3d
219-
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
219+
#[derive(Component, Clone, Copy, Debug, Default, Deref, DerefMut, Reflect)]
220220
#[reflect(Component, Default, Debug, Clone)]
221221
pub struct Frustum(pub ViewFrustum);
222222

223-
impl Deref for Frustum {
224-
type Target = ViewFrustum;
225-
226-
fn deref(&self) -> &Self::Target {
227-
&self.0
228-
}
229-
}
230-
231-
impl DerefMut for Frustum {
232-
fn deref_mut(&mut self) -> &mut Self::Target {
233-
&mut self.0
234-
}
235-
}
236-
237223
impl Frustum {
238224
/// Checks if a sphere intersects the frustum.
239225
#[inline]

crates/bevy_math/src/primitives/view_frustum.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
77

88
/// A region of 3D space defined by the intersection of 6 [`HalfSpace`]s.
99
///
10-
/// Frustums are typically an apex-truncated square pyramid (a pyramid without the top) or a cuboid.
10+
/// View Frustums are typically an apex-truncated square pyramid (a pyramid without the top) or a cuboid.
1111
///
1212
/// Half spaces are ordered left, right, top, bottom, near, far. The normal vectors
1313
/// of the half-spaces point towards the interior of the frustum.
@@ -35,17 +35,17 @@ impl ViewFrustum {
3535
/// Vec4 representing an inactive half space.
3636
/// The bisecting plane's unit normal is set to (0, 0, 0).
3737
/// The signed distance along the normal from the plane to the origin is set to `f32::INFINITY`.
38-
pub const INACTIVE_HALF_SPACE: Vec4 = Vec4::new(0.0, 0.0, 0.0, f32::INFINITY);
38+
const INACTIVE_HALF_SPACE: Vec4 = Vec4::new(0.0, 0.0, 0.0, f32::INFINITY);
3939

40-
/// Returns a frustum derived from `clip_from_world`.
40+
/// Returns a view frustum derived from `clip_from_world`.
4141
#[inline]
4242
pub fn from_clip_from_world(clip_from_world: &Mat4) -> Self {
4343
let mut frustum = ViewFrustum::from_clip_from_world_no_far(clip_from_world);
4444
frustum.half_spaces[Self::FAR_PLANE_IDX] = HalfSpace::new(clip_from_world.row(2));
4545
frustum
4646
}
4747

48-
/// Returns a frustum derived from `clip_from_world`,
48+
/// Returns a view frustum derived from `clip_from_world`,
4949
/// but with a custom far plane.
5050
#[inline]
5151
pub fn from_clip_from_world_custom_far(
@@ -64,7 +64,7 @@ impl ViewFrustum {
6464
// NOTE: This approach of extracting the frustum half-space from the view
6565
// projection matrix is from Foundations of Game Engine Development 2
6666
// Rendering by Lengyel.
67-
/// Returns a frustum derived from `view_projection`,
67+
/// Returns a view frustum derived from `view_projection`,
6868
/// without a far plane.
6969
fn from_clip_from_world_no_far(clip_from_world: &Mat4) -> Self {
7070
let row0 = clip_from_world.row(0);

0 commit comments

Comments
 (0)