Skip to content

Commit

Permalink
Fixed invisible textures due to frustum culling introduced in Bevy 0.…
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Kirschner committed Aug 19, 2023
1 parent 0c11796 commit e3ce841
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/game/camera.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::game::constants::RENDER_PLANE_Z;
use crate::game::tilewrapper::MapWrapper;
use crate::ui::uicontrols::WindowUiOverlayInfo;
use crate::ui::UiSizeChangedEvent;
Expand Down Expand Up @@ -122,11 +123,11 @@ pub fn setup_camera(
};
image.resize(size);
let image_handle = images.add(image);
let mut layer_camera = Camera2dBundle::new_with_far(1000.);
let mut layer_camera = Camera2dBundle::default();
layer_camera.camera.target = RenderTarget::Image(image_handle.clone());
layer_camera.camera.order = -1;

let main_camera = Camera2dBundle::new_with_far(1000.);
let main_camera = Camera2dBundle::default();
let layer = RenderLayers::layer(LAYER_ID);
commands.insert_resource::<WindowUiOverlayInfo>(WindowUiOverlayInfo::default());
commands.spawn((main_camera, MainCamera));
Expand All @@ -137,7 +138,8 @@ pub fn setup_camera(
transform: Transform {
// Rescale the world, such that 1 world unit = 1 tile
scale: Vec3::splat(1. / (config.config.tile_set.texture_size() as f32)),
..Transform::IDENTITY
translation: Vec3::new(0., 0., RENDER_PLANE_Z),
..default()
},
..default()
},
Expand Down
8 changes: 5 additions & 3 deletions src/game/constants.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/// The Player's Z coordinate
pub const PLAYER_Z: f32 = -1.0;
pub const PLAYER_Z: f32 = 10.0;
/// The World Tiles' Z coordinate
pub const WORLD_Z: f32 = -2.0;
pub const WORLD_Z: f32 = 5.0;
/// The Render Plane' Z coordinate
pub const RENDER_PLANE_Z: f32 = 99.0;
/// The Map Editor Preview Tiles' Z coordinate
pub const MAPEDITOR_PREVIEWTILE_Z: f32 = 0.0;
pub const MAPEDITOR_PREVIEWTILE_Z: f32 = 50.0;
/// The Map Editor Preview Tiles' Alpha value [0.0,1.0]
pub const MAPEDITOR_PREVIEWTILE_ALPHA: f32 = 0.40;
/// The Map Editor Preview Tiles' Air Texture Atlas Index
Expand Down

0 comments on commit e3ce841

Please sign in to comment.