Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show 2D labels in 3D space views. #1641

Merged
merged 2 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/re_viewer/src/ui/view_spatial/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ pub fn create_labels(
eye3d: &Eye,
parent_ui: &mut egui::Ui,
highlights: &SpaceViewHighlights,
nav_mode: SpatialNavigationMode,
) -> Vec<egui::Shape> {
crate::profile_function!();

Expand All @@ -547,6 +548,10 @@ pub fn create_labels(
for label in &scene_ui.labels {
let (wrap_width, text_anchor_pos) = match label.target {
UiLabelTarget::Rect(rect) => {
// TODO(#1640): 2D labels are not visible in 3D for now.
if nav_mode == SpatialNavigationMode::ThreeD {
continue;
}
let rect_in_ui = ui_from_space2d.transform_rect(rect);
(
// Place the text centered below the rect
Expand All @@ -555,6 +560,10 @@ pub fn create_labels(
)
}
UiLabelTarget::Point2D(pos) => {
// TODO(#1640): 2D labels are not visible in 3D for now.
if nav_mode == SpatialNavigationMode::ThreeD {
continue;
}
let pos_in_ui = ui_from_space2d.transform_pos(pos);
(f32::INFINITY, pos_in_ui + egui::vec2(0.0, 3.0))
}
Expand Down
6 changes: 5 additions & 1 deletion crates/re_viewer/src/ui/view_spatial/ui_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use re_data_store::EntityPath;
use re_log_types::component_types::TensorTrait;
use re_renderer::view_builder::TargetConfiguration;

use super::{eye::Eye, scene::AdditionalPickingInfo, ui::create_labels, ViewSpatialState};
use super::{
eye::Eye, scene::AdditionalPickingInfo, ui::create_labels, SpatialNavigationMode,
ViewSpatialState,
};
use crate::{
misc::{HoveredSpace, Item, SpaceViewHighlights},
ui::{
Expand Down Expand Up @@ -312,6 +315,7 @@ fn view_2d_scrollable(
&eye,
parent_ui,
highlights,
SpatialNavigationMode::TwoD,
);

// Check if we're hovering any hover primitive.
Expand Down
3 changes: 2 additions & 1 deletion crates/re_viewer/src/ui/view_spatial/ui_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
scene::AdditionalPickingInfo,
ui::{create_labels, outline_config},
ui_renderer_bridge::{create_scene_paint_callback, get_viewport, ScreenBackground},
SceneSpatial, SpaceCamera3D,
SceneSpatial, SpaceCamera3D, SpatialNavigationMode,
},
SpaceViewId, UiVerbosity,
},
Expand Down Expand Up @@ -310,6 +310,7 @@ pub fn view_3d(
&eye,
ui,
highlights,
SpatialNavigationMode::ThreeD,
);

// TODO(andreas): We're very close making the hover reaction of ui2d and ui3d the same. Finish the job!
Expand Down