From e206cdde4aaff445445386e47d7f8e9ea595cb96 Mon Sep 17 00:00:00 2001 From: Philip Linden Date: Sun, 15 Dec 2024 19:59:34 -0500 Subject: [PATCH 1/2] reorg: multiple crates --- .github/workflows/{cargo.yml => build.yml} | 34 +------ .github/workflows/extras.yml | 66 +++++++++++++ Cargo.toml | 106 ++++++++++----------- README.md | 53 +++++++++++ book.toml | 28 ++++++ docs/.gitignore | 1 + docs/SUMMARY.md | 11 +++ docs/devlog.md | 9 +- docs/index.md | 18 ++++ src/app3d/mod.rs | 45 --------- src/cli/Cargo.toml | 82 ++++++++++++++++ src/cli/README.md | 0 src/cli/src/lib.rs | 0 src/cli/src/main.rs | 12 +++ src/lib.rs | 37 ------- src/main.rs | 9 -- src/simulator/Cargo.toml | 75 +++++++++++++++ src/simulator/README.md | 0 src/simulator/{ => src}/atmosphere.rs | 5 +- src/simulator/{ => src}/balloon.rs | 8 +- src/simulator/{ => src}/core.rs | 0 src/simulator/{ => src}/forces/aero.rs | 6 +- src/simulator/{ => src}/forces/body.rs | 8 +- src/simulator/{ => src}/forces/mod.rs | 7 +- src/simulator/{ => src}/forces/scratch.rs | 0 src/simulator/{ => src}/heat.rs | 0 src/simulator/{ => src}/ideal_gas.rs | 9 +- src/simulator/src/lib.rs | 20 ++++ src/simulator/{ => src}/mod.rs | 3 +- src/simulator/{ => src}/payload.rs | 0 src/simulator/{ => src}/properties.rs | 0 src/simulator/{ => src}/time.rs | 2 +- src/ui/Cargo.toml | 96 +++++++++++++++++++ src/ui/README.md | 0 src/{app3d => ui/src}/camera.rs | 2 +- src/{app3d => ui/src}/controls.rs | 2 +- src/{app3d => ui/src}/dev_tools.rs | 11 +-- src/{app3d => ui/src}/gizmos.rs | 0 src/ui/src/lib.rs | 0 src/ui/src/main.rs | 50 ++++++++++ src/{app3d => ui/src}/scene.rs | 2 +- 41 files changed, 610 insertions(+), 207 deletions(-) rename .github/workflows/{cargo.yml => build.yml} (61%) create mode 100644 .github/workflows/extras.yml create mode 100644 book.toml create mode 100644 docs/.gitignore create mode 100644 docs/SUMMARY.md create mode 100644 docs/index.md delete mode 100644 src/app3d/mod.rs create mode 100644 src/cli/Cargo.toml create mode 100644 src/cli/README.md create mode 100644 src/cli/src/lib.rs create mode 100644 src/cli/src/main.rs delete mode 100644 src/lib.rs delete mode 100644 src/main.rs create mode 100644 src/simulator/Cargo.toml create mode 100644 src/simulator/README.md rename src/simulator/{ => src}/atmosphere.rs (98%) rename src/simulator/{ => src}/balloon.rs (95%) rename src/simulator/{ => src}/core.rs (100%) rename src/simulator/{ => src}/forces/aero.rs (96%) rename src/simulator/{ => src}/forces/body.rs (95%) rename src/simulator/{ => src}/forces/mod.rs (95%) rename src/simulator/{ => src}/forces/scratch.rs (100%) rename src/simulator/{ => src}/heat.rs (100%) rename src/simulator/{ => src}/ideal_gas.rs (96%) create mode 100644 src/simulator/src/lib.rs rename src/simulator/{ => src}/mod.rs (86%) rename src/simulator/{ => src}/payload.rs (100%) rename src/simulator/{ => src}/properties.rs (100%) rename src/simulator/{ => src}/time.rs (98%) create mode 100644 src/ui/Cargo.toml create mode 100644 src/ui/README.md rename src/{app3d => ui/src}/camera.rs (99%) rename src/{app3d => ui/src}/controls.rs (98%) rename src/{app3d => ui/src}/dev_tools.rs (97%) rename src/{app3d => ui/src}/gizmos.rs (100%) create mode 100644 src/ui/src/lib.rs create mode 100644 src/ui/src/main.rs rename src/{app3d => ui/src}/scene.rs (98%) diff --git a/.github/workflows/cargo.yml b/.github/workflows/build.yml similarity index 61% rename from .github/workflows/cargo.yml rename to .github/workflows/build.yml index 2a0c0dc..4d9e23e 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Cargo +name: Build on: push: @@ -64,35 +64,3 @@ jobs: with: name: doc path: target/doc - - # deploy: - # if: github.ref == 'refs/heads/main' - # needs: doc - # # Grant GITHUB_TOKEN the permissions required to make a Pages deployment - # permissions: - # pages: write # to deploy to Pages - # id-token: write # to verify the deployment originates from an appropriate source - # # Deploy to the github-pages environment - # environment: - # name: github-pages - # url: ${{ steps.deployment.outputs.page_url }} - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # with: - # fetch-depth: 0 - - # - uses: actions/download-artifact@v4 - # with: - # name: doc - # path: ${{ github.workspace }} - - # - name: Upload Pages artifact - # uses: actions/upload-pages-artifact@v3 - # with: - # path: target/doc - - # - name: Deploy to GitHub Pages - # id: deployment - # uses: actions/deploy-pages@v4 - # if: github.event_name != 'pull_request' diff --git a/.github/workflows/extras.yml b/.github/workflows/extras.yml new file mode 100644 index 0000000..1b415c5 --- /dev/null +++ b/.github/workflows/extras.yml @@ -0,0 +1,66 @@ +name: Extras + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + RUST_LOG: info + +jobs: + + book: + runs-on: ubuntu-20.04 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + steps: + - uses: actions/checkout@v2 + + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v2 + with: + mdbook-version: '0.4.10' + + - run: mdbook build + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.ref == 'refs/heads/main' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./book + +# deploy: +# if: github.ref == 'refs/heads/main' +# needs: doc +# # Grant GITHUB_TOKEN the permissions required to make a Pages deployment +# permissions: +# pages: write # to deploy to Pages +# id-token: write # to verify the deployment originates from an appropriate source +# # Deploy to the github-pages environment +# environment: +# name: github-pages +# url: ${{ steps.deployment.outputs.page_url }} +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 0 + +# - uses: actions/download-artifact@v4 +# with: +# name: doc +# path: ${{ github.workspace }} + +# - name: Upload Pages artifact +# uses: actions/upload-pages-artifact@v3 +# with: +# path: target/doc + +# - name: Deploy to GitHub Pages +# id: deployment +# uses: actions/deploy-pages@v4 +# if: github.event_name != 'pull_request' diff --git a/Cargo.toml b/Cargo.toml index 8b4f1da..8dd3790 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,73 +1,64 @@ [package] name = "yahs" description = "Yet Another HAB Simulator" -authors = ["Philip Linden "] version = "0.4.0" -edition = "2021" +authors = ["Philip Linden "] readme = "README.md" -license-file = "LICENSE" +license = "MIT or Apache-2.0" +edition = "2021" + +default-run = "yahs" + +# When importing this crate as a dependency, use the simulator library as "yahs" +[lib] +name = "yahs" +path = "src/simulator/src/lib.rs" +# When running this project as a CLI, use the CLI binary as "yahs" [[bin]] name = "yahs" -path = "src/main.rs" +path = "src/cli/src/main.rs" + +# Include the GUI binary as "yahs-ui" +[[bin]] +name = "yahs-ui" +path = "src/ui/src/main.rs" + +# These are the dependencies for the project when building it from the root +[dependencies] +yahs-simulator = { path = "src/simulator" } +yahs-ui = { path = "src/ui" } +yahs-cli = { path = "src/cli" } +bevy = { workspace = true } +avian3d = { workspace = true } +bevy-trait-query = { workspace = true } [features] -default = [ - # Default to a native dev build. - "dev_native", - "render", -] -dev = [ - # Improve compile times for dev builds by linking Bevy as a dynamic - # library. - "bevy/dynamic_linking", - "bevy/bevy_dev_tools", -] -dev_native = [ - "dev", - # Enable system information plugin for native dev builds. - "bevy/sysinfo_plugin", -] -headless = [ - # Exclude rendering features - # This feature does not include the "render" feature - # Thus, rendering-related dependencies are disabled -] -render = [ - # Enable features needed for visuals, windowed operation, and UIs. - "bevy/bevy_asset", - "bevy/bevy_color", - "bevy/bevy_core_pipeline", - "bevy/bevy_gizmos", - "bevy/ktx2", - "bevy/bevy_mesh_picking_backend", - "bevy/bevy_pbr", - "bevy/bevy_render", - "bevy/bevy_picking", - "bevy/bevy_text", - "bevy/bevy_ui", - "bevy/bevy_ui_picking_backend", - "bevy/bevy_window", - "bevy/bevy_winit", - "bevy/default_font", - "bevy/tonemapping_luts", - "bevy/png", - "bevy/webgl2", -] -inspect = [ - "default", - "bevy-inspector-egui", +default = ["dev"] +dev = ["yahs-ui/dev", "yahs-cli/dev", "yahs-simulator/dev"] +inspect = ["yahs-ui/inspect"] + +[workspace.package] +authors = ["Philip Linden "] +edition = "2021" +license = "MIT or Apache-2.0" + +[workspace] +resolver = "2" # Important for Bevy +members = [ + "src/yahs-simulator", + "src/yahs-ui", + "src/yahs-cli" ] -[dependencies] -bevy = { version = "0.15.0", default-features = false, features = [ - "bevy_asset", - "bevy_state", - "multi_threaded", +[workspace.dependencies] +# Shared dependencies with fixed versions +bevy = { version = "0.15.0", default-features = false, features = [ + "bevy_asset", "bevy_state", "multi_threaded" ] } -avian3d = { git = "https://github.com/Jondolf/avian.git", branch = "main", features = ["debug-plugin"] } -bevy-trait-query = { git = "https://github.com/JoJoJet/bevy-trait-query.git", branch = "bevy-0.15-rc" } -bevy-inspector-egui = { version = "0.28", optional = true, features = ["highlight_changes"] } +avian3d = { git = "https://github.com/Jondolf/avian.git", branch = "main" } +bevy-trait-query = "0.7.0" + # ----------------------------------------------------------------------------- # Some Bevy optimizations # ----------------------------------------------------------------------------- @@ -83,7 +74,6 @@ too_many_arguments = "allow" # Queries that access many components may trigger this lint. type_complexity = "allow" - # Compile with Performance Optimizations: # https://bevyengine.org/learn/quick-start/getting-started/setup/#compile-with-performance-optimizations diff --git a/README.md b/README.md index 10a7b0f..3570832 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,59 @@ A high altitude balloon flight simulator built in [devlog](docs/devlog.md) +## Usage + +### As a library + +Add `yahs` to your `Cargo.toml`: + +```toml +[dependencies] +yahs = "0.4.0" +``` + +Then, add the `SimulatorPlugins` to your Bevy app: + +```rust +use yahs::prelude::SimulatorPlugins; + +fn main() { + App::new().add_plugins(SimulatorPlugins); +} +``` + +Then you can use all of the components and systems from the +[`yahs-simulator`](./src/simulator/README.md) crate. + + +### As an application + +Running this package as a standalone application compiles all of the crates +and runs the CLI by default: + +```bash +cargo run --workspace +``` + +Force the standalone application to run the GUI instead of the CLI: + +```bash +cargo run --workspace --bin yahs-ui +``` + +Or install the standalone application to your system: + +```bash +# as a CLI +$ cargo install --path "src/cli" --release +$ yahs --help + +# as a GUI +$ cargo install --path "src/ui" --release +$ yahs-ui +``` + + ## License Except where noted (below and/or in individual files), all code in this diff --git a/book.toml b/book.toml new file mode 100644 index 0000000..fe47cbe --- /dev/null +++ b/book.toml @@ -0,0 +1,28 @@ +[book] +authors = ["Philip Linden"] +language = "en" +multilingual = false +title = "yahs documentation" +src = "docs" + +[build] +build-dir = "docs/book" +create-missing = false + +[output.html] +mathjax-support = true +default-theme = "ayu" +preferred-dark-theme = "ayu" +smart-punctuation = true +# no-section-label = true +git-repository-url = "https://github.com/philiplinden/yahs" +git-repository-icon = "fa-github" +edit-url-template = "https://github.com/philiplinden/yahs/edit/main/docs/{path}" + +[output.html.print] +enable = true # include support for printable output +page-break = true # insert page-break after each chapter + +[output.html.fold] +enable = true # whether or not to enable section folding +level = 1 # the depth to start folding diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..7585238 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +book diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md new file mode 100644 index 0000000..70b16c7 --- /dev/null +++ b/docs/SUMMARY.md @@ -0,0 +1,11 @@ +[Introduction](index.md) + +--- + +- [yahs-sim](crates/yahs-sim/README.md) +- [yahs-ui](crates/yahs-ui/README.md) +- [yahs-cli](crates/yahs-cli/README.md) + +--- + +[Devlog](devlog.md) diff --git a/docs/devlog.md b/docs/devlog.md index 32ae5ee..4af3818 100644 --- a/docs/devlog.md +++ b/docs/devlog.md @@ -1,5 +1,12 @@ # development log +## 2024-12-15 + +- Added [mdbook](https://github.com/rust-lang/mdBook) to the project. +- Added a CLI to the project so I can run things from the terminal without + getting caught up in the graphics. +- Organized the project into separate crates for the simulator, UI, and CLI. + ## 2024-11-30 One last check for third party crates to see if they've officially updated to @@ -36,7 +43,7 @@ Things I added: - [x] Lighting based on Bevy's example. - [x] Camera controller based on Bevy's `camera_controller` example. - [x] Observer/trigger-based debug UI toggles. Only some of them are working. -- [x] Added targeting controls to the camera. +- [x] Added targeting controls to the camera. Could be better. I spent a few hours trying to get the skybox working but I couldn't get it to load. diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..3d07d7d --- /dev/null +++ b/docs/index.md @@ -0,0 +1,18 @@ +# yet another HAB simulator + +This is a high altitude balloon simulator built in +[Bevy](https://bevyengine.org/). The goal is to simulate the flight of a HAB +(High Altitude Balloon) and to provide a software-in-the-loop platform for +testing out various physics and engineering concepts with a realistic +simulation. + +This project is split into three parts: + +- [yahs-sim](https://github.com/philiplinden/yahs-sim) is the main simulation + crate. It is a Bevy plugin that can be added to any Bevy project. +- [yahs-ui](https://github.com/philiplinden/yahs-ui) is a simple UI for the + simulation. It is not required but it is useful for visualizing the + simulation and for debugging. +- [yahs-cli](https://github.com/philiplinden/yahs-cli) is a command line tool + for running the simulation. It is useful for testing out the simulation + without having to deal with the UI. diff --git a/src/app3d/mod.rs b/src/app3d/mod.rs deleted file mode 100644 index 828048b..0000000 --- a/src/app3d/mod.rs +++ /dev/null @@ -1,45 +0,0 @@ -mod camera; -pub mod controls; -mod dev_tools; -mod scene; - -use camera::CameraPlugin; -use controls::ControlsPlugin; -use dev_tools::DevToolsPlugin; -use scene::ScenePlugin; - -use bevy::{ - app::{PluginGroup, PluginGroupBuilder}, - prelude::*, -}; - -pub struct App3dPlugins; - -impl PluginGroup for App3dPlugins { - fn build(self) -> PluginGroupBuilder { - PluginGroupBuilder::start::() - .add(UiPlugin) - .add(RenderedObjectsPlugin) - } -} - -/// A plugin group that includes all interface-related plugins -struct UiPlugin; - -impl Plugin for UiPlugin { - fn build(&self, app: &mut App) { - app.add_plugins(( - ControlsPlugin, - #[cfg(feature = "dev")] - DevToolsPlugin, - )); - } -} - -struct RenderedObjectsPlugin; - -impl Plugin for RenderedObjectsPlugin { - fn build(&self, app: &mut App) { - app.add_plugins((ScenePlugin, CameraPlugin)); - } -} diff --git a/src/cli/Cargo.toml b/src/cli/Cargo.toml new file mode 100644 index 0000000..717cc17 --- /dev/null +++ b/src/cli/Cargo.toml @@ -0,0 +1,82 @@ +[package] +name = "yahs-cli" +version = "0.4.0" +description = "CLI for the YAHS simulator" +edition = "2021" +authors = { workspace = true } +license = { workspace = true } + +[[bin]] +name = "yahs" +path = "src/main.rs" + +[dependencies] +yahs-simulator = { path = "../simulator" } +bevy = { workspace = true, default-features = false, features = [ + "bevy_state", + "multi_threaded", +] } +clap = { version = "4.5.23", features = [ "env"] } +thiserror = "2.0.7" + +[features] +default = ["dev"] +dev = [ + "yahs-simulator/dev", + "bevy/dynamic_linking", + "bevy/bevy_dev_tools", + "clap/debug", +] + +# ----------------------------------------------------------------------------- +# Some Bevy optimizations +# ----------------------------------------------------------------------------- + +# Idiomatic Bevy code often triggers these lints, and the CI workflow treats +# them as errors. In some cases they may still signal poor code quality however, +# so consider commenting out these lines. +[lints.clippy] +# Bevy supplies arguments to systems via dependency injection, so it's +# natural for systems to request more than 7 arguments -- which triggers +# this lint. +too_many_arguments = "allow" +# Queries that access many components may trigger this lint. +type_complexity = "allow" + +# Compile with Performance Optimizations: +# https://bevyengine.org/learn/quick-start/getting-started/setup/#compile-with-performance-optimizations + +# Enable a small amount of optimization in the dev profile for our code. +[profile.dev] +opt-level = 1 + +# Enable a large amount of optimization in the dev profile for dependencies. +[profile.dev.package."*"] +opt-level = 3 + +# The default profile is optimized for Wasm builds because that's what [Trunk +# reads](https://github.com/trunk-rs/trunk/issues/605). Optimize for size in the +# wasm-release profile to reduce load times and bandwidth usage on web. +[profile.release] +# Compile the entire crate as one unit. Slows compile times, marginal +# improvements. +codegen-units = 1 +# Do a second optimization pass over the entire program, including +# dependencies. Slows compile times, marginal improvements. +lto = "thin" +# Optimize with size in mind (also try "z", sometimes it is better). +# Slightly slows compile times, great improvements to file size and runtime +# performance. +opt-level = "s" +# Strip all debugging information from the binary to slightly reduce file +# size. +strip = "debuginfo" + +# Override some settings for native builds. +[profile.release-native] +# Default to release profile values. +inherits = "release" +# Optimize with performance in mind. +opt-level = 3 +# Keep debug information in the binary. +strip = "none" diff --git a/src/cli/README.md b/src/cli/README.md new file mode 100644 index 0000000..e69de29 diff --git a/src/cli/src/lib.rs b/src/cli/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/cli/src/main.rs b/src/cli/src/main.rs new file mode 100644 index 0000000..1391260 --- /dev/null +++ b/src/cli/src/main.rs @@ -0,0 +1,12 @@ +use bevy::{prelude::*, state::app::StatesPlugin}; +use yahs_simulator::prelude::SimulatorPlugins; + +fn main() { + App::new() + .add_plugins(( + MinimalPlugins, + StatesPlugin, + SimulatorPlugins, + )) + .run(); +} diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 319ab1c..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,37 +0,0 @@ - -mod app3d; -mod simulator; - -use bevy::{asset::AssetMetaCheck, prelude::*}; - -pub struct YahsPlugin; - -impl Plugin for YahsPlugin { - fn build(&self, app: &mut App) { - // Add Bevy plugins. - app.add_plugins(( - DefaultPlugins - .set(AssetPlugin { - // Wasm builds will check for meta files (that don't exist) - // if this isn't set. This causes errors and even panics on - // web build on itch. See - // https://github.com/bevyengine/bevy_github_ci_template/issues/48. - meta_check: AssetMetaCheck::Never, - ..default() - }) - .set(WindowPlugin { - primary_window: Window { - title: "🎈".to_string(), - canvas: Some("#bevy".to_string()), - fit_canvas_to_parent: true, - prevent_default_event_handling: true, - ..default() - } - .into(), - ..default() - }), - simulator::SimulatorPlugins, - app3d::App3dPlugins, - )); - } -} diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 7d22685..0000000 --- a/src/main.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Disable console on Windows for non-dev builds. -#![cfg_attr(not(feature = "dev"), windows_subsystem = "windows")] - -use bevy::prelude::*; -use yahs::YahsPlugin; - -fn main() -> AppExit { - App::new().add_plugins(YahsPlugin).run() -} diff --git a/src/simulator/Cargo.toml b/src/simulator/Cargo.toml new file mode 100644 index 0000000..5fac92e --- /dev/null +++ b/src/simulator/Cargo.toml @@ -0,0 +1,75 @@ +[package] +name = "yahs-simulator" +version = "0.4.0" +description = "High Altitude Balloon simulation plugin for Bevy" +edition = "2021" +authors = { workspace = true } +license = { workspace = true } + +[dependencies] +bevy = { workspace = true, default-features = false, features = [ + "bevy_state", + "multi_threaded", +] } +avian3d = { workspace = true } +bevy-trait-query = { workspace = true } + +[features] +default = [] +dev = [ + "bevy/dynamic_linking", + "bevy/bevy_dev_tools", +] + +# ----------------------------------------------------------------------------- +# Some Bevy optimizations +# ----------------------------------------------------------------------------- + +# Idiomatic Bevy code often triggers these lints, and the CI workflow treats +# them as errors. In some cases they may still signal poor code quality however, +# so consider commenting out these lines. +[lints.clippy] +# Bevy supplies arguments to systems via dependency injection, so it's +# natural for systems to request more than 7 arguments -- which triggers +# this lint. +too_many_arguments = "allow" +# Queries that access many components may trigger this lint. +type_complexity = "allow" + +# Compile with Performance Optimizations: +# https://bevyengine.org/learn/quick-start/getting-started/setup/#compile-with-performance-optimizations + +# Enable a small amount of optimization in the dev profile for our code. +[profile.dev] +opt-level = 1 + +# Enable a large amount of optimization in the dev profile for dependencies. +[profile.dev.package."*"] +opt-level = 3 + +# The default profile is optimized for Wasm builds because that's what [Trunk +# reads](https://github.com/trunk-rs/trunk/issues/605). Optimize for size in the +# wasm-release profile to reduce load times and bandwidth usage on web. +[profile.release] +# Compile the entire crate as one unit. Slows compile times, marginal +# improvements. +codegen-units = 1 +# Do a second optimization pass over the entire program, including +# dependencies. Slows compile times, marginal improvements. +lto = "thin" +# Optimize with size in mind (also try "z", sometimes it is better). +# Slightly slows compile times, great improvements to file size and runtime +# performance. +opt-level = "s" +# Strip all debugging information from the binary to slightly reduce file +# size. +strip = "debuginfo" + +# Override some settings for native builds. +[profile.release-native] +# Default to release profile values. +inherits = "release" +# Optimize with performance in mind. +opt-level = 3 +# Keep debug information in the binary. +strip = "none" diff --git a/src/simulator/README.md b/src/simulator/README.md new file mode 100644 index 0000000..e69de29 diff --git a/src/simulator/atmosphere.rs b/src/simulator/src/atmosphere.rs similarity index 98% rename from src/simulator/atmosphere.rs rename to src/simulator/src/atmosphere.rs index d0849e0..2056554 100644 --- a/src/simulator/atmosphere.rs +++ b/src/simulator/src/atmosphere.rs @@ -8,10 +8,11 @@ use avian3d::prelude::Position; use bevy::prelude::*; -use super::{ +use crate::{ ideal_gas::{ideal_gas_density, GasSpecies}, properties::{Density, Pressure, Temperature}, - SimulationUpdateOrder, SimState, Balloon, + core::{SimulationUpdateOrder, SimState}, + balloon::Balloon, }; pub struct AtmospherePlugin; diff --git a/src/simulator/balloon.rs b/src/simulator/src/balloon.rs similarity index 95% rename from src/simulator/balloon.rs rename to src/simulator/src/balloon.rs index 5e1b590..d6bb344 100644 --- a/src/simulator/balloon.rs +++ b/src/simulator/src/balloon.rs @@ -3,9 +3,11 @@ use avian3d::{math::PI, prelude::*}; use bevy::prelude::*; -use super::{ - ideal_gas::IdealGas, properties::sphere_radius_from_volume, - SimulationUpdateOrder, Volume, Weight, Drag, Buoyancy, +use crate::{ + ideal_gas::IdealGas, + properties::{sphere_radius_from_volume, Volume}, + core::SimulationUpdateOrder, + forces::{Weight, Drag, Buoyancy}, }; pub struct BalloonPlugin; diff --git a/src/simulator/core.rs b/src/simulator/src/core.rs similarity index 100% rename from src/simulator/core.rs rename to src/simulator/src/core.rs diff --git a/src/simulator/forces/aero.rs b/src/simulator/src/forces/aero.rs similarity index 96% rename from src/simulator/forces/aero.rs rename to src/simulator/src/forces/aero.rs index e01c4b1..239dd6d 100644 --- a/src/simulator/forces/aero.rs +++ b/src/simulator/src/forces/aero.rs @@ -4,7 +4,11 @@ use avian3d::{math::PI, prelude::*}; use bevy::prelude::*; use bevy_trait_query::{self, RegisterExt}; -use super::{Atmosphere, Balloon, Density, ForceUpdateOrder, Force}; +use crate::{ + atmosphere::Atmosphere, + balloon::Balloon, + forces::{Density, Force, ForceUpdateOrder}, +}; pub struct AeroForcesPlugin; diff --git a/src/simulator/forces/body.rs b/src/simulator/src/forces/body.rs similarity index 95% rename from src/simulator/forces/body.rs rename to src/simulator/src/forces/body.rs index 0fee262..dbd8b48 100644 --- a/src/simulator/forces/body.rs +++ b/src/simulator/src/forces/body.rs @@ -4,8 +4,12 @@ use avian3d::{math::PI, prelude::*}; use bevy::prelude::*; use bevy_trait_query::{self, RegisterExt}; -use super::{Atmosphere, Balloon, Density, Force, ForceUpdateOrder, Mass, Volume}; -use crate::simulator::properties::{EARTH_RADIUS_M, STANDARD_G}; +use crate::{ + atmosphere::Atmosphere, + balloon::Balloon, + forces::{Density, Force, ForceUpdateOrder, Mass, Volume}, + properties::{EARTH_RADIUS_M, STANDARD_G}, +}; pub struct BodyForcesPlugin; diff --git a/src/simulator/forces/mod.rs b/src/simulator/src/forces/mod.rs similarity index 95% rename from src/simulator/forces/mod.rs rename to src/simulator/src/forces/mod.rs index 00d63ce..8f00804 100644 --- a/src/simulator/forces/mod.rs +++ b/src/simulator/src/forces/mod.rs @@ -12,7 +12,12 @@ pub use aero::Drag; #[allow(unused_imports)] pub use body::{Buoyancy, Weight}; -use super::{Atmosphere, Balloon, Density, SimulationUpdateOrder, SimState, Volume}; +use crate::{ + atmosphere::Atmosphere, + balloon::Balloon, + core::{SimulationUpdateOrder, SimState}, + properties::{Density, Volume}, +}; pub struct ForcesPlugin; impl Plugin for ForcesPlugin { diff --git a/src/simulator/forces/scratch.rs b/src/simulator/src/forces/scratch.rs similarity index 100% rename from src/simulator/forces/scratch.rs rename to src/simulator/src/forces/scratch.rs diff --git a/src/simulator/heat.rs b/src/simulator/src/heat.rs similarity index 100% rename from src/simulator/heat.rs rename to src/simulator/src/heat.rs diff --git a/src/simulator/ideal_gas.rs b/src/simulator/src/ideal_gas.rs similarity index 96% rename from src/simulator/ideal_gas.rs rename to src/simulator/src/ideal_gas.rs index 03ea96c..e6dd0aa 100644 --- a/src/simulator/ideal_gas.rs +++ b/src/simulator/src/ideal_gas.rs @@ -3,8 +3,13 @@ use avian3d::prelude::*; use bevy::prelude::*; -use super::properties::{AVOGADRO_CONSTANT, BOLTZMANN_CONSTANT}; -use super::{Atmosphere, Density, MolarMass, Pressure, SimulationUpdateOrder, Temperature, Volume}; +use crate::{ + atmosphere::Atmosphere, + core::SimulationUpdateOrder, + properties::{ + Density, MolarMass, Pressure, Temperature, Volume, AVOGADRO_CONSTANT, BOLTZMANN_CONSTANT, + }, +}; pub const R: f32 = BOLTZMANN_CONSTANT * AVOGADRO_CONSTANT; // [J/K-mol] Ideal gas constant diff --git a/src/simulator/src/lib.rs b/src/simulator/src/lib.rs new file mode 100644 index 0000000..2ad6b7d --- /dev/null +++ b/src/simulator/src/lib.rs @@ -0,0 +1,20 @@ +#![allow(unused_imports)] +mod core; +mod atmosphere; +mod balloon; +mod forces; +mod ideal_gas; +mod payload; +mod properties; +mod time; + +pub mod prelude { + pub use crate::core::{SimulatorPlugins, SimState, SimulationUpdateOrder}; + pub use crate::properties::{Density, Pressure, Temperature, Volume, MolarMass}; + pub use crate::atmosphere::Atmosphere; + pub use crate::forces::{Weight, Buoyancy, Drag, Force}; + pub use crate::balloon::{Balloon, BalloonBundle, BalloonMaterial}; + pub use crate::ideal_gas::{GasSpecies, IdealGas}; + pub use crate::payload::Payload; + pub use crate::time::TimeScaleOptions; +} diff --git a/src/simulator/mod.rs b/src/simulator/src/mod.rs similarity index 86% rename from src/simulator/mod.rs rename to src/simulator/src/mod.rs index 00b3486..19d0e48 100644 --- a/src/simulator/mod.rs +++ b/src/simulator/src/mod.rs @@ -12,7 +12,8 @@ pub mod time; pub use core::{SimulatorPlugins, SimState, SimulationUpdateOrder}; pub use properties::{Density, Pressure, Temperature, Volume, MolarMass}; pub use atmosphere::Atmosphere; -pub use forces::{Weight, Buoyancy, Drag}; +pub use forces::{Weight, Buoyancy, Drag, Force}; pub use balloon::{Balloon, BalloonBundle, BalloonMaterial}; pub use ideal_gas::{GasSpecies, IdealGas}; pub use payload::Payload; +pub use time::TimeScaleOptions; diff --git a/src/simulator/payload.rs b/src/simulator/src/payload.rs similarity index 100% rename from src/simulator/payload.rs rename to src/simulator/src/payload.rs diff --git a/src/simulator/properties.rs b/src/simulator/src/properties.rs similarity index 100% rename from src/simulator/properties.rs rename to src/simulator/src/properties.rs diff --git a/src/simulator/time.rs b/src/simulator/src/time.rs similarity index 98% rename from src/simulator/time.rs rename to src/simulator/src/time.rs index 1cc667b..234ad29 100644 --- a/src/simulator/time.rs +++ b/src/simulator/src/time.rs @@ -1,7 +1,7 @@ use avian3d::prelude::*; use bevy::prelude::*; -use super::SimState; +use crate::core::SimState; pub struct TimeScalePlugin; diff --git a/src/ui/Cargo.toml b/src/ui/Cargo.toml new file mode 100644 index 0000000..1a308ed --- /dev/null +++ b/src/ui/Cargo.toml @@ -0,0 +1,96 @@ +[package] +name = "yahs-ui" +version = "0.4.0" +description = "UI for the YAHS simulator" +edition = "2021" +authors = { workspace = true } +license = { workspace = true } + +[[bin]] +name = "yahs-ui" +path = "src/main.rs" + +[dependencies] +yahs-simulator = { path = "../simulator" } +bevy = { workspace = true, default-features = false, features = [ + "bevy_asset", + "bevy_core_pipeline", + "bevy_pbr", + "bevy_render", + "bevy_text", + "bevy_ui", + "bevy_window", + "bevy_winit", + "bevy_gizmos", + "default_font", + "png", + "tonemapping_luts", + "webgl2", +] } +avian3d = { workspace = true } +bevy-inspector-egui = { version = "0.28", optional = true, features = [ + "highlight_changes", +] } + +[features] +default = ["dev"] +dev = [ + "avian3d/debug-plugin", + "bevy/bevy_dev_tools", + "bevy/dynamic_linking", + "yahs-simulator/dev", +] +inspect = ["bevy-inspector-egui"] + +# ----------------------------------------------------------------------------- +# Some Bevy optimizations +# ----------------------------------------------------------------------------- + +# Idiomatic Bevy code often triggers these lints, and the CI workflow treats +# them as errors. In some cases they may still signal poor code quality however, +# so consider commenting out these lines. +[lints.clippy] +# Bevy supplies arguments to systems via dependency injection, so it's +# natural for systems to request more than 7 arguments -- which triggers +# this lint. +too_many_arguments = "allow" +# Queries that access many components may trigger this lint. +type_complexity = "allow" + +# Compile with Performance Optimizations: +# https://bevyengine.org/learn/quick-start/getting-started/setup/#compile-with-performance-optimizations + +# Enable a small amount of optimization in the dev profile for our code. +[profile.dev] +opt-level = 1 + +# Enable a large amount of optimization in the dev profile for dependencies. +[profile.dev.package."*"] +opt-level = 3 + +# The default profile is optimized for Wasm builds because that's what [Trunk +# reads](https://github.com/trunk-rs/trunk/issues/605). Optimize for size in the +# wasm-release profile to reduce load times and bandwidth usage on web. +[profile.release] +# Compile the entire crate as one unit. Slows compile times, marginal +# improvements. +codegen-units = 1 +# Do a second optimization pass over the entire program, including +# dependencies. Slows compile times, marginal improvements. +lto = "thin" +# Optimize with size in mind (also try "z", sometimes it is better). +# Slightly slows compile times, great improvements to file size and runtime +# performance. +opt-level = "s" +# Strip all debugging information from the binary to slightly reduce file +# size. +strip = "debuginfo" + +# Override some settings for native builds. +[profile.release-native] +# Default to release profile values. +inherits = "release" +# Optimize with performance in mind. +opt-level = 3 +# Keep debug information in the binary. +strip = "none" diff --git a/src/ui/README.md b/src/ui/README.md new file mode 100644 index 0000000..e69de29 diff --git a/src/app3d/camera.rs b/src/ui/src/camera.rs similarity index 99% rename from src/app3d/camera.rs rename to src/ui/src/camera.rs index 1319ba6..0f90a3c 100644 --- a/src/app3d/camera.rs +++ b/src/ui/src/camera.rs @@ -6,7 +6,7 @@ use bevy::{ use std::f32::consts::PI; use super::controls::{CameraControls, KeyBindingsConfig}; -use crate::simulator::Balloon; +use yahs_simulator::prelude::Balloon; pub struct CameraPlugin; diff --git a/src/app3d/controls.rs b/src/ui/src/controls.rs similarity index 98% rename from src/app3d/controls.rs rename to src/ui/src/controls.rs index 1dfbab9..b261fd0 100644 --- a/src/app3d/controls.rs +++ b/src/ui/src/controls.rs @@ -1,6 +1,6 @@ use bevy::prelude::*; -use crate::simulator::{SimState, time::TimeScaleOptions}; +use yahs_simulator::prelude::{SimState, TimeScaleOptions}; pub struct ControlsPlugin; diff --git a/src/app3d/dev_tools.rs b/src/ui/src/dev_tools.rs similarity index 97% rename from src/app3d/dev_tools.rs rename to src/ui/src/dev_tools.rs index 609e840..4f43e84 100644 --- a/src/app3d/dev_tools.rs +++ b/src/ui/src/dev_tools.rs @@ -12,7 +12,7 @@ use bevy::{ use avian3d::debug_render::*; use super::controls::KeyBindingsConfig; -use crate::simulator::{forces::Force, SimState}; +use yahs_simulator::prelude::{Force, SimState}; // Define all Show and Hide events #[derive(Event)] @@ -44,13 +44,8 @@ pub struct DevToolsPlugin; impl Plugin for DevToolsPlugin { fn build(&self, app: &mut App) { app.add_plugins(( - #[cfg(feature = "headless")] - ( - FrameTimeDiagnosticsPlugin, - EntityCountDiagnosticsPlugin, - LogDiagnosticsPlugin::default(), - ), - #[cfg(feature = "render")] + FrameTimeDiagnosticsPlugin, + EntityCountDiagnosticsPlugin, RenderedDevToolsPlugin, )); diff --git a/src/app3d/gizmos.rs b/src/ui/src/gizmos.rs similarity index 100% rename from src/app3d/gizmos.rs rename to src/ui/src/gizmos.rs diff --git a/src/ui/src/lib.rs b/src/ui/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/ui/src/main.rs b/src/ui/src/main.rs new file mode 100644 index 0000000..04c9cbd --- /dev/null +++ b/src/ui/src/main.rs @@ -0,0 +1,50 @@ +// Disable console on Windows for non-dev builds. +#![cfg_attr(not(feature = "dev"), windows_subsystem = "windows")] + +mod camera; +pub mod controls; +mod dev_tools; +mod scene; + +use camera::CameraPlugin; +use controls::ControlsPlugin; +use scene::ScenePlugin; + +#[cfg(feature = "dev")] +use dev_tools::DevToolsPlugin; + +use bevy::{ + prelude::*, + asset::AssetMetaCheck, +}; + +use yahs_simulator::prelude::SimulatorPlugins; + +fn main() { + App::new() + .add_plugins(( + DefaultPlugins + .set(AssetPlugin { + meta_check: AssetMetaCheck::Never, + ..default() + }) + .set(WindowPlugin { + primary_window: Window { + title: "🎈".to_string(), + canvas: Some("#bevy".to_string()), + fit_canvas_to_parent: true, + prevent_default_event_handling: true, + ..default() + } + .into(), + ..default() + }), + SimulatorPlugins, + ControlsPlugin, + ScenePlugin, + CameraPlugin, + #[cfg(feature = "dev")] + DevToolsPlugin, + )) + .run(); +} diff --git a/src/app3d/scene.rs b/src/ui/src/scene.rs similarity index 98% rename from src/app3d/scene.rs rename to src/ui/src/scene.rs index 582cfd1..853991c 100644 --- a/src/app3d/scene.rs +++ b/src/ui/src/scene.rs @@ -2,7 +2,7 @@ use avian3d::prelude::*; use bevy::prelude::*; use std::f32::consts::PI; -use crate::simulator::*; +use yahs_simulator::prelude::*; pub struct ScenePlugin; From 60bfc4ef325274662ae2fb83ba9fab6cdcbb764f Mon Sep 17 00:00:00 2001 From: Philip Linden Date: Sun, 15 Dec 2024 22:33:01 -0500 Subject: [PATCH 2/2] checkpoint --- Cargo.toml | 32 +++++++++---------- README.md | 17 ++-------- src/cli/Cargo.toml | 68 +++++----------------------------------- src/cli/README.md | 7 +++++ src/cli/src/main.rs | 42 +++++++++++++++++++------ src/simulator/Cargo.toml | 54 ------------------------------- src/ui/Cargo.toml | 55 +------------------------------- src/ui/src/main.rs | 3 +- 8 files changed, 67 insertions(+), 211 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8dd3790..952077a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,24 +19,24 @@ path = "src/simulator/src/lib.rs" name = "yahs" path = "src/cli/src/main.rs" -# Include the GUI binary as "yahs-ui" -[[bin]] -name = "yahs-ui" -path = "src/ui/src/main.rs" - -# These are the dependencies for the project when building it from the root +# These are the dependencies when building the CLI from the project root [dependencies] +# Simulator dependencies yahs-simulator = { path = "src/simulator" } -yahs-ui = { path = "src/ui" } -yahs-cli = { path = "src/cli" } bevy = { workspace = true } avian3d = { workspace = true } bevy-trait-query = { workspace = true } +# CLI dependencies +yahs-cli = { path = "src/cli" } +bevy_ratatui = "0.7.0" +ratatui = "0.29" +color-eyre = "0.6.3" +crossterm = "0.28.1" + [features] default = ["dev"] -dev = ["yahs-ui/dev", "yahs-cli/dev", "yahs-simulator/dev"] -inspect = ["yahs-ui/inspect"] +dev = ["yahs-cli/dev", "yahs-simulator/dev"] [workspace.package] authors = ["Philip Linden "] @@ -46,15 +46,15 @@ license = "MIT or Apache-2.0" [workspace] resolver = "2" # Important for Bevy members = [ - "src/yahs-simulator", - "src/yahs-ui", - "src/yahs-cli" + "src/simulator", + "src/cli", + "src/ui" ] [workspace.dependencies] # Shared dependencies with fixed versions bevy = { version = "0.15.0", default-features = false, features = [ - "bevy_asset", "bevy_state", "multi_threaded" + "bevy_state", "multi_threaded" ] } avian3d = { git = "https://github.com/Jondolf/avian.git", branch = "main" } bevy-trait-query = "0.7.0" @@ -84,6 +84,7 @@ opt-level = 1 # Enable a large amount of optimization in the dev profile for dependencies. [profile.dev.package."*"] opt-level = 3 +debug = false # The default profile is optimized for Wasm builds because that's what [Trunk # reads](https://github.com/trunk-rs/trunk/issues/605). Optimize for size in the @@ -92,9 +93,6 @@ opt-level = 3 # Compile the entire crate as one unit. Slows compile times, marginal # improvements. codegen-units = 1 -# Do a second optimization pass over the entire program, including -# dependencies. Slows compile times, marginal improvements. -lto = "thin" # Optimize with size in mind (also try "z", sometimes it is better). # Slightly slows compile times, great improvements to file size and runtime # performance. diff --git a/README.md b/README.md index 3570832..1854d29 100644 --- a/README.md +++ b/README.md @@ -37,28 +37,15 @@ Running this package as a standalone application compiles all of the crates and runs the CLI by default: ```bash -cargo run --workspace +cargo run ``` Force the standalone application to run the GUI instead of the CLI: ```bash -cargo run --workspace --bin yahs-ui +cargo run --bin yahs-ui ``` -Or install the standalone application to your system: - -```bash -# as a CLI -$ cargo install --path "src/cli" --release -$ yahs --help - -# as a GUI -$ cargo install --path "src/ui" --release -$ yahs-ui -``` - - ## License Except where noted (below and/or in individual files), all code in this diff --git a/src/cli/Cargo.toml b/src/cli/Cargo.toml index 717cc17..e1f8448 100644 --- a/src/cli/Cargo.toml +++ b/src/cli/Cargo.toml @@ -7,76 +7,22 @@ authors = { workspace = true } license = { workspace = true } [[bin]] -name = "yahs" +name = "yahs-cli" path = "src/main.rs" [dependencies] yahs-simulator = { path = "../simulator" } -bevy = { workspace = true, default-features = false, features = [ +bevy = { workspace = true, features = [ "bevy_state", "multi_threaded", ] } -clap = { version = "4.5.23", features = [ "env"] } -thiserror = "2.0.7" +bevy_ratatui = "0.7" +ratatui = "0.29" +crossterm = "0.28.1" +color-eyre = "0.6.3" [features] -default = ["dev"] +default = [] dev = [ - "yahs-simulator/dev", "bevy/dynamic_linking", - "bevy/bevy_dev_tools", - "clap/debug", ] - -# ----------------------------------------------------------------------------- -# Some Bevy optimizations -# ----------------------------------------------------------------------------- - -# Idiomatic Bevy code often triggers these lints, and the CI workflow treats -# them as errors. In some cases they may still signal poor code quality however, -# so consider commenting out these lines. -[lints.clippy] -# Bevy supplies arguments to systems via dependency injection, so it's -# natural for systems to request more than 7 arguments -- which triggers -# this lint. -too_many_arguments = "allow" -# Queries that access many components may trigger this lint. -type_complexity = "allow" - -# Compile with Performance Optimizations: -# https://bevyengine.org/learn/quick-start/getting-started/setup/#compile-with-performance-optimizations - -# Enable a small amount of optimization in the dev profile for our code. -[profile.dev] -opt-level = 1 - -# Enable a large amount of optimization in the dev profile for dependencies. -[profile.dev.package."*"] -opt-level = 3 - -# The default profile is optimized for Wasm builds because that's what [Trunk -# reads](https://github.com/trunk-rs/trunk/issues/605). Optimize for size in the -# wasm-release profile to reduce load times and bandwidth usage on web. -[profile.release] -# Compile the entire crate as one unit. Slows compile times, marginal -# improvements. -codegen-units = 1 -# Do a second optimization pass over the entire program, including -# dependencies. Slows compile times, marginal improvements. -lto = "thin" -# Optimize with size in mind (also try "z", sometimes it is better). -# Slightly slows compile times, great improvements to file size and runtime -# performance. -opt-level = "s" -# Strip all debugging information from the binary to slightly reduce file -# size. -strip = "debuginfo" - -# Override some settings for native builds. -[profile.release-native] -# Default to release profile values. -inherits = "release" -# Optimize with performance in mind. -opt-level = 3 -# Keep debug information in the binary. -strip = "none" diff --git a/src/cli/README.md b/src/cli/README.md index e69de29..17a7929 100644 --- a/src/cli/README.md +++ b/src/cli/README.md @@ -0,0 +1,7 @@ +# yahs-cli + +This is the CLI for the yahs project. + +```bash +cargo run --bin yahs-cli +``` diff --git a/src/cli/src/main.rs b/src/cli/src/main.rs index 1391260..0142bb0 100644 --- a/src/cli/src/main.rs +++ b/src/cli/src/main.rs @@ -1,12 +1,36 @@ -use bevy::{prelude::*, state::app::StatesPlugin}; -use yahs_simulator::prelude::SimulatorPlugins; - +use bevy::{ + app::{AppExit, ScheduleRunnerPlugin}, + prelude::*, +}; +use bevy_ratatui::{ + error::exit_on_error, event::KeyEvent, terminal::RatatuiContext, RatatuiPlugins, +}; fn main() { + let wait_duration = std::time::Duration::from_secs_f64(1. / 60.); // 60 FPS App::new() - .add_plugins(( - MinimalPlugins, - StatesPlugin, - SimulatorPlugins, - )) + .add_plugins(RatatuiPlugins::default()) + .add_plugins(ScheduleRunnerPlugin::run_loop(wait_duration)) + .add_systems(PreUpdate, keyboard_input_system) + .add_systems(Update, hello_world.pipe(exit_on_error)) .run(); -} +} + +fn hello_world(mut context: ResMut) -> color_eyre::Result<()> { + context.draw(|frame| { + let text = ratatui::text::Text::raw("hello world\nPress 'q' to Quit"); + frame.render_widget(text, frame.area()) + })?; + Ok(()) +} + +fn keyboard_input_system(mut events: EventReader, mut exit: EventWriter) { + use crossterm::event::KeyCode; + for event in events.read() { + match event.code { + KeyCode::Char('q') | KeyCode::Esc => { + exit.send_default(); + } + _ => {} + } + } +} diff --git a/src/simulator/Cargo.toml b/src/simulator/Cargo.toml index 5fac92e..261c979 100644 --- a/src/simulator/Cargo.toml +++ b/src/simulator/Cargo.toml @@ -18,58 +18,4 @@ bevy-trait-query = { workspace = true } default = [] dev = [ "bevy/dynamic_linking", - "bevy/bevy_dev_tools", ] - -# ----------------------------------------------------------------------------- -# Some Bevy optimizations -# ----------------------------------------------------------------------------- - -# Idiomatic Bevy code often triggers these lints, and the CI workflow treats -# them as errors. In some cases they may still signal poor code quality however, -# so consider commenting out these lines. -[lints.clippy] -# Bevy supplies arguments to systems via dependency injection, so it's -# natural for systems to request more than 7 arguments -- which triggers -# this lint. -too_many_arguments = "allow" -# Queries that access many components may trigger this lint. -type_complexity = "allow" - -# Compile with Performance Optimizations: -# https://bevyengine.org/learn/quick-start/getting-started/setup/#compile-with-performance-optimizations - -# Enable a small amount of optimization in the dev profile for our code. -[profile.dev] -opt-level = 1 - -# Enable a large amount of optimization in the dev profile for dependencies. -[profile.dev.package."*"] -opt-level = 3 - -# The default profile is optimized for Wasm builds because that's what [Trunk -# reads](https://github.com/trunk-rs/trunk/issues/605). Optimize for size in the -# wasm-release profile to reduce load times and bandwidth usage on web. -[profile.release] -# Compile the entire crate as one unit. Slows compile times, marginal -# improvements. -codegen-units = 1 -# Do a second optimization pass over the entire program, including -# dependencies. Slows compile times, marginal improvements. -lto = "thin" -# Optimize with size in mind (also try "z", sometimes it is better). -# Slightly slows compile times, great improvements to file size and runtime -# performance. -opt-level = "s" -# Strip all debugging information from the binary to slightly reduce file -# size. -strip = "debuginfo" - -# Override some settings for native builds. -[profile.release-native] -# Default to release profile values. -inherits = "release" -# Optimize with performance in mind. -opt-level = 3 -# Keep debug information in the binary. -strip = "none" diff --git a/src/ui/Cargo.toml b/src/ui/Cargo.toml index 1a308ed..95a7e72 100644 --- a/src/ui/Cargo.toml +++ b/src/ui/Cargo.toml @@ -33,7 +33,7 @@ bevy-inspector-egui = { version = "0.28", optional = true, features = [ ] } [features] -default = ["dev"] +default = [] dev = [ "avian3d/debug-plugin", "bevy/bevy_dev_tools", @@ -41,56 +41,3 @@ dev = [ "yahs-simulator/dev", ] inspect = ["bevy-inspector-egui"] - -# ----------------------------------------------------------------------------- -# Some Bevy optimizations -# ----------------------------------------------------------------------------- - -# Idiomatic Bevy code often triggers these lints, and the CI workflow treats -# them as errors. In some cases they may still signal poor code quality however, -# so consider commenting out these lines. -[lints.clippy] -# Bevy supplies arguments to systems via dependency injection, so it's -# natural for systems to request more than 7 arguments -- which triggers -# this lint. -too_many_arguments = "allow" -# Queries that access many components may trigger this lint. -type_complexity = "allow" - -# Compile with Performance Optimizations: -# https://bevyengine.org/learn/quick-start/getting-started/setup/#compile-with-performance-optimizations - -# Enable a small amount of optimization in the dev profile for our code. -[profile.dev] -opt-level = 1 - -# Enable a large amount of optimization in the dev profile for dependencies. -[profile.dev.package."*"] -opt-level = 3 - -# The default profile is optimized for Wasm builds because that's what [Trunk -# reads](https://github.com/trunk-rs/trunk/issues/605). Optimize for size in the -# wasm-release profile to reduce load times and bandwidth usage on web. -[profile.release] -# Compile the entire crate as one unit. Slows compile times, marginal -# improvements. -codegen-units = 1 -# Do a second optimization pass over the entire program, including -# dependencies. Slows compile times, marginal improvements. -lto = "thin" -# Optimize with size in mind (also try "z", sometimes it is better). -# Slightly slows compile times, great improvements to file size and runtime -# performance. -opt-level = "s" -# Strip all debugging information from the binary to slightly reduce file -# size. -strip = "debuginfo" - -# Override some settings for native builds. -[profile.release-native] -# Default to release profile values. -inherits = "release" -# Optimize with performance in mind. -opt-level = 3 -# Keep debug information in the binary. -strip = "none" diff --git a/src/ui/src/main.rs b/src/ui/src/main.rs index 04c9cbd..4e08fcd 100644 --- a/src/ui/src/main.rs +++ b/src/ui/src/main.rs @@ -3,8 +3,9 @@ mod camera; pub mod controls; -mod dev_tools; mod scene; +#[cfg(feature = "dev")] +mod dev_tools; use camera::CameraPlugin; use controls::ControlsPlugin;