From fd2579f4d956d1b3e7c6eaa6975d35af5cc83768 Mon Sep 17 00:00:00 2001 From: 443eb9#C <443eb9@gmail.com> Date: Tue, 12 Mar 2024 19:35:09 +0800 Subject: [PATCH] Changed: Some misc --- RELEASE_DRAFT.md | 1 + examples/basic.rs | 15 ++------------- examples/pbr.rs | 2 +- examples/print_graph.rs | 2 +- examples/stress_test.rs | 2 +- src/lib.rs | 40 +++++----------------------------------- 6 files changed, 11 insertions(+), 51 deletions(-) diff --git a/RELEASE_DRAFT.md b/RELEASE_DRAFT.md index a2e79d2..271d0cd 100644 --- a/RELEASE_DRAFT.md +++ b/RELEASE_DRAFT.md @@ -4,6 +4,7 @@ - Moved redundant Bevy features into dev-dependencies. - Added `alpha_threshold` to `ShadowMap2dConfig`. - Samples of PCF is no longer limited to 32. +- Added `SpotLight2d` # What's Fixed: diff --git a/examples/basic.rs b/examples/basic.rs index 912642d..9eca41b 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -39,7 +39,7 @@ fn main() { }), ..Default::default() }), - IncandescentPlugin::default(), + IncandescentPlugin, HelpersPlugin { inspector: true }, )) .add_systems(Startup, setup) @@ -104,17 +104,6 @@ fn setup(mut commands: Commands, asset_server: Res) { ..Default::default() }); - // commands.spawn(PointLight2dBundle { - // point_light: PointLight2d { - // color: Color::rgb(rd.gen(), rd.gen(), rd.gen()), - // intensity: 0.8, - // range: 400., - // radius: 30., - // }, - // transform: Transform::from_xyz(-50., -25., 0.), - // ..Default::default() - // }); - commands.spawn(SpotLight2dBundle { spot_light: SpotLight2d { color: Color::rgb(rd.gen(), rd.gen(), rd.gen()), @@ -123,7 +112,7 @@ fn setup(mut commands: Commands, asset_server: Res) { radius: 30., sector: CircularSector::Angles { start: std::f32::consts::FRAC_PI_6, - end: std::f32::consts::FRAC_PI_2, + end: std::f32::consts::FRAC_PI_2 + std::f32::consts::PI, }, }, transform: Transform::from_xyz(-50., -25., 0.), diff --git a/examples/pbr.rs b/examples/pbr.rs index 49f6103..2819610 100644 --- a/examples/pbr.rs +++ b/examples/pbr.rs @@ -34,7 +34,7 @@ fn main() { App::new() .add_plugins(( DefaultPlugins, - IncandescentPlugin::default(), + IncandescentPlugin, HelpersPlugin { inspector: true }, )) .add_systems(Startup, setup) diff --git a/examples/print_graph.rs b/examples/print_graph.rs index a55662b..2ededd6 100644 --- a/examples/print_graph.rs +++ b/examples/print_graph.rs @@ -3,6 +3,6 @@ use bevy_incandescent::IncandescentPlugin; fn main() { let mut app = App::new(); - app.add_plugins((DefaultPlugins, IncandescentPlugin::default())); + app.add_plugins((DefaultPlugins, IncandescentPlugin)); bevy_mod_debugdump::print_render_graph(&mut app); } diff --git a/examples/stress_test.rs b/examples/stress_test.rs index edf6cca..46e5798 100644 --- a/examples/stress_test.rs +++ b/examples/stress_test.rs @@ -27,7 +27,7 @@ fn main() { }), ..Default::default() }), - IncandescentPlugin::default(), + IncandescentPlugin, HelpersPlugin { inspector: false }, )) .add_systems(Startup, setup) diff --git a/src/lib.rs b/src/lib.rs index 4666256..332d80e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,27 +8,10 @@ pub mod ecs; pub mod math; pub mod render; -const APPRACHES: [LightingApproach; 1] = [ - #[cfg(feature = "catalinzz")] - LightingApproach::Catalinzz, - #[cfg(not(feature = "catalinzz"))] - LightingApproach::None, -]; +#[cfg(not(any(feature = "catalinzz")))] +compile_error!("Incandescent requires at least one render approach feature to be enabled!"); -pub struct IncandescentPlugin { - pub approach: LightingApproach, -} - -impl Default for IncandescentPlugin { - fn default() -> Self { - Self { - approach: *APPRACHES - .iter() - .find(|a| (**a) != LightingApproach::None) - .unwrap_or_else(|| panic!("No lighting approach is enabled")), - } - } -} +pub struct IncandescentPlugin; impl Plugin for IncandescentPlugin { fn build(&self, app: &mut App) { @@ -37,21 +20,8 @@ impl Plugin for IncandescentPlugin { IncandescentEcsPlugin, #[cfg(feature = "debug")] debug::IncandescentDebugPlugin, - )); - - match self.approach { - LightingApproach::None => unreachable!(), #[cfg(feature = "catalinzz")] - LightingApproach::Catalinzz => { - app.add_plugins(render::catalinzz::CatalinzzApproachPlugin); - } - } + render::catalinzz::CatalinzzApproachPlugin, + )); } } - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum LightingApproach { - None, - #[cfg(feature = "catalinzz")] - Catalinzz, -}