Skip to content

Commit

Permalink
Use Time resource instead of Extracting Time (#7316)
Browse files Browse the repository at this point in the history
# Objective

- "Fixes #7308".

## Solution

- Use the `Time` `Resource` instead of `Extract<Res<Time>>`
  • Loading branch information
targrub committed Jan 21, 2023
1 parent cb4e8c8 commit ff5e4fd
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions examples/stress_tests/many_lights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bevy::{
math::{DVec2, DVec3},
pbr::{ExtractedPointLight, GlobalLightMeta},
prelude::*,
render::{camera::ScalingMode, Extract, RenderApp, RenderStage},
render::{camera::ScalingMode, RenderApp, RenderStage},
window::{PresentMode, WindowPlugin},
};
use rand::{thread_rng, Rng};
Expand Down Expand Up @@ -156,15 +156,13 @@ impl Plugin for LogVisibleLights {
Err(_) => return,
};

render_app
.add_system_to_stage(RenderStage::Extract, extract_time)
.add_system_to_stage(RenderStage::Prepare, print_visible_light_count);
render_app.add_system_to_stage(RenderStage::Prepare, print_visible_light_count);
}
}

// System for printing the number of meshes on every tick of the timer
fn print_visible_light_count(
time: Res<ExtractedTime>,
time: Res<Time>,
mut timer: Local<PrintingTimer>,
visible: Query<&ExtractedPointLight>,
global_light_meta: Res<GlobalLightMeta>,
Expand All @@ -180,13 +178,6 @@ fn print_visible_light_count(
}
}

#[derive(Resource, Deref, DerefMut)]
pub struct ExtractedTime(Time);

fn extract_time(mut commands: Commands, time: Extract<Res<Time>>) {
commands.insert_resource(ExtractedTime(time.clone()));
}

struct PrintingTimer(Timer);

impl Default for PrintingTimer {
Expand Down

0 comments on commit ff5e4fd

Please sign in to comment.