From 54a5b4572313802d8b0c0ea8ef5bc34ad409aad0 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Wed, 26 Jul 2023 13:05:52 +0800 Subject: [PATCH 1/2] Fix dimensions for legacy lifts (#126) Signed-off-by: Luca Della Vedova Signed-off-by: Michael X. Grey Co-authored-by: Michael X. Grey --- rmf_site_format/src/legacy/lift.rs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/rmf_site_format/src/legacy/lift.rs b/rmf_site_format/src/legacy/lift.rs index d5d16b11..5022bd83 100644 --- a/rmf_site_format/src/legacy/lift.rs +++ b/rmf_site_format/src/legacy/lift.rs @@ -45,8 +45,14 @@ impl Lift { // TODO(MXG): Rewrite this with glam now that we've accepted it as a dependency let x = self.x as f32; let y = self.y as f32; - let d = self.depth as f32 / 2.0; - let w = self.width as f32 / 2.0; + // NOTE: Coordinate axes changed between the legacy format and the + // new format. Width used to be along the local x axis, and depth + // used to be along the local y axis, but now that is flipped to + // better align with the robotics convention of the local x axis + // being forward/backward while the local y axis is the lateral + // direction (side-to-side). + let d = self.width as f32 / 2.0; + let w = self.depth as f32 / 2.0; let theta = self.yaw as f32; let rotate = |x, y| { ( @@ -95,8 +101,14 @@ impl Lift { let dx = door.x as f32; let dy = door.y as f32; - let half_width = self.width as f32 / 2.0; - let half_depth = self.depth as f32 / 2.0; + // NOTE: Coordinate axes changed between the legacy format and the + // new format. Width used to be along the local x axis, and depth + // used to be along the local y axis, but now that is flipped to + // better align with the robotics convention of the local x axis + // being forward/backward while the local y axis is the lateral + // direction (side-to-side). + let half_width = self.depth as f32 / 2.0; + let half_depth = self.width as f32 / 2.0; let cabin_face = if dx.abs() < 1e-3 { // Very small x value means the door must be on the left or right face @@ -208,8 +220,14 @@ impl Lift { } } - let width = self.width as f32; - let depth = self.depth as f32; + // NOTE: Coordinate axes changed between the legacy format and the + // new format. Width used to be along the local x axis, and depth + // used to be along the local y axis, but now that is flipped to + // better align with the robotics convention of the local x axis + // being forward/backward while the local y axis is the lateral + // direction (side-to-side). + let width = self.depth as f32; + let depth = self.width as f32; let cabin = RectangularLiftCabin { width, depth, From d2fb61f8785e66021b56286fb64b6fda454f9ffe Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Wed, 26 Jul 2023 13:45:55 +0800 Subject: [PATCH 2/2] Hotfix for outline issue in wasm (#127) Signed-off-by: Luca Della Vedova --- rmf_site_editor/src/interaction/outline.rs | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/rmf_site_editor/src/interaction/outline.rs b/rmf_site_editor/src/interaction/outline.rs index 1d1a699e..ce81ef70 100644 --- a/rmf_site_editor/src/interaction/outline.rs +++ b/rmf_site_editor/src/interaction/outline.rs @@ -81,17 +81,20 @@ impl OutlineVisualization { } } - // A strange issue is causing outlines to diverge at certain camera angles - // for objects that use the Flat depth. The issue doesn't seem to happen - // for objects with Real depth, so we are switching most objects to use the - // Real outline setting. However, I don't think this looks good for certain - // types of objects so we will keep the Flat setting for them and accept - // that certain camera angles can make their outline look strange. - // - // The relevant upstream issue is being tracked here: https://github.com/komadori/bevy_mod_outline/issues/14 + // Flat outlines look better but are subject to glitches in wasm, use a feature flag to use + // Real outline depth in wasm and flat in other platforms. + // Tracking issue here https://github.com/komadori/bevy_mod_outline/issues/19 + // TODO(luca) revisit once issue is solved pub fn depth(&self) -> SetOutlineDepth { - SetOutlineDepth::Flat { - model_origin: Vec3::ZERO, + #[cfg(target_arch = "wasm32")] + { + SetOutlineDepth::Real + } + #[cfg(not(target_arch = "wasm32"))] + { + SetOutlineDepth::Flat { + model_origin: Vec3::ZERO, + } } }