diff --git a/Cargo.lock b/Cargo.lock index 6fc6b84..9ef0a43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,8 +7,10 @@ name = "Flower" version = "0.1.0" dependencies = [ "bevy", + "bevy-inspector-egui", "bevy_egui 0.27.0", "bevy_pancam", + "bevy_vector_shapes", "meval", ] @@ -179,6 +181,12 @@ dependencies = [ "libc", ] +[[package]] +name = "any_vec" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78f17bacc1bc7b91fef7b1885c10772eb2b9e4e989356f6f0f6a972240f97cd" + [[package]] name = "approx" version = "0.5.1" @@ -324,6 +332,48 @@ dependencies = [ "bevy_internal", ] +[[package]] +name = "bevy-inspector-egui" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a437cb56d4ca4d3b770889e0bd9c464cfd8e68ef370e232bd39cb4f40d880a7f" +dependencies = [ + "bevy-inspector-egui-derive", + "bevy_app", + "bevy_asset", + "bevy_core", + "bevy_core_pipeline", + "bevy_ecs", + "bevy_egui 0.27.0", + "bevy_hierarchy", + "bevy_log", + "bevy_math", + "bevy_pbr", + "bevy_reflect", + "bevy_render", + "bevy_time", + "bevy_utils", + "bevy_window", + "egui 0.27.2", + "egui-dropdown", + "fuzzy-matcher", + "image 0.24.9", + "once_cell", + "pretty-type-name", + "smallvec", +] + +[[package]] +name = "bevy-inspector-egui-derive" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "975d905908c2d621b5a55a6925ac331feac19df430e4c8818b35ef1b95142b14" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", +] + [[package]] name = "bevy_a11y" version = "0.13.2" @@ -1064,6 +1114,20 @@ dependencies = [ "syn 2.0.61", ] +[[package]] +name = "bevy_vector_shapes" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9db0755f3ecacdca38e1add345b1838eba81bd21714fbdbc1966ea28a5219ca6" +dependencies = [ + "any_vec", + "bevy", + "bitfield", + "bitflags 2.5.0", + "smallvec", + "wgpu", +] + [[package]] name = "bevy_window" version = "0.13.2" @@ -1141,6 +1205,12 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +[[package]] +name = "bitfield" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d7e60934ceec538daadb9d8432424ed043a904d8e0243f3c6446bce549a46ac" + [[package]] name = "bitflags" version = "1.3.2" @@ -1685,6 +1755,15 @@ dependencies = [ "nohash-hasher", ] +[[package]] +name = "egui-dropdown" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240e9423d44c6fd18a72208b442b1101ac871f9636c06d30cc6555d125f57db0" +dependencies = [ + "egui 0.27.2", +] + [[package]] name = "either" version = "1.11.0" @@ -1957,6 +2036,15 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "fuzzy-matcher" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54614a3312934d066701a80f20f15fa3b56d67ac7722b39eea5b4c9dd1d66c94" +dependencies = [ + "thread_local", +] + [[package]] name = "gethostname" version = "0.4.3" @@ -3055,6 +3143,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" +[[package]] +name = "pretty-type-name" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f73cdaf19b52e6143685c3606206e114a4dfa969d6b14ec3894c88eb38bd4b" + [[package]] name = "proc-macro-crate" version = "3.1.0" diff --git a/Cargo.toml b/Cargo.toml index 9ff0f3f..3e26b2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,8 @@ bevy = { version = "0.13.2" } bevy_egui = "0.27" bevy_pancam = { version = "0.11.1", features = ["bevy_egui"] } meval = "0.2" +bevy_vector_shapes = "0.7.0" +bevy-inspector-egui = "0.24" [features] block_input = ["bevy_pancam/bevy_egui"] \ No newline at end of file diff --git a/src/flower.rs b/src/flower.rs index 29f3283..b1624d2 100644 --- a/src/flower.rs +++ b/src/flower.rs @@ -1,7 +1,8 @@ use std::{f32::consts::PI, ops::Deref}; -use bevy::{prelude::*, sprite::{Mesh2dHandle, MaterialMesh2dBundle}}; +use bevy::{prelude::*, render::{render_resource::encase::rts_array::Truncate}, sprite::{MaterialMesh2dBundle, Mesh2dHandle}}; +use bevy_vector_shapes::{painter::{ShapeCommands, ShapePainter}, shapes::{LinePainter, LineSpawner}}; -use crate::{constants::PHI, ui::UiState}; +use crate::{constants::PHI, ui::UiState, Callback, FlowerComponent}; pub struct FlowerSeedPlugin; @@ -9,8 +10,8 @@ impl Plugin for FlowerSeedPlugin { fn build(&self, app: &mut App) { app .init_resource::() - .add_systems(Startup, spawn_initial_flowers) - .add_systems(Update, animate_flowers); + .add_systems(Startup, (register_systems, spawn_flower_seeds)) + .add_systems(Update, animate_flower_seeds); } } @@ -25,13 +26,15 @@ pub struct SeedSettings { pub radius: f32, pub amount: i32, pub color: Color, + pub material_handle: Option>, + pub mesh_handle: Option } impl Default for SeedSettings { fn default() -> Self { - Self { rotation: 0., distance: 4.0, radius: 4.0, amount: 50, color: Color::ORANGE} + Self { rotation: 0., distance: 4.0, radius: 4.0, amount: 50, color: Color::ORANGE, material_handle: None, mesh_handle: None } } } @@ -39,11 +42,22 @@ impl Default for SeedSettings { impl SeedSettings { pub fn default_petal() -> Self { - Self { rotation: 0., distance: 50.0, radius: 4.0, amount: 1, color: Color::ORANGE} + Self { rotation: 0., distance: 50.0, radius: 4.0, amount: 1, color: Color::ORANGE, material_handle: None, mesh_handle: None } } } +#[derive(Component)] +pub struct ResetFlowerSeeds; + +fn register_systems( + world: &mut World +) { + let spawn_id = world.register_system(spawn_flower_seeds); + world.spawn((Callback(spawn_id), ResetFlowerSeeds)); +} + +/* fn spawn_initial_flowers( mut commands: Commands, mut meshes: ResMut>, @@ -51,53 +65,74 @@ fn spawn_initial_flowers( seed_settings: Res ) { spawn_flowers(&mut commands, &mut meshes, &mut materials, seed_settings.deref()); -} +}*/ -fn animate_flowers( +fn animate_flower_seeds( mut commands: Commands, - mut meshes: ResMut>, - mut materials: ResMut>, mut seed_settings: ResMut, ui_state: Res, time: Res