From a472ffe470c4215d8c532fc1d2f4cd5bc2ea88f8 Mon Sep 17 00:00:00 2001 From: Philip Linden Date: Wed, 2 Jul 2025 02:13:18 -0400 Subject: [PATCH 1/2] repo: remove big_space options --- crates/buoy-physics/Cargo.toml | 4 - crates/buoy-physics/src/fluid_volume.rs | 154 --------------------- crates/buoy-physics/src/forces.rs | 5 +- crates/buoy-physics/src/grid.rs | 85 ------------ crates/buoy-physics/src/lib.rs | 5 - crates/buoy-physics/src/objects/balloon.rs | 2 - crates/buoy-runtime/Cargo.toml | 2 - crates/buoy-runtime/src/lib.rs | 7 - crates/buoy-ui/Cargo.toml | 6 - crates/buoy-ui/src/camera.rs | 52 ------- crates/buoy-ui/src/debug.rs | 10 -- 11 files changed, 1 insertion(+), 331 deletions(-) delete mode 100644 crates/buoy-physics/src/fluid_volume.rs delete mode 100644 crates/buoy-physics/src/grid.rs diff --git a/crates/buoy-physics/Cargo.toml b/crates/buoy-physics/Cargo.toml index ab0671a..84fd6ad 100644 --- a/crates/buoy-physics/Cargo.toml +++ b/crates/buoy-physics/Cargo.toml @@ -9,7 +9,6 @@ license = { workspace = true } [dependencies] bevy = { workspace = true } avian3d = { workspace = true } -big_space = { workspace = true, optional = true} uom = { workspace = true } [features] @@ -21,9 +20,6 @@ dev = [ "bevy/bevy_debug_stepping", "avian3d/bevy_diagnostic", ] -grid_space = [ - "big_space", -] # [package.metadata.mutually_exclusive_features] diff --git a/crates/buoy-physics/src/fluid_volume.rs b/crates/buoy-physics/src/fluid_volume.rs deleted file mode 100644 index 5c80369..0000000 --- a/crates/buoy-physics/src/fluid_volume.rs +++ /dev/null @@ -1,154 +0,0 @@ -use bevy::prelude::*; -use big_space::prelude::*; -use uom::si::{ - f32::*, length::meter, mass_density::kilogram_per_cubic_meter, pressure::pascal, - thermodynamic_temperature::kelvin, -}; - -use crate::atmosphere::Atmosphere; -use crate::constants::TRANSLATION_SCALE; -use crate::grid::{ - Precision, RootGrid, GRID_CELL_EDGE_LENGTH_METERS, GRID_SWITCHING_THRESHOLD_METERS, -}; - -pub(crate) fn plugin(app: &mut App) { - app.init_resource::(); -} - -/// Marks a grid that contains a fluid volume. -/// -/// FIXME: There must be a better way to do this. -#[derive(Component)] -pub struct FluidVolumeGrid; - -/// Represents a volume of fluid with physical properties. -/// Each fluid volume is its own grid, allowing for independent spatial organization -/// and property management. -#[derive(Component)] -pub struct FluidVolume { - /// Temperature in Kelvin (K) - pub temperature: ThermodynamicTemperature, - /// Pressure in Pascals (Pa) - pub pressure: Pressure, - /// Density in kg/mยณ - pub density: MassDensity, - /// Grid that defines the spatial structure of this volume - pub grid: Grid, -} - -/// Builder for creating fluid volumes with custom properties -pub struct FluidVolumeBuilder { - temperature: ThermodynamicTemperature, - pressure: Pressure, - density: MassDensity, - size: IVec3, // Number of cells in each dimension - position: Vec3, -} - -impl FluidVolumeBuilder { - /// Create a new builder with default atmospheric conditions - pub fn new() -> Self { - Self { - temperature: ThermodynamicTemperature::new::(300.0), - pressure: Pressure::new::(101325.0), - density: MassDensity::new::(1.225), - size: IVec3::new(10, 10, 10), // Default 10x10x10 grid - position: Vec3::ZERO, - } - } - - /// Set the temperature of the fluid volume - pub fn with_temperature(mut self, temperature: ThermodynamicTemperature) -> Self { - self.temperature = temperature; - self - } - - /// Set the pressure of the fluid volume - pub fn with_pressure(mut self, pressure: Pressure) -> Self { - self.pressure = pressure; - self - } - - /// Set the density of the fluid volume - pub fn with_density(mut self, density: MassDensity) -> Self { - self.density = density; - self - } - - /// Set the size of the fluid volume in grid cells - pub fn with_size(mut self, size: IVec3) -> Self { - self.size = size; - self - } - - /// Set the position of the fluid volume in world space - pub fn with_position(mut self, position: Vec3) -> Self { - self.position = position; - self - } - - /// Build and spawn the fluid volume - pub fn spawn(self, commands: &mut Commands, root_grid: Entity) { - commands.entity(root_grid).with_children(|parent| { - let mut volume_grid = parent.spawn(( - Grid::::new( - GRID_CELL_EDGE_LENGTH_METERS, - GRID_SWITCHING_THRESHOLD_METERS, - ), - FluidVolumeGrid, - Transform::from_translation(self.position), - GridCell::::default(), - )); - - let half_size = self.size / 2; - - for x in -half_size.x..half_size.x { - for y in -half_size.y..half_size.y { - for z in -half_size.z..half_size.z { - let position = Vec3::new( - x as f32 * GRID_CELL_EDGE_LENGTH_METERS, - y as f32 * GRID_CELL_EDGE_LENGTH_METERS, - z as f32 * GRID_CELL_EDGE_LENGTH_METERS, - ); - - volume_grid.with_children(|cells| { - cells.spawn(( - FluidVolumeCell { - temperature: self.temperature, - pressure: self.pressure, - density: self.density, - }, - Transform::from_translation(position), - GridCell::::default(), - )); - }); - } - } - } - }); - } -} - -#[derive(Component)] -pub struct FluidVolumeCell { - pub temperature: ThermodynamicTemperature, - pub pressure: Pressure, - pub density: MassDensity, -} - -#[derive(Resource)] -pub struct DefaultFluidVolumeSettings { - pub temperature: ThermodynamicTemperature, - pub pressure: Pressure, - pub density: MassDensity, -} - -impl Default for DefaultFluidVolumeSettings { - fn default() -> Self { - Self { - temperature: ThermodynamicTemperature::new::(300.0), - pressure: Pressure::new::(101325.0), - density: MassDensity::new::(1.225), - } - } -} diff --git a/crates/buoy-physics/src/forces.rs b/crates/buoy-physics/src/forces.rs index 748d3f7..c189ed7 100644 --- a/crates/buoy-physics/src/forces.rs +++ b/crates/buoy-physics/src/forces.rs @@ -6,10 +6,7 @@ use uom::si::{ mass_density::kilogram_per_cubic_meter, ratio::ratio, volume::cubic_meter, }; -use crate::{ - atmosphere::Atmosphere, - constants::{EARTH_RADIUS_M, STANDARD_GRAVITY}, -}; +use crate::constants::{EARTH_RADIUS_M, STANDARD_GRAVITY}; pub(crate) fn plugin(app: &mut App) { app.insert_resource(Gravity( diff --git a/crates/buoy-physics/src/grid.rs b/crates/buoy-physics/src/grid.rs deleted file mode 100644 index 2dc3bb0..0000000 --- a/crates/buoy-physics/src/grid.rs +++ /dev/null @@ -1,85 +0,0 @@ -//! Grid system for managing spatial organization and fluid volumes in the simulation. -//! -//! This module implements a hierarchical grid system using BigSpace for large-scale -//! simulations. The root grid contains the entire world, while child grids can be -//! used for specific volumes like atmospheres or oceans. -//! -//! Use child grids to specify large environment volumes, like atmosphere or ocean. -//! New spatial entities should be spawned with their own local grids. -//! Objects can move across environment boundaries so long as they are related -//! along the same branch of the hierarchy. -//! -//! The switching threshold (set to 0.0 here) determines when grid cells switch. -//! A non-zero threshold creates a "buffer zone" around cell boundaries to prevent -//! rapid switching when objects oscillate near the edge. For example: -//! -//! ```text -//! Cell 1 | Cell 2 -//! | -//! <--๐Ÿš€-->| (threshold = 0.0) -//! | -//! [===buffer zone===] (threshold > 0.0) -//! ``` -//! -//! With threshold = 0.0, the object triggers an immediate cell switch when crossing -//! the boundary. A positive threshold allows some movement past the boundary before -//! switching, preventing jitter for objects that frequently cross cell edges. - -use bevy::prelude::*; -use big_space::prelude::*; - -/// The size of grid cells in meters. This determines the spatial resolution of the grid. -/// Larger values improve performance but reduce precision. -pub const GRID_CELL_EDGE_LENGTH_METERS: f32 = 10.0; - -/// The buffer zone around grid cell boundaries in meters. This prevents rapid switching -/// when objects oscillate near cell edges. A value of 0.5 means objects can move 0.5m -/// past the boundary before switching cells. -pub const GRID_SWITCHING_THRESHOLD_METERS: f32 = 0.5; - -/// The precision type for grid coordinates. This determines the maximum size of the -/// simulation space. Higher precision types allow larger worlds but use more memory. -pub type Precision = i32; - -// Plugin setup -pub(crate) fn plugin(app: &mut App) { - // Add BigSpace plugin with selected precision - app.add_plugins(BigSpacePlugin::::default()); - - // Add startup systems - order matters! - // 1. setup_worldspace creates the root grid - // 2. spawn_fluid_volume creates fluid volumes as children of the root grid - app.add_systems(Startup, setup_worldspace); -} - -/// Creates the root grid that contains the entire simulation world. -/// This is the top-level grid in the hierarchy. All other grids and entities -/// should be children of this grid to maintain proper spatial relationships. -fn setup_worldspace(mut commands: Commands) { - let world_grid = Grid::::new( - GRID_CELL_EDGE_LENGTH_METERS, - GRID_SWITCHING_THRESHOLD_METERS, - ); - - // Spawn the root grid with necessary components - commands.spawn_big_space(world_grid, |root_grid| { - // Mark this as the root grid - root_grid.insert(RootGrid); - - // Create a starting spot entity - root_grid.spawn_spatial(( - Name::new("Starting Spot"), - StartingSpot, - FloatingOrigin, - Transform::default(), - )); - }); -} - -/// Marks the starting location of the simulation world -#[derive(Component)] -pub struct StartingSpot; - -/// Marks the root grid entity -#[derive(Component)] -pub struct RootGrid; diff --git a/crates/buoy-physics/src/lib.rs b/crates/buoy-physics/src/lib.rs index 234dc76..ca3753c 100644 --- a/crates/buoy-physics/src/lib.rs +++ b/crates/buoy-physics/src/lib.rs @@ -7,9 +7,6 @@ pub mod ideal_gas; // pub mod mesh_utils; pub mod objects; -#[cfg(feature = "grid_space")] -pub mod grid; - pub mod prelude { pub use crate::{ atmosphere::Atmosphere, @@ -34,8 +31,6 @@ impl Plugin for BuoyPhysicsPlugin { ideal_gas::plugin, forces::plugin, // mesh_utils::plugin, - #[cfg(feature = "grid_space")] - grid::plugin, )); } } diff --git a/crates/buoy-physics/src/objects/balloon.rs b/crates/buoy-physics/src/objects/balloon.rs index e4d11a7..0487ded 100644 --- a/crates/buoy-physics/src/objects/balloon.rs +++ b/crates/buoy-physics/src/objects/balloon.rs @@ -1,11 +1,9 @@ use bevy::prelude::*; -use avian3d::prelude::*; #[derive(Component, Default)] #[require(Transform)] pub struct Balloon; - impl Balloon { pub fn new() -> BalloonBundle { let balloon = Balloon; diff --git a/crates/buoy-runtime/Cargo.toml b/crates/buoy-runtime/Cargo.toml index 7fee462..7ae132b 100644 --- a/crates/buoy-runtime/Cargo.toml +++ b/crates/buoy-runtime/Cargo.toml @@ -16,7 +16,6 @@ buoy-physics = { path = "../buoy-physics" } buoy-ui = { path = "../buoy-ui", optional = true } bevy = { workspace = true } avian3d = { workspace = true } -big_space = { workspace = true, optional = true } uom = { workspace = true } bevy-inspector-egui = { version = "0.31.0", optional = true, features = [ "highlight_changes", @@ -26,7 +25,6 @@ bevy_egui = { workspace = true, optional = true } [features] default = ["dev"] dev = ["buoy-physics/dev", "bevy/dynamic_linking"] -grid_space = ["buoy-physics/grid_space", "big_space"] render = [ "bevy/bevy_render", "bevy/bevy_core_pipeline", diff --git a/crates/buoy-runtime/src/lib.rs b/crates/buoy-runtime/src/lib.rs index ace4591..5d04fe8 100644 --- a/crates/buoy-runtime/src/lib.rs +++ b/crates/buoy-runtime/src/lib.rs @@ -23,13 +23,6 @@ impl PluginGroup for BuoyDefaultPlugins { // Creature comforts group = group.add(format::PrettyPrintPlugin); - // disable TransformPlugin if grid_space feature is enabled - #[cfg(feature = "grid_space")] - { - // big_space requires TransformPlugin to be disabled - group = group.disable::(); - } - // configure headless rendering if gui feature is disabled #[cfg(not(feature = "gui"))] { diff --git a/crates/buoy-ui/Cargo.toml b/crates/buoy-ui/Cargo.toml index 19bf9ca..bfca479 100644 --- a/crates/buoy-ui/Cargo.toml +++ b/crates/buoy-ui/Cargo.toml @@ -24,7 +24,6 @@ bevy = { workspace = true, features = [ "x11", ] } avian3d = { workspace = true, optional = true, features = ["bevy_picking"] } -big_space = { workspace = true, optional = true, features = ["camera"] } bevy_egui = { workspace = true } [features] @@ -36,8 +35,3 @@ dev = [ "avian3d/debug-plugin", "bevy/bevy_dev_tools", ] -grid_space = [ - "buoy-physics/grid_space", - "big_space", - "big_space/debug", -] diff --git a/crates/buoy-ui/src/camera.rs b/crates/buoy-ui/src/camera.rs index 796c23f..f8a119f 100644 --- a/crates/buoy-ui/src/camera.rs +++ b/crates/buoy-ui/src/camera.rs @@ -1,22 +1,8 @@ use bevy::prelude::*; -#[cfg(feature = "grid_space")] -mod grid_space { - use bevy::math::DVec3; - use big_space::prelude::*; - use buoy_physics::grid::Precision; -} - const CAMERA_TARGET: Vec3 = Vec3::ZERO; pub fn plugin(app: &mut App) { - #[cfg(feature = "grid_space")] - { - app.add_plugins((big_space::camera::CameraControllerPlugin::::default(),)); - app.add_systems(PostStartup, setup_floating_camera); - app.add_systems(PostUpdate, big_space::camera::default_camera_inputs); - } - #[cfg(not(feature = "grid_space"))] { app.init_resource::() .add_systems(Startup, setup_normal_camera); @@ -26,44 +12,6 @@ pub fn plugin(app: &mut App) { #[derive(Resource, Deref, DerefMut, Default)] pub struct OriginalCameraTransform(Transform); -/// Spawns the camera in the root grid and attaches the FloatingOrigin to it. -/// -/// This system removes the previous FloatingOrigin and spawns a new one with -/// the camera. There should only be one FloatingOrigin. Any spatial entity can -/// be the floating origin. Attaching it to the camera ensures the camera will -/// never see floating point precision rendering artifacts. -#[cfg(feature = "grid_space")] -fn setup_floating_camera( - mut commands: Commands, - mut previous_origin: Query>, - // HACK: This is a hack to access the root grid and add to it. It is not - // ideal nor recommended. https://github.com/aevyrie/big_space/issues/36 - root_grid: Query<(Entity, &Grid), With>, -) { - // Remove the FloatingOrigin component from the previous origin. - let origin = previous_origin.single_mut(); - commands.entity(origin).remove::(); - - let (root_grid_id, root_grid) = root_grid.single(); - - // Spawn the camera and attach the FloatingOrigin to it. - let object_pos = DVec3::new(0.0, 10.0, 20.0); - let (object_cell, object_pos) = root_grid.translation_to_grid(object_pos); - commands - .spawn(( - Camera3d::default(), - FloatingOrigin, - object_cell, - Transform::from_translation(object_pos).looking_at(Vec3::ZERO, Vec3::Y), - big_space::camera::CameraController::default() // Built-in camera controller - .with_speed_bounds([0.1, 10.0]) - .with_smoothness(0.98, 0.98) - .with_speed(1.0), - )) - .set_parent(root_grid_id); -} - -#[cfg(not(feature = "grid_space"))] fn setup_normal_camera(mut commands: Commands) { let camera_pos = Vec3::new(-2.0, 2.5, 5.0); let camera_transform = diff --git a/crates/buoy-ui/src/debug.rs b/crates/buoy-ui/src/debug.rs index f016dcc..ad4f48c 100644 --- a/crates/buoy-ui/src/debug.rs +++ b/crates/buoy-ui/src/debug.rs @@ -5,12 +5,6 @@ use bevy::{ prelude::*, }; -#[cfg(feature = "grid_space")] -use { - big_space::{camera::CameraController, prelude::*}, - buoy_physics::grid::Precision, -}; - use crate::colors::ColorPalette; @@ -21,10 +15,6 @@ pub(crate) fn plugin(app: &mut App) { FpsOverlayPlugin::default(), TransformPathPlugin, )); - #[cfg(feature = "grid_space")] - app.add_plugins(( - FloatingOriginDebugPlugin::::default(), // Draws cell AABBs and grids - )); app.insert_resource(WireframeConfig { // The global wireframe config enables drawing of wireframes on every mesh, // except those with `NoWireframe`. Meshes with `Wireframe` will always have a wireframe, From 67c028073412198612282f5ea9b0efb5a6c980b5 Mon Sep 17 00:00:00 2001 From: philiplinden Date: Wed, 2 Jul 2025 06:14:26 +0000 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 46 ++++++++++++---------------------------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7c4436..09676f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,50 +2,28 @@ Notable changes to this project will be documented in this file. -## [0.1.0] - 2025-03-02 +## [0.2.0](https://github.com/philiplinden/buoy/compare/v0.1.0..v0.2.0) - 2025-06-27 -### ๐Ÿ“š Documentation +### ๐Ÿš€ Features -- Update readme ([`5685be7`](https://github.com/philiplinden/buoy/commit/5685be7df46da343be3b831e7e5c15e024227a1c)) -- More resources ([`696266b`](https://github.com/philiplinden/buoy/commit/696266b175e90f3e36d5de8494ef2f7977d41b43)) +- Mesh tools and a simple scene (#37) ([`d9d7bc2`](https://github.com/philiplinden/buoy/commit/d9d7bc29ad77b49017b29eb6dc673a638bddac7a)) +- Add egui side panel (#35) ([`1c5dff4`](https://github.com/philiplinden/buoy/commit/1c5dff46f16cf93c01641ddbb4625dc69aabc544)) ### โ™ป๏ธ Refactor -- Disallow dead code in most places, add placeholders for payload ([`edb98d3`](https://github.com/philiplinden/buoy/commit/edb98d3a6aff3c3633de027930e3406e3fdd3bb0)) - -### ๐ŸŽจ UI & Styling - -- Improved plots ([`6d1bba1`](https://github.com/philiplinden/buoy/commit/6d1bba1862d9be682693fe6932148195a8db3ea7)) -- Switch to egui, add plots (#15) ([`bdc6113`](https://github.com/philiplinden/buoy/commit/bdc6113a3d77993f56df5796358879371002e8f9)) -- Deconflict debug text and console screen space ([`837a626`](https://github.com/philiplinden/buoy/commit/837a626c0a4781d22150d1fe3ea12e71519d5729)) -- Add gizmos, flatten app module (#3) ([`119dade`](https://github.com/philiplinden/buoy/commit/119dade9ffb889d48ddcccb3381958bff7eae594)) -- Add a gas monitor ([`3de7b41`](https://github.com/philiplinden/buoy/commit/3de7b4167d26622d516bd4cf9a11c5c584d724b0)) -- Some debug ui practice ([`c80aa64`](https://github.com/philiplinden/buoy/commit/c80aa64d2bbd4cc2c1932889863bada2f8a1d0c2)) -- Sim state monitoring, play/pause ([`88ce33b`](https://github.com/philiplinden/buoy/commit/88ce33b46f65d1e592057e51128b995d65eb34eb)) -- Drop egui, add iyes_perf_ui ([`8cf8096`](https://github.com/philiplinden/buoy/commit/8cf8096625dd3ea4cfe98125a4f8d1d148eb5fbb)) +- Merge buoy-common with buoy-runtime (#38) ([`9e8fd7e`](https://github.com/philiplinden/buoy/commit/9e8fd7e4f29aae8f5b18840d4225965704e0b581)) +- Run headless by default (#36) ([`012f179`](https://github.com/philiplinden/buoy/commit/012f179b78804c3cd393d2d4d304e9e55befb2f9)) +- Buoy-core -> buoy-physics, add buoy-common, grid space is optional (#34) ([`a8e770e`](https://github.com/philiplinden/buoy/commit/a8e770e58c88a950f74c46a53fc069474c044607)) +- Remove python experiments (#33) ([`089042b`](https://github.com/philiplinden/buoy/commit/089042b574e39ba263ec528affa14a5448073341)) ### ๐Ÿ› Bug Fixes -- Fix up physics states ([`b311fe4`](https://github.com/philiplinden/buoy/commit/b311fe4d9e38f67e2c4fa5ee20b268da6797afe1)) - -### ๐Ÿงช Experimental - -- Scaffold things in python for prototyping (#25) ([`45f8e98`](https://github.com/philiplinden/buoy/commit/45f8e98b571bff0a2bf8aac607f6745b0cc2743c)) -- Smooth out artifacts ([`11ee325`](https://github.com/philiplinden/buoy/commit/11ee325c5d2f418f33b6db4e483ed94fb9f58709)) -- Experimenting with plots and big space ([`8a57fb7`](https://github.com/philiplinden/buoy/commit/8a57fb7f7f6ce7151209f9f8f577bf3d248b7277)) -- Experimenting with meshes and modules ([`2d75f55`](https://github.com/philiplinden/buoy/commit/2d75f5528cecac68c87851a3f5e1a4388741c1e1)) -- Forces are stable! (#14) ([`5e0dbef`](https://github.com/philiplinden/buoy/commit/5e0dbefea4e4adf7eda26d73c3f7f9eb711020ad)) +- Disable mesh utils for now and focus on headless ([`db8ac1f`](https://github.com/philiplinden/buoy/commit/db8ac1f90a3a683c5d5f7902302ff1f66faa871a)) ### โš™๏ธ Repository -- Yet another reorg - more submodules ([`2ac04de`](https://github.com/philiplinden/buoy/commit/2ac04de27df4b41f1223042e15e2c5a817b1bcb3)) -- Skip deploys ([`2db5450`](https://github.com/philiplinden/buoy/commit/2db5450b77d736bbd545dab3b71a3681782d62f9)) -- I guess docs need sound? ([`eb141a6`](https://github.com/philiplinden/buoy/commit/eb141a6a446042670815ea3cfb9a5598b7f5e036)) -- Replace cache step with the one from leafwing ([`99642d9`](https://github.com/philiplinden/buoy/commit/99642d9cd84ff8eda7d29904e2fc7c22c3fd8f08)) -- Add bevy deps ([`56ed0f3`](https://github.com/philiplinden/buoy/commit/56ed0f3d6c41e6f2b114d4cacfda22bd3e0f2a0a)) - - -## New Contributors โค๏ธ +- Refresh the changelog on pushes to main ([`26a2e6a`](https://github.com/philiplinden/buoy/commit/26a2e6a3f26df28b7d622901302cc12f579b98dc)) +- Package the bevy-ui binary for releases ([`064e94c`](https://github.com/philiplinden/buoy/commit/064e94cd37ee1a161564b2b5c04f80533033742d)) +- Include unreleased changes in log ([`c9fa447`](https://github.com/philiplinden/buoy/commit/c9fa4478d781a42c0e25d37669a5157b390f4195)) -* @philiplinden made their first contribution