From 96c8800d638daccc7f24481b3dd2a402dc7edfff Mon Sep 17 00:00:00 2001 From: Laurent Moussault Date: Fri, 8 Sep 2023 13:01:41 +0200 Subject: [PATCH] Extend the default render range of the camera (#29) Done in order to match similar change in Bevy's camera (see bevyengine/bevy#9310) --- Cargo.toml | 15 ++++++++++++--- src/pixel_camera.rs | 5 ++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fd06a3e..fc901f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_pixel_camera" -version = "0.5.0" +version = "0.5.1" authors = ["drakmaniso "] edition = "2021" description = "A simple pixel-perfect camera plugin for Bevy, suitable for pixel-art" @@ -12,10 +12,19 @@ exclude = ["assets/**", ".vscode/**"] license = "MIT OR Apache-2.0" [dependencies] -bevy = { version = "0.11", default-features = false, features = ["bevy_core_pipeline", "bevy_render", "bevy_sprite"] } +bevy = { version = "0.11", default-features = false, features = [ + "bevy_core_pipeline", + "bevy_render", + "bevy_sprite", +] } [dev-dependencies] -bevy = { version = "0.11", default-features = false, features = ["bevy_winit", "bevy_asset", "png", "x11"] } +bevy = { version = "0.11", default-features = false, features = [ + "bevy_winit", + "bevy_asset", + "png", + "x11", +] } [[example]] name = "flappin" diff --git a/src/pixel_camera.rs b/src/pixel_camera.rs index 494d041..57df268 100644 --- a/src/pixel_camera.rs +++ b/src/pixel_camera.rs @@ -24,8 +24,7 @@ pub struct PixelCameraBundle { impl PixelCameraBundle { /// Create a component bundle for a camera with the specified projection. pub fn new(pixel_projection: PixelProjection) -> Self { - let far = pixel_projection.far; - let transform = Transform::from_xyz(0.0, 0.0, far - 0.1); + let transform = Transform::from_xyz(0.0, 0.0, 0.0); let view_projection = pixel_projection.get_projection_matrix() * transform.compute_matrix().inverse(); let frustum = Frustum::from_view_projection_custom_far( @@ -203,7 +202,7 @@ impl Default for PixelProjection { right: 1.0, bottom: -1.0, top: 1.0, - near: 0.0, + near: -1000.0, far: 1000.0, desired_width: None, desired_height: None,