Skip to content

Commit

Permalink
Use the first camera on RenderLayer 0
Browse files Browse the repository at this point in the history
  • Loading branch information
cpetzold authored and ChristopherBiscardi committed Jul 24, 2024
1 parent 5882f36 commit 032e4e0
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/render/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use super::extract::{
use crate::CoordinateSpace;
use bevy::{
prelude::*,
render::{camera::ExtractedCamera, view::ExtractedView},
render::{
camera::ExtractedCamera,
view::{ExtractedView, RenderLayers},
},
};
use vello::kurbo::Affine;

Expand Down Expand Up @@ -107,11 +110,14 @@ impl PrepareRenderInstance for ExtractedRenderAsset {

pub fn prepare_vector_affines(
mut commands: Commands,
camera: Query<(&ExtractedCamera, &ExtractedView), With<Camera2d>>,
camera: Query<(&ExtractedCamera, &ExtractedView, &RenderLayers), With<Camera2d>>,
mut render_assets: Query<(Entity, &ExtractedRenderAsset)>,
pixel_scale: Res<ExtractedPixelScale>,
) {
let Ok((camera, view)) = camera.get_single() else {
let Some((camera, view, _)) = camera
.iter()
.find(|&(_, _, &render_layers)| render_layers.intersects(&RenderLayers::default()))
else {
return;
};
let viewport_size: UVec2 = camera.physical_viewport_size.unwrap();
Expand All @@ -127,13 +133,17 @@ pub fn prepare_vector_affines(

pub fn prepare_scene_affines(
mut commands: Commands,
camera: Query<(&ExtractedCamera, &ExtractedView), With<Camera2d>>,
camera: Query<(&ExtractedCamera, &ExtractedView, &RenderLayers), With<Camera2d>>,
mut render_scenes: Query<(Entity, &ExtractedRenderScene)>,
pixel_scale: Res<ExtractedPixelScale>,
) {
let Ok((camera, view)) = camera.get_single() else {
let Some((camera, view, _)) = camera
.iter()
.find(|&(_, _, &render_layers)| render_layers.intersects(&RenderLayers::default()))
else {
return;
};

let size_pixels: UVec2 = camera.physical_viewport_size.unwrap();
let (pixels_x, pixels_y) = (size_pixels.x as f32, size_pixels.y as f32);
for (entity, render_scene) in render_scenes.iter_mut() {
Expand Down Expand Up @@ -208,11 +218,14 @@ pub fn prepare_scene_affines(

pub fn prepare_text_affines(
mut commands: Commands,
camera: Query<(&ExtractedCamera, &ExtractedView), With<Camera2d>>,
camera: Query<(&ExtractedCamera, &ExtractedView, &RenderLayers), With<Camera2d>>,
render_texts: Query<(Entity, &ExtractedRenderText)>,
pixel_scale: Res<ExtractedPixelScale>,
) {
let Ok((camera, view)) = camera.get_single() else {
let Some((camera, view, _)) = camera
.iter()
.find(|&(_, _, &render_layers)| render_layers.intersects(&RenderLayers::default()))
else {
return;
};
let size_pixels: UVec2 = camera.physical_viewport_size.unwrap();
Expand Down

0 comments on commit 032e4e0

Please sign in to comment.