From ba0651296f14cc5e9597b4a478bd400c19806fd8 Mon Sep 17 00:00:00 2001 From: Tobias Berger Date: Mon, 7 Nov 2022 12:29:56 +0100 Subject: [PATCH] Remove globe_view feature it's really just not worth the effort imho --- .github/workflows/release.yaml | 36 ++++++++----- Cargo.toml | 3 +- build_all.sh.ps1 | 24 +++------ planet/Cargo.toml | 3 +- planet/src/world_manager.rs | 54 +------------------ src/gui/widgets/toolbar.rs | 33 ------------ src/gui/windows/tile_info.rs | 6 +-- src/main.rs | 95 ---------------------------------- src/plugins/world_plugins.rs | 5 -- 9 files changed, 39 insertions(+), 220 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f75d642..4216eea 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -10,18 +10,6 @@ jobs: strategy: matrix: include: - - target: x86_64-apple-darwin - os: macos-latest - features: globe_view - - target: aarch64-apple-darwin - os: macos-latest - features: globe_view - - target: x86_64-pc-windows-msvc - os: windows-latest - features: globe_view - - target: x86_64-unknown-linux-gnu - os: ubuntu-latest - features: globe_view - target: x86_64-apple-darwin os: macos-latest features: render @@ -46,6 +34,30 @@ jobs: - target: x86_64-unknown-linux-gnu os: ubuntu-latest features: "" + - target: x86_64-apple-darwin + os: macos-latest + features: render,logging + - target: aarch64-apple-darwin + os: macos-latest + features: render,logging + - target: x86_64-pc-windows-msvc + os: windows-latest + features: render,logging + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + features: render,logging + - target: x86_64-apple-darwin + os: macos-latest + features: logging + - target: aarch64-apple-darwin + os: macos-latest + features: logging + - target: x86_64-pc-windows-msvc + os: windows-latest + features: logging + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + features: logging runs-on: ${{ matrix.os }} steps: - name: Checkout diff --git a/Cargo.toml b/Cargo.toml index 039f5f7..87e276a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,9 +27,8 @@ codegen-units = 1 # bevy/trace_chrome for tracing by function # https://github.com/bevyengine/bevy/blob/main/docs/profiling.md logging = ["planet/logging"] -globe_view = ["planet/globe_view", "render"] render = ["bevy/bevy_asset", "bevy/bevy_winit", "bevy/x11", "bevy/wayland", "bevy/render", "planet/render", "dep:fxhash", "dep:bevy_egui"] -default = ["render", "logging", "globe_view"] +default = ["render", "logging"] [dependencies.planet] path = "planet" diff --git a/build_all.sh.ps1 b/build_all.sh.ps1 index 0382f31..42d840b 100755 --- a/build_all.sh.ps1 +++ b/build_all.sh.ps1 @@ -1,26 +1,18 @@ #!/bin/env /bin/sh -echo "Debug-build features: minimal" +echo "Debug-build with features: minimal" cargo build --no-default-features --features= && -echo "Debug-build features: logging" && +echo "Debug-build with features: logging" && cargo build --no-default-features --features=logging && -echo "Debug-build features: render" && +echo "Debug-build with features: render" && cargo build --no-default-features --features=render && -echo "Debug-build features: logging,render" && +echo "Debug-build with features: logging render" && cargo build --no-default-features --features=logging,render && -echo "Debug-build features: globe_view" && -cargo build --no-default-features --features=globe_view && -echo "Debug-build features: logging,globe_view" && -cargo build --no-default-features --features=logging,globe_view && -echo "Release-build features: minimal" +echo "Release-build with features: minimal" cargo build --release --no-default-features --features= && -echo "Release-build features: logging" && +echo "Release-build with features: logging" && cargo build --release --no-default-features --features=logging && -echo "Release-build features: render" && +echo "Release-build with features: render" && cargo build --release --no-default-features --features=render && -echo "Release-build features: logging,render" && +echo "Release-build with features: logging render" && cargo build --release --no-default-features --features=logging,render && -echo "Release-build features: globe_view" && -cargo build --release --no-default-features --features=globe_view && -echo "Release-build features: logging,globe_view" && -cargo build --release --no-default-features --features=logging,globe_view && echo "Done!" \ No newline at end of file diff --git a/planet/Cargo.toml b/planet/Cargo.toml index a18a094..e6a149b 100644 --- a/planet/Cargo.toml +++ b/planet/Cargo.toml @@ -8,9 +8,8 @@ release = { strip = "symbols", lto = "thin", opt-level = "z" } [features] logging = [] -globe_view = ["render"] render = ["bevy/render"] -default = ["render", "logging", "globe_view"] +default = ["render", "logging"] [dependencies.rand] version = "0.8.5" diff --git a/planet/src/world_manager.rs b/planet/src/world_manager.rs index 083f128..7537046 100644 --- a/planet/src/world_manager.rs +++ b/planet/src/world_manager.rs @@ -1,12 +1,8 @@ #[cfg(all(feature = "logging", feature = "render"))] use bevy::log::debug; -#[cfg(feature = "logging")] -use bevy::utils::default; -#[cfg(all(feature = "render", feature = "globe_view"))] -use std::f32::consts::PI; use { crate::{macros::iterable_enum, World, WorldGenError}, - bevy::log::warn, + bevy::{log::warn, utils::default}, rand::random, std::{ error::Error, @@ -94,11 +90,7 @@ iterable_enum!(PlanetView { Biomes, Altitude }); #[cfg(feature = "render")] #[derive(Debug, Default)] pub struct WorldRenderSettings { - pub map_image_handle_id: Option, - #[cfg(feature = "globe_view")] - pub globe_image_handle_id: Option, - #[cfg(feature = "globe_view")] - pub globe_material_handle_id: Option, + pub map_image_handle_id: Option, rainfall_visible: bool, temperature_visible: bool, @@ -422,46 +414,4 @@ impl WorldManager { }) .collect() } - - #[cfg(all(feature = "render", feature = "globe_view"))] - #[must_use] - fn globe_colors(&self) -> Vec { - let world = self.world(); - let width = world.width as usize; - let height = world.height as usize; - - let mut colors = vec![Color::PINK; height * width]; - - for y in 0..world.height as usize * 2 { - for x in 0..world.width as usize { - let factor_y = (1.0 - f32::cos(PI * y as f32 / (world.height * 2) as f32)) / 2.0; - let real_y = f32::floor(world.height as f32 * factor_y) as usize; - #[cfg(feature = "logging")] - assert!( - real_y < world.height as usize, - "Trying to get cell off of planet. {}/{}", - real_y, - world.height - ); - - colors[real_y * width + x] = self.generate_color(&world.terrain[real_y][x]); - } - } - colors - } - - #[cfg(all(feature = "render", feature = "globe_view"))] - #[must_use] - pub fn globe_color_bytes(&self) -> Vec { - self.globe_colors() - .iter() - .flat_map(|color| { - color - .as_rgba_f32() - .iter() - .flat_map(|num| num.to_le_bytes()) - .collect::>() - }) - .collect() - } } diff --git a/src/gui/widgets/toolbar.rs b/src/gui/widgets/toolbar.rs index d7d7b19..8c09aef 100644 --- a/src/gui/widgets/toolbar.rs +++ b/src/gui/widgets/toolbar.rs @@ -1,12 +1,3 @@ -#[cfg(feature = "globe_view")] -use { - crate::components::panning::Pan2d, - bevy::{ - core_pipeline::{core_2d::Camera2d, core_3d::Camera3d}, - ecs::query::{With, Without}, - render::camera::Camera, - }, -}; use { crate::{ gui::{open_window, update_textures, windows::Overlay, WidgetId, WidgetSystem}, @@ -29,7 +20,6 @@ use { std::marker::PhantomData, }; -#[cfg(not(feature = "globe_view"))] iterable_enum!(ToolbarButton { GenerateWorld, SaveWorld, @@ -37,15 +27,6 @@ iterable_enum!(ToolbarButton { Overlays, ToggleBiomes, }); -#[cfg(feature = "globe_view")] -iterable_enum!(ToolbarButton { - GenerateWorld, - SaveWorld, - LoadWorld, - Overlays, - ToggleBiomes, - GlobeView, -}); impl ToolbarButton { fn clicked(self, world: &mut World) { @@ -78,18 +59,6 @@ impl ToolbarButton { world_manager.render_settings.cycle_view(); update_textures(&world_manager, &mut world.resource_mut::>()); }, - #[cfg(feature = "globe_view")] - ToolbarButton::GlobeView => { - let mut camera_3d = world - .query_filtered::<&mut Camera, (With, Without)>() - .single_mut(world); - camera_3d.is_active = !camera_3d.is_active; - let (mut camera_2d, mut pancam) = world - .query_filtered::<(&mut Camera, &mut Pan2d), (With, Without)>() - .single_mut(world); - camera_2d.is_active = !camera_2d.is_active; - pancam.enabled = camera_2d.is_active; - }, }; }); } @@ -103,8 +72,6 @@ impl From for &'static str { ToolbarButton::GenerateWorld => "Generate new world", ToolbarButton::SaveWorld => "Save", ToolbarButton::LoadWorld => "Load", - #[cfg(feature = "globe_view")] - ToolbarButton::GlobeView => "Toggle globe", } } } diff --git a/src/gui/windows/tile_info.rs b/src/gui/windows/tile_info.rs index 45af2b5..221a823 100644 --- a/src/gui/windows/tile_info.rs +++ b/src/gui/windows/tile_info.rs @@ -42,13 +42,13 @@ impl WindowSystem for TileInfo<'_, '_> { } = &world_manager.world().terrain[cursor_y as usize][cursor_x as usize]; _ = ui.label("Altitude"); - _ = ui.label(format!("{:.2}", altitude)); + _ = ui.label(format!("{altitude:.2}")); ui.end_row(); _ = ui.label("Rainfall"); - _ = ui.label(format!("{:.2}", rainfall)); + _ = ui.label(format!("{rainfall:.2}")); ui.end_row(); _ = ui.label("Temperature"); - _ = ui.label(format!("{:.2}", temperature)); + _ = ui.label(format!("{temperature:.2}")); ui.end_row(); ui.end_row(); diff --git a/src/main.rs b/src/main.rs index 3620052..5ffc00b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,20 +57,6 @@ use { gui::{render_windows, widget, widgets::ToolbarWidget, window::open_window, windows::TileInfo}, resources::{CursorMapPosition, OpenedWindows}, }; -#[cfg(all(feature = "render", feature = "globe_view"))] -use { - bevy::{ - asset::Handle, - core_pipeline::core_3d::Camera3dBundle, - pbr::{PbrBundle, PointLight, PointLightBundle, StandardMaterial}, - prelude::{Quat, Vec3}, - render::camera::OrthographicProjection, - render::mesh::{shape::UVSphere, Mesh}, - time::Time, - transform::components::Transform, - }, - std::f32::consts::FRAC_PI_2, -}; #[cfg(feature = "render")] fn update_cursor_map_position( @@ -104,26 +90,12 @@ fn update_cursor_map_position( } } -#[cfg(all(feature = "render", feature = "globe_view"))] -const GLOBE_ROTATIONS_PER_SECOND: f32 = std::f32::consts::TAU / 15.0; -#[cfg(all(feature = "render", feature = "globe_view"))] -fn rotate_globe( - mut globe_transform: Query<'_, '_, &mut Transform, With>>, - time: Res