Skip to content

Commit

Permalink
Update to Bevy 0.11 (#180)
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Michael X. Grey <grey@openrobotics.org>
Co-authored-by: Grey <grey@openrobotics.org>
  • Loading branch information
luca-della-vedova and mxgrey authored Nov 10, 2023
1 parent 66af620 commit 856c2d8
Show file tree
Hide file tree
Showing 89 changed files with 2,606 additions and 2,650 deletions.
1,363 changes: 774 additions & 589 deletions Cargo.lock

Large diffs are not rendered by default.

32 changes: 14 additions & 18 deletions rmf_site_editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,23 @@ name = "extending_site_editor"
path = "examples/extending_menu.rs"

[dependencies]
bevy_egui = "0.19"
bevy_mod_picking = "0.11"
bevy_mod_raycast = "0.7"
bevy_mod_outline = "0.3.3"
bevy_infinite_grid = "0.6"
bevy_polyline = "0.4"
bevy_stl = "0.7.0"
bevy_obj = { git = "https://github.com/luca-della-vedova/bevy_obj", branch = "luca/scene_0.9", features = ["scene"]}
bevy_rapier3d = "0.20.0"
bevy_egui = "0.21"
bevy_mod_raycast = "0.13"
bevy_mod_outline = "0.5"
bevy_infinite_grid = "0.8"
bevy_polyline = "0.7"
bevy_stl = "0.11"
bevy_obj = { version = "0.11", features = ["scene"] }
bevy_rapier3d = "0.22.0"
smallvec = "*"
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.8.23"
serde_json = "1.0"
# wasm-bindgen 0.2.85 introduces a compile error in stdweb
wasm-bindgen = "=0.2.84"
web-sys = { version = "0.3.56", features = ["console"] }
futures-lite = "1.12.0"
bevy = "0.9"
bevy_utils = "0.9"
bevy = { version = "0.11", features = ["pnm", "jpeg", "tga"] }
bevy_utils = "0.11"
dirs = "4.0"
thread_local = "*"
lyon = "1"
Expand All @@ -52,17 +50,15 @@ sdformat_rs = { git = "https://github.com/open-rmf/sdf_rust_experimental", rev =
gz-fuel = { git = "https://github.com/open-rmf/gz-fuel-rs", branch = "first_implementation" }
pathdiff = "*"

# only enable the 'dynamic' feature if we're not building for web or windows
# only enable the 'dynamic_linking' feature if we're not building for web or windows
# TODO(luca) it seems this can be enabled on windows, check
# https://bevyengine.org/learn/book/getting-started/setup/#enable-fast-compiles-optional
[target.'cfg(all(not(target_arch = "wasm32"), not(target_os = "windows")))'.dependencies]
bevy = { version = "0.9", features = ["dynamic", "jpeg", "tga"] }
bevy = { version = "0.11", features = ["dynamic_linking"] }
surf = { version = "2.3" }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
clap = { version = "4.0.10", features = ["color", "derive", "help", "usage", "suggestions"] }

# windows doesnt work well with dynamic feature yet
[target.'cfg(target_os = "windows")'.dependencies]
bevy = { version = "0.9", features = ["jpeg", "tga"] }
surf = { version = "2.3" }

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
8 changes: 4 additions & 4 deletions rmf_site_editor/src/aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn update_bounds(
mut mesh_reassigned: Query<(Entity, &Handle<Mesh>, &mut Aabb), Changed<Handle<Mesh>>>,
mut entity_mesh_map: ResMut<EntityMeshMap>,
mut mesh_events: EventReader<AssetEvent<Mesh>>,
entities_lost_mesh: RemovedComponents<Handle<Mesh>>,
mut entities_lost_mesh: RemovedComponents<Handle<Mesh>>,
) {
for entity in entities_lost_mesh.iter() {
entity_mesh_map.deregister(entity);
Expand Down Expand Up @@ -127,10 +127,10 @@ pub struct AabbUpdatePlugin;
impl Plugin for AabbUpdatePlugin {
fn build(&self, app: &mut App) {
app.init_resource::<EntityMeshMap>()
.add_system_to_stage(
CoreStage::PostUpdate,
.add_systems(
PostUpdate,
register_bounds.after(VisibilitySystems::CalculateBounds),
)
.add_system_to_stage(CoreStage::PostUpdate, update_bounds);
.add_systems(PostUpdate, update_bounds);
}
}
6 changes: 4 additions & 2 deletions rmf_site_editor/src/animate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ pub struct AnimationPlugin;

impl Plugin for AnimationPlugin {
fn build(&self, app: &mut App) {
app.add_system(update_spinning_animations)
.add_system(update_bobbing_animations);
app.add_systems(
Update,
(update_spinning_animations, update_bobbing_animations),
);
}
}
30 changes: 15 additions & 15 deletions rmf_site_editor/src/interaction/anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,25 @@ pub fn add_anchor_visual_cues(
_ => site_assets.site_anchor_mesh.clone(),
};

let mut entity_commands = commands.entity(e);
let body = entity_commands.add_children(|parent| {
let mut body = parent.spawn(PbrBundle {
let body = commands
.spawn(PbrBundle {
mesh: body_mesh,
material: site_assets.passive_anchor_material.clone(),
..default()
});
body.insert(Selectable::new(e));
if subordinate.is_none() {
body.insert(DragPlaneBundle::new(e, Vec3::Z));
}
let body = body.id();

body
});
})
.insert(Selectable::new(e))
.id();
if subordinate.is_none() {
commands
.entity(body)
.insert(DragPlaneBundle::new(e, Vec3::Z));
}

let mut entity_commands = commands.entity(e);
entity_commands
.insert(AnchorVisualization { body, drag: None })
.insert(OutlineVisualization::Anchor { body });
.insert(OutlineVisualization::Anchor { body })
.add_child(body);

// 3D anchors should always be visible with arrow cue meshes
if anchor.is_3D() {
Expand Down Expand Up @@ -184,8 +184,8 @@ pub fn update_anchor_visual_cues(
&mut AnchorVisualization,
&mut VisualCue,
Option<&Subordinate>,
ChangeTrackers<Hovered>,
ChangeTrackers<Selected>,
Ref<Hovered>,
Ref<Selected>,
),
Or<(Changed<Hovered>, Changed<Selected>, Changed<Dependents>)>,
>,
Expand Down
66 changes: 43 additions & 23 deletions rmf_site_editor/src/interaction/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl InteractionAssets {

pub fn make_axis(
&self,
command: &mut Commands,
commands: &mut Commands,
// What entity will be moved when this gizmo is dragged
for_entity_opt: Option<Entity>,
// What entity should be the parent frame of this gizmo
Expand All @@ -73,22 +73,24 @@ impl InteractionAssets {
rotation: Quat,
scale: f32,
) -> Entity {
return command.entity(parent).add_children(|parent| {
let mut child_entity = parent.spawn(PbrBundle {
let child_entity = commands
.spawn(PbrBundle {
transform: Transform::from_rotation(rotation)
.with_translation(offset)
.with_scale(Vec3::splat(scale)),
mesh: self.arrow_mesh.clone(),
material: material_set.passive.clone(),
..default()
});
})
.set_parent(parent)
.id();

if let Some(for_entity) = for_entity_opt {
child_entity
.insert(DragAxisBundle::new(for_entity, Vec3::Z).with_materials(material_set));
}
child_entity.id()
});
if let Some(for_entity) = for_entity_opt {
commands
.entity(child_entity)
.insert(DragAxisBundle::new(for_entity, Vec3::Z).with_materials(material_set));
}
child_entity
}

pub fn make_draggable_axis(
Expand Down Expand Up @@ -121,12 +123,11 @@ impl InteractionAssets {
anchor: Entity,
cue: &mut AnchorVisualization,
) {
let drag_parent = commands.entity(anchor).add_children(|parent| {
parent
.spawn(SpatialBundle::default())
.insert(VisualCue::no_outline().irregular().always_xray())
.id()
});
let drag_parent = commands
.spawn(SpatialBundle::default())
.insert(VisualCue::no_outline().irregular().always_xray())
.set_parent(anchor)
.id();

let height = 0.0;
let scale = 0.2;
Expand Down Expand Up @@ -167,12 +168,11 @@ impl InteractionAssets {
cue: &mut AnchorVisualization,
draggable: bool,
) {
let drag_parent = commands.entity(anchor).add_children(|parent| {
parent
.spawn(SpatialBundle::default())
.insert(VisualCue::no_outline().irregular().always_xray())
.id()
});
let drag_parent = commands
.spawn(SpatialBundle::default())
.insert(VisualCue::no_outline().irregular().always_xray())
.id();
commands.entity(anchor).add_child(drag_parent);

let for_entity = if draggable { Some(anchor) } else { None };
let scale = 0.2;
Expand All @@ -197,7 +197,7 @@ impl InteractionAssets {
self.make_axis(commands, for_entity, drag_parent, m, p, r, scale);
}

commands.entity(drag_parent).add_children(|parent| {
commands.entity(drag_parent).with_children(|parent| {
for (polyline, material) in &self.centimeter_finite_grid {
parent.spawn(PolylineBundle {
polyline: polyline.clone(),
Expand Down Expand Up @@ -292,20 +292,28 @@ impl FromWorld for InteractionAssets {
base_color: Color::WHITE,
alpha_mode: AlphaMode::Blend,
unlit: true,
perceptual_roughness: 0.089,
metallic: 0.01,
..default()
});
let dagger_material = materials.add(StandardMaterial {
base_color: Color::WHITE,
perceptual_roughness: 0.089,
metallic: 0.01,
..default()
});
let light_cover_color = Color::rgb(0.6, 0.7, 0.8);
let physical_light_cover_material = materials.add(StandardMaterial {
base_color: light_cover_color,
perceptual_roughness: 0.089,
metallic: 0.01,
..default()
});
let direction_light_cover_material = materials.add(StandardMaterial {
base_color: light_cover_color,
unlit: true,
perceptual_roughness: 0.089,
metallic: 0.01,
..default()
});
let x_axis_materials = GizmoMaterialSet::make_x_axis(&mut materials);
Expand All @@ -317,18 +325,24 @@ impl FromWorld for InteractionAssets {
base_color: Color::rgba(0.1, 0.9, 0.1, 0.1),
alpha_mode: AlphaMode::Blend,
unlit: true,
perceptual_roughness: 0.089,
metallic: 0.01,
..default()
}),
hover: materials.add(StandardMaterial {
base_color: Color::rgba(0.1, 0.9, 0.1, 0.9),
alpha_mode: AlphaMode::Blend,
unlit: true,
perceptual_roughness: 0.089,
metallic: 0.01,
..default()
}),
drag: materials.add(StandardMaterial {
base_color: Color::rgba(0.1, 0.9, 0.1, 0.9),
alpha_mode: AlphaMode::Blend,
unlit: true,
perceptual_roughness: 0.089,
metallic: 0.01,
..default()
}),
};
Expand All @@ -337,18 +351,24 @@ impl FromWorld for InteractionAssets {
base_color: Color::rgba(0.9, 0.1, 0.1, 0.1),
alpha_mode: AlphaMode::Blend,
unlit: true,
perceptual_roughness: 0.089,
metallic: 0.01,
..default()
}),
hover: materials.add(StandardMaterial {
base_color: Color::rgba(0.9, 0.1, 0.1, 0.9),
alpha_mode: AlphaMode::Blend,
unlit: true,
perceptual_roughness: 0.089,
metallic: 0.01,
..default()
}),
drag: materials.add(StandardMaterial {
base_color: Color::rgba(0.9, 0.1, 0.1, 0.9),
alpha_mode: AlphaMode::Blend,
unlit: true,
perceptual_roughness: 0.089,
metallic: 0.01,
..default()
}),
};
Expand Down
Loading

0 comments on commit 856c2d8

Please sign in to comment.