diff --git a/Cargo.lock b/Cargo.lock index 4c9847d4..f5c566d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -732,6 +732,23 @@ dependencies = [ "thiserror", ] +[[package]] +name = "bevy_gltf_export" +version = "0.1.0" +source = "git+https://github.com/luca-della-vedova/bevy_gltf_export?branch=luca/transform_api#a896bca4148648b44212d4a9e6be98dd64cc3d8f" +dependencies = [ + "bevy_asset", + "bevy_pbr", + "bevy_render", + "bevy_transform", + "gltf", + "gltf-json", + "image", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "bevy_hierarchy" version = "0.12.1" @@ -1300,6 +1317,12 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + [[package]] name = "bitfield" version = "0.14.0" @@ -1830,6 +1853,12 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-common" version = "0.1.6" @@ -2116,6 +2145,22 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "exr" +version = "1.72.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "887d93f60543e9a9362ef8a21beedd0a833c5d9610e18c67abe15a5963dcb1a4" +dependencies = [ + "bit_field", + "flume", + "half", + "lebe", + "miniz_oxide", + "rayon-core", + "smallvec", + "zune-inflate", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -2177,6 +2222,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8" +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "spin", +] + [[package]] name = "fnv" version = "1.0.7" @@ -2375,6 +2429,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gif" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2" +dependencies = [ + "color_quant", + "weezl", +] + [[package]] name = "gilrs" version = "0.10.4" @@ -2637,16 +2701,27 @@ dependencies = [ [[package]] name = "gz-fuel" version = "0.1.0" -source = "git+https://github.com/open-rmf/gz-fuel-rs?branch=luca/ehttp#44b3fc616146a9f0b32652ba9a9fe34eaf40a629" +source = "git+https://github.com/open-rmf/gz-fuel-rs?branch=main#cbdb4b587834ac9af78d0018c6dcd9ab3efd3cb2" dependencies = [ + "crossbeam-channel", "dirs", "ehttp", - "futures-lite 2.2.0", - "itertools 0.12.1", + "futures-lite 1.13.0", + "itertools 0.11.0", "serde", "serde_json", ] +[[package]] +name = "half" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if", + "crunchy", +] + [[package]] name = "hash32" version = "0.2.1" @@ -2808,9 +2883,12 @@ dependencies = [ "bytemuck", "byteorder", "color_quant", + "exr", + "gif", "jpeg-decoder", "num-traits", "png", + "qoi", "tiff", ] @@ -2948,6 +3026,9 @@ name = "jpeg-decoder" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" +dependencies = [ + "rayon", +] [[package]] name = "js-sys" @@ -2990,6 +3071,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +[[package]] +name = "lebe" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" + [[package]] name = "lewton" version = "0.10.2" @@ -3157,15 +3244,6 @@ dependencies = [ "paste", ] -[[package]] -name = "minidom" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f45614075738ce1b77a1768912a60c0227525971b03e09122a05b8a34a2a6278" -dependencies = [ - "rxml", -] - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -3898,6 +3976,15 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + [[package]] name = "quote" version = "1.0.35" @@ -3961,6 +4048,26 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "rectangle-pack" version = "0.4.2" @@ -4096,6 +4203,7 @@ version = "0.0.1" dependencies = [ "bevy", "bevy_egui", + "bevy_gltf_export", "bevy_infinite_grid", "bevy_mod_outline", "bevy_mod_raycast", @@ -4129,6 +4237,7 @@ dependencies = [ "urdf-rs", "utm", "wasm-bindgen", + "yaserde", ] [[package]] @@ -4138,14 +4247,17 @@ dependencies = [ "bevy", "float_eq", "glam", + "once_cell", "pathdiff", "ron", + "sdformat_rs", "serde", "serde_json", "serde_yaml", "thiserror", "urdf-rs", "uuid", + "yaserde", ] [[package]] @@ -4263,23 +4375,6 @@ dependencies = [ "twox-hash", ] -[[package]] -name = "rxml" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a98f186c7a2f3abbffb802984b7f1dfd65dac8be1aafdaabbca4137f53f0dff7" -dependencies = [ - "bytes", - "rxml_validation", - "smartstring", -] - -[[package]] -name = "rxml_validation" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a197350ece202f19a166d1ad6d9d6de145e1d2a8ef47db299abe164dbd7530" - [[package]] name = "ryu" version = "1.0.17" @@ -4313,10 +4408,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sdformat_rs" version = "0.1.0" -source = "git+https://github.com/open-rmf/sdf_rust_experimental?rev=a5daef0#a5daef0c03380e55cfdaba507c89883a87127a05" +source = "git+https://github.com/open-rmf/sdf_rust_experimental?rev=9fc35f2#9fc35f2b5f55afab37a4c1906c395fc22d069322" dependencies = [ "convert_case", - "minidom", "nalgebra", "xmltree", "yaserde", @@ -4469,17 +4563,6 @@ dependencies = [ "serde", ] -[[package]] -name = "smartstring" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" -dependencies = [ - "autocfg", - "static_assertions", - "version_check", -] - [[package]] name = "smol_str" version = "0.2.1" @@ -5834,3 +5917,12 @@ name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] diff --git a/rmf_site_editor/Cargo.toml b/rmf_site_editor/Cargo.toml index 51656c27..371dd17a 100644 --- a/rmf_site_editor/Cargo.toml +++ b/rmf_site_editor/Cargo.toml @@ -21,6 +21,7 @@ bevy_mod_raycast = "0.16" bevy_mod_outline = "0.6" # PR merged after 0.10 but not released yet, bump to 0.10.1 once merged bevy_infinite_grid = { git = "https://github.com/ForesightMiningSoftwareCorporation/bevy_infinite_grid", rev = "86018dd" } +bevy_gltf_export = { git = "https://github.com/luca-della-vedova/bevy_gltf_export", branch = "luca/transform_api"} bevy_polyline = "0.8.1" bevy_stl = "0.12" bevy_obj = { version = "0.12.1", features = ["scene"] } @@ -43,9 +44,10 @@ tracing = "0.1.37" tracing-subscriber = "0.3.1" rfd = "0.12" urdf-rs = "0.7" +yaserde = "0.7" utm = "0.1.6" -sdformat_rs = { git = "https://github.com/open-rmf/sdf_rust_experimental", rev = "a5daef0"} -gz-fuel = { git = "https://github.com/open-rmf/gz-fuel-rs", branch = "luca/ehttp" } +sdformat_rs = { git = "https://github.com/open-rmf/sdf_rust_experimental", rev = "9fc35f2"} +gz-fuel = { git = "https://github.com/open-rmf/gz-fuel-rs", branch = "main" } pathdiff = "*" tera = "1.19.1" ehttp = { version = "0.4", features = ["native-async"] } diff --git a/rmf_site_editor/examples/extending_menu.rs b/rmf_site_editor/examples/extending_menu.rs index 6f3f6442..82510145 100644 --- a/rmf_site_editor/examples/extending_menu.rs +++ b/rmf_site_editor/examples/extending_menu.rs @@ -84,5 +84,7 @@ impl Plugin for MyMenuPlugin { /// Lets embed site editor in our application with our own plugin fn main() { - App::new().add_plugins((SiteEditor, MyMenuPlugin)).run(); + App::new() + .add_plugins((SiteEditor::default(), MyMenuPlugin)) + .run(); } diff --git a/rmf_site_editor/src/aabb.rs b/rmf_site_editor/src/aabb.rs index 1a42323d..6bf91f1a 100644 --- a/rmf_site_editor/src/aabb.rs +++ b/rmf_site_editor/src/aabb.rs @@ -17,10 +17,12 @@ use bevy::{ use smallvec::SmallVec; /// Tracks which [`Entities`](Entity) have which meshes for entities whose [`Aabb`]s are managed by -/// the [`calculate_bounds`] and [`update_bounds`] systems. This is needed because `update_bounds` +/// the [`calculate_bounds`][1] and [`update_bounds`] systems. This is needed because `update_bounds` /// recomputes `Aabb`s for entities whose mesh has been mutated. These mutations are visible via /// [`AssetEvent`](AssetEvent) which tells us which mesh was changed but not which entities /// have that mesh. +/// +/// [1]: bevy::render::view::calculate_bounds #[derive(Debug, Default, Clone, Resource)] pub struct EntityMeshMap { entities_with_mesh: HashMap, SmallVec<[Entity; 1]>>, @@ -76,8 +78,6 @@ pub fn register_bounds( /// Updates [`Aabb`]s for [`Entities`](Entity) with [`Mesh`]es. This includes `Entities` that have /// been assigned new `Mesh`es as well as `Entities` whose `Mesh` has been directly mutated. /// -/// To opt out of bound calculation for an `Entity`, give it the [`NoAabbUpdate`] component. -/// /// NOTE: This system needs to remove entities from their collection in /// [`EntityMeshMap`] whenever a mesh handle is reassigned or an entity's mesh handle is /// removed. This may impact performance if meshes with many entities are frequently diff --git a/rmf_site_editor/src/autoload.rs b/rmf_site_editor/src/autoload.rs new file mode 100644 index 00000000..5608e5f0 --- /dev/null +++ b/rmf_site_editor/src/autoload.rs @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2024 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +use bevy::prelude::*; +use std::path::PathBuf; + +#[derive(Resource)] +pub struct Autoload { + pub filename: Option, + pub import: Option, +} + +impl Autoload { + pub fn file(filename: PathBuf, import: Option) -> Self { + Autoload { + filename: Some(filename), + import, + } + } +} diff --git a/rmf_site_editor/src/interaction/camera_controls/keyboard.rs b/rmf_site_editor/src/interaction/camera_controls/keyboard.rs index f3bf6aa1..453ad092 100644 --- a/rmf_site_editor/src/interaction/camera_controls/keyboard.rs +++ b/rmf_site_editor/src/interaction/camera_controls/keyboard.rs @@ -19,7 +19,7 @@ use super::{ utils::*, CameraCommandType, CameraControls, ProjectionMode, MAX_FOV, MAX_SCALE, MIN_FOV, MIN_SCALE, }; -use crate::widgets::UncoveredWindow; +use crate::widgets::UserCameraDisplay; use bevy::{prelude::*, window::PrimaryWindow}; use bevy_mod_raycast::immediate::Raycast; @@ -85,7 +85,7 @@ pub fn update_keyboard_command( immediate_raycast: Raycast, time: Res