Skip to content

Commit

Permalink
Merge pull request #1 from philiplinden/bevy
Browse files Browse the repository at this point in the history
Rewrite with Bevy
  • Loading branch information
philiplinden authored Nov 22, 2024
2 parents fd222e7 + 6c18c04 commit db5fc7e
Show file tree
Hide file tree
Showing 45 changed files with 2,888 additions and 2,102 deletions.
63 changes: 25 additions & 38 deletions .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,24 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Restore cargo cache
uses: actions/cache@v3

- name: Populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
sweep-cache: true

- name: Install Bevy dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev

- name: Cargo Check
run: RUSTFLAGS="$RUSTFLAGS -A dead_code" cargo check

- name: Cargo Build
run: cargo build --release --all-features
test:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Restore cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

doc:
runs-on: ubuntu-latest
needs:
Expand All @@ -63,24 +45,26 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Restore cargo cache
uses: actions/cache@v3

- name: Install Bevy dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev

- name: Populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
sweep-cache: true

- name: Cargo Doc
run: cargo doc --no-deps

- uses: actions/upload-artifact@v4
with:
name: doc
path: target/doc

deploy:
if: github.ref == 'refs/heads/main'
needs: doc
Expand All @@ -97,14 +81,17 @@ jobs:
- 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
Expand Down
120 changes: 86 additions & 34 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,101 @@
name = "yahs"
description = "Yet Another HAB Simulator"
authors = ["Philip Linden <[email protected]>"]
version = "0.2.0"
version = "0.4.0"
edition = "2021"
readme = "README.md"
license-file = "LICENSE"

[features]
default = ["gui"]
gui = [
"egui",
"egui_extras",
"egui_plot",
"eframe",
"emath",
"rfd",
default = [
# Default to a native dev build.
"dev_native",
]
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",
"iyes_perf_ui/sysinfo",
]
config-files = ["ron", "bevy_common_assets", "serde"]
inspect = ["bevy-inspector-egui", "bevy_panorbit_camera/bevy_egui"]

[dependencies]
pretty_env_logger = "0.5.0"
libm = "0.2.1"
toml = "0.8.10"
clap = { version = "4.1", default-features = false, features = [
"derive",
"std",
"help",
"usage",
"error-context",
"suggestions",
] }
csv = "1.2.1"
serde = { version = "1.0.196", features = ["derive"] }
log = { version = "0.4.20", features = ["release_max_level_debug"] }
egui = { version = "0.26.2", features = ["log", "serde"], optional = true }
egui_plot = { version = "0.26.2", features = ["serde"], optional = true }
eframe = { version = "0.26.2", features = ["persistence"], optional = true }
emath = { version = "0.26.2", optional = true }
egui_extras = { version = "0.26.2", features = [
"chrono",
"datepicker",
"file",
], optional = true }
rfd = { version = "0.14.0", optional = true }
ultraviolet = { version = "0.9.2", features = ["serde"] }
# core dependencies
bevy = "0.14.2"
bevy-trait-query = "0.6.0"
# physics dependencies
avian3d = { version = "0.1.2", features = ["debug-plugin"] }
# ui dependencies
bevy_panorbit_camera = { version = "0.20.0" }
bevy-inspector-egui = { version = "0.27.0", features = ["highlight_changes"], optional = true }
iyes_perf_ui = "0.3.0"
# file io dependencies
bevy_common_assets = { version = "0.11.0", features = ["ron"], optional = true }
ron = { version = "0.8.1", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
parry3d = { version = "0.17.2", features = ["parallel"] }

[[bin]]
name = "yahs"
path = "src/main.rs"

# -----------------------------------------------------------------------------
# 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.
[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"
21 changes: 4 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
# yet another HAB simulator

A high altitude balloon flight simulator based on [tkschuler/EarthSHAB](https://github.com/tkschuler/EarthSHAB) and [brickworks/mfc-apps](https://github.com/Brickworks/mfc-apps), built on Rust.
A high altitude balloon flight simulator based on
[tkschuler/EarthSHAB](https://github.com/tkschuler/EarthSHAB) and
[brickworks/mfc-apps](https://github.com/Brickworks/mfc-apps), built on Rust.

## Installation

```sh
cargo install --git https://github.com/Brickworks/yahs.git --features gui
yahs --help
```

## Usage (CLI)
Set the simulation configuration in `config/default.toml`

Then use the `start` command to start a flight simulation. Use the `RUST_LOG`
environment variable to specify the log level to report.

```sh
yahs start
```

## Usage (GUI)

```sh
yahs gui
```
103 changes: 103 additions & 0 deletions assets/configs/properties.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
(
gases: [
// Species of gas with a known molar mass (kg/mol)
(
name: "Air",
abbreviation: "Air",
molar_mass: 0.02897,
),
(
name: "Helium",
abbreviation: "He",
molar_mass: 0.0040026,
),
(
name: "Hydrogen",
abbreviation: "H2",
molar_mass: 0.00201594,
),
(
name: "Nitrogen",
abbreviation: "N2",
molar_mass: 0.0280134,
),
(
name: "Oxygen",
abbreviation: "O2",
molar_mass: 0.0319988,
),
(
name: "Argon",
abbreviation: "Ar",
molar_mass: 0.039948,
),
(
name: "Carbon Dioxide",
abbreviation: "CO2",
molar_mass: 0.04400995,
),
(
name: "Neon",
abbreviation: "Ne",
molar_mass: 0.020183,
),
(
name: "Krypton",
abbreviation: "Kr",
molar_mass: 0.08380,
),
(
name: "Xenon",
abbreviation: "Xe",
molar_mass: 0.13130,
),
(
name: "Methane",
abbreviation: "CH4",
molar_mass: 0.01604303,
),
],
// Properties, attributes and functions related to the material properties.
// Source: https://www.matweb.com/
materials: [
(
name: "Nothing",
max_temperature: 1e30,
density: 0.0,
emissivity: 1.0,
absorptivity: 0.0,
thermal_conductivity: 1e30,
specific_heat: 0.0,
poissons_ratio: 0.5,
elasticity: 1e30,
max_strain: 1e30,
max_stress: 1e30,
),
(
name: "Rubber",
max_temperature: 385.0,
density: 1000.0,
emissivity: 0.86,
absorptivity: 0.86,
thermal_conductivity: 0.25,
specific_heat: 1490.0,
poissons_ratio: 0.5,
elasticity: 4000000.0,
max_strain: 8.0,
max_stress: 25000000.0,
),
(
name: "LowDensityPolyethylene",
max_temperature: 348.0,
density: 919.0,
emissivity: 0.94,
absorptivity: 0.94,
thermal_conductivity: 0.3175,
specific_heat: 2600.0,
poissons_ratio: 0.5,
elasticity: 300_000_000.0,
max_strain: 6.25,
max_stress: 10_000_000.0,
),
]
)
Binary file added assets/textures/balloon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit db5fc7e

Please sign in to comment.