Skip to content

Commit

Permalink
model description inspector plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Reuben Thomas <[email protected]>
  • Loading branch information
reuben-thomas committed Jul 23, 2024
1 parent b3f232d commit c284a64
Show file tree
Hide file tree
Showing 8 changed files with 427 additions and 88 deletions.
1 change: 1 addition & 0 deletions rmf_site_editor/src/site/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ pub use util::*;

pub mod wall;
pub use wall::*;
use yaserde::ser::Config;

use crate::recency::{RecencyRank, RecencyRankingPlugin};
use crate::{AppState, RegisterIssueType};
Expand Down
6 changes: 4 additions & 2 deletions rmf_site_editor/src/site/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ use bevy::{
};
use bevy_mod_outline::OutlineMeshExt;
use rmf_site_format::{
Affiliation, AssetSource, ModelMarker, ModelProperty, NameInSite, Pending, Pose, Scale,
Affiliation, AssetSource, DifferentialDrive, ModelMarker, ModelProperty, NameInSite, Pending,
Pose, Scale,
};
use smallvec::SmallVec;
use std::any::TypeId;
use std::{any::TypeId, collections::HashMap};

#[derive(Component, Debug, Clone)]
pub struct ModelScene {
Expand Down Expand Up @@ -487,6 +488,7 @@ pub fn propagate_model_render_layers(
}
}

/// This system keeps model instances up to date with the properties of their affiliated descriptions
pub fn update_model_instances<T: Component + Default + Clone>(
mut commands: Commands,
model_properties: Query<
Expand Down
49 changes: 3 additions & 46 deletions rmf_site_editor/src/widgets/inspector/inspect_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,21 @@
*/

use crate::{
site::{
Affiliation, AssetSource, Change, DefaultFile, Group, Members, ModelProperty, NameInSite,
Scale, Texture,
},
site::{Affiliation, Change, DefaultFile, Group, Members, ModelMarker, NameInSite, Texture},
widgets::{inspector::InspectTexture, prelude::*, Inspect, SelectorWidget},
CurrentWorkspace, InspectAssetSourceComponent, InspectScaleComponent,
CurrentWorkspace,
};
use bevy::{ecs::system::SystemParam, prelude::*};
use bevy_egui::egui::{CollapsingHeader, RichText, Ui};
use rmf_site_format::RecallAssetSource;

#[derive(SystemParam)]
pub struct InspectGroup<'w, 's> {
is_group: Query<'w, 's, (), With<Group>>,
affiliation: Query<'w, 's, &'static Affiliation<Entity>>,
affiliation: Query<'w, 's, &'static Affiliation<Entity>, Without<ModelMarker>>,
names: Query<'w, 's, &'static NameInSite>,
textures: Query<'w, 's, &'static Texture>,
model_descriptions: Query<
'w,
's,
(
&'static ModelProperty<AssetSource>,
&'static ModelProperty<Scale>,
),
>,
members: Query<'w, 's, &'static Members>,
default_file: Query<'w, 's, &'static DefaultFile>,
change_asset_source: EventWriter<'w, Change<ModelProperty<AssetSource>>>,
change_scale: EventWriter<'w, Change<ModelProperty<Scale>>>,
change_texture: EventWriter<'w, Change<Texture>>,
current_workspace: Res<'w, CurrentWorkspace>,
selector: SelectorWidget<'w, 's>,
Expand Down Expand Up @@ -81,35 +67,6 @@ impl<'w, 's> InspectGroup<'w, 's> {
.root
.map(|e| self.default_file.get(e).ok())
.flatten();
if let Ok((ModelProperty(current_source), ModelProperty(current_scale))) =
self.model_descriptions.get(id)
{
ui.label(RichText::new("Model Description Properties").size(18.0));
ui.add_space(10.0);

// Asset Source
let default_file = self
.current_workspace
.root
.map(|e| self.default_file.get(e).ok())
.flatten();
if let Some(new_source) = InspectAssetSourceComponent::new(
&current_source,
&RecallAssetSource::default(),
default_file,
)
.show(ui)
{
self.change_asset_source
.send(Change::new(ModelProperty(new_source), id));
}

// Scale
if let Some(new_scale) = InspectScaleComponent::new(&current_scale).show(ui) {
self.change_scale
.send(Change::new(ModelProperty(new_scale), id));
}
}
if let Ok(texture) = self.textures.get(id) {
ui.label(RichText::new("Texture Properties").size(18.0));
if let Some(new_texture) = InspectTexture::new(texture, default_file).show(ui) {
Expand Down
Loading

0 comments on commit c284a64

Please sign in to comment.