Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_solari/src/realtime/extract.rs
6596 views
1
use super::{prepare::SolariLightingResources, SolariLighting};
2
use bevy_camera::Camera;
3
use bevy_ecs::system::{Commands, ResMut};
4
use bevy_pbr::deferred::SkipDeferredLighting;
5
use bevy_render::{sync_world::RenderEntity, MainWorld};
6
7
pub fn extract_solari_lighting(mut main_world: ResMut<MainWorld>, mut commands: Commands) {
8
let mut cameras_3d = main_world.query::<(RenderEntity, &Camera, Option<&mut SolariLighting>)>();
9
10
for (entity, camera, solari_lighting) in cameras_3d.iter_mut(&mut main_world) {
11
let mut entity_commands = commands
12
.get_entity(entity)
13
.expect("Camera entity wasn't synced.");
14
if let Some(mut solari_lighting) = solari_lighting
15
&& camera.is_active
16
{
17
entity_commands.insert((solari_lighting.clone(), SkipDeferredLighting));
18
solari_lighting.reset = false;
19
} else {
20
entity_commands.remove::<(
21
SolariLighting,
22
SolariLightingResources,
23
SkipDeferredLighting,
24
)>();
25
}
26
}
27
}
28
29