Skip to content

Commit

Permalink
fixup: Address comments by Selene.
Browse files Browse the repository at this point in the history
  • Loading branch information
tormeh committed Jul 13, 2023
1 parent 5e18846 commit 5afba9d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions crates/bevy_render/src/camera/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,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).
Expand All @@ -241,7 +241,7 @@ impl Camera {
) -> Option<Vec2> {
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;
}
Expand All @@ -264,8 +264,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,
Expand Down Expand Up @@ -344,8 +345,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<Vec3> {
// Build a transformation matrix to convert from NDC to world space using camera data
let ndc_to_world =
Expand Down

0 comments on commit 5afba9d

Please sign in to comment.