Skip to content

Commit

Permalink
Changed: Some misc
Browse files Browse the repository at this point in the history
  • Loading branch information
443eb9 committed Mar 12, 2024
1 parent 2267037 commit fd2579f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 51 deletions.
1 change: 1 addition & 0 deletions RELEASE_DRAFT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
15 changes: 2 additions & 13 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn main() {
}),
..Default::default()
}),
IncandescentPlugin::default(),
IncandescentPlugin,
HelpersPlugin { inspector: true },
))
.add_systems(Startup, setup)
Expand Down Expand Up @@ -104,17 +104,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
..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()),
Expand All @@ -123,7 +112,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
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.),
Expand Down
2 changes: 1 addition & 1 deletion examples/pbr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main() {
App::new()
.add_plugins((
DefaultPlugins,
IncandescentPlugin::default(),
IncandescentPlugin,
HelpersPlugin { inspector: true },
))
.add_systems(Startup, setup)
Expand Down
2 changes: 1 addition & 1 deletion examples/print_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion examples/stress_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() {
}),
..Default::default()
}),
IncandescentPlugin::default(),
IncandescentPlugin,
HelpersPlugin { inspector: false },
))
.add_systems(Startup, setup)
Expand Down
40 changes: 5 additions & 35 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
}

0 comments on commit fd2579f

Please sign in to comment.