diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index a5cc9c6c0723a..668ca075489ab 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -228,7 +228,7 @@ impl Camera { /// [`world_to_ndc`](Self::world_to_ndc). /// /// Returns `None` if any of these conditions occur: - /// - The computed coordinates are beyond the near or far plane + /// - The computed coordinates are beyond the near or far plane defined by the [`Projection`] /// - The logical viewport size cannot be computed. See [`logical_viewport_size`](Camera::logical_viewport_size) /// - The world coordinates cannot be mapped to the Normalized Device Coordinates. See [`world_to_ndc`](Camera::world_to_ndc) /// May also panic if `glam_assert` is enabled. See [`world_to_ndc`](Camera::world_to_ndc). @@ -240,7 +240,7 @@ impl Camera { ) -> Option { let target_size = self.logical_viewport_size()?; let ndc_space_coords = self.world_to_ndc(camera_transform, world_position)?; - // NDC z-values outside of 0 < z < 1 are outside the (implicit) camera frustum and are thus not in viewport-space + // NDC z-values outside of 0 < z < 1 are outside the (implicit, defined by the projection) camera frustum and are thus not in viewport-space if ndc_space_coords.z < 0.0 || ndc_space_coords.z > 1.0 { return None; } @@ -263,8 +263,9 @@ impl Camera { /// /// Returns `None` if any of these conditions occur: /// - The logical viewport size cannot be computed. See [`logical_viewport_size`](Camera::logical_viewport_size) - /// - The near or far plane cannot be computed. This can happen if the `camera_transform`, the `world_position`, or the projection matrix defined by [`CameraProjection`] contain `NAN`. - /// Panics if the projection matrix is null and `glam_assert` is enabled. + /// - The near or far plane cannot be computed. This can happen if the `camera_transform`, the `world_position`, or the + /// projection matrix defined by [`CameraProjection`] contain `NAN`, or the projection matrix cannot be inverted. + /// Panics if the projection matrix cannot be inverted and `glam_assert` is enabled. pub fn viewport_to_world( &self, camera_transform: &GlobalTransform, @@ -343,8 +344,9 @@ impl Camera { /// To get the world space coordinates with the viewport position, you should use /// [`world_to_viewport`](Self::world_to_viewport). /// - /// Returns `None` if the `camera_transform`, the `world_position`, or the projection matrix defined by [`CameraProjection`] contain `NAN`. - /// Panics if the projection matrix is null and `glam_assert` is enabled. + /// Returns `None` if the `camera_transform`, the `world_position`, or the projection matrix defined by + /// [`CameraProjection`] contain `NAN`, or the projection matrix cannot be inverted. + /// Panics if the projection matrix cannot be inverted and `glam_assert` is enabled. pub fn ndc_to_world(&self, camera_transform: &GlobalTransform, ndc: Vec3) -> Option { // Build a transformation matrix to convert from NDC to world space using camera data let ndc_to_world =