Skip to content

Commit

Permalink
Fix ui radius crashing graph view (#8502)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf authored Dec 17, 2024
1 parent 6b00c77 commit 49fb94f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/viewer/re_view_graph/src/visualizers/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use re_chunk::LatestAtQuery;
use re_log_types::{EntityPath, Instance};
use re_query::{clamped_zip_2x4, range_zip_1x4};
use re_types::components::{Color, Radius, ShowLabels};
use re_types::datatypes::Float32;
use re_types::{
self, archetypes,
components::{self},
Expand All @@ -23,6 +22,8 @@ pub struct NodeVisualizer {
pub data: ahash::HashMap<EntityPath, NodeData>,
}

pub const FALLBACK_RADIUS: f32 = 4.0;

/// The label information of a [`re_types::archetypes::GraphNodes`].
#[derive(Clone)]
pub enum Label {
Expand Down Expand Up @@ -120,7 +121,8 @@ impl VisualizerSystem for NodeVisualizer {
color,
},
_ => Label::Circle {
radius: radius.unwrap_or(4.0),
// Radius is negative for UI radii, but we don't handle this here.
radius: radius.unwrap_or(FALLBACK_RADIUS).abs(),
color,
},
};
Expand Down Expand Up @@ -160,7 +162,7 @@ impl TypedComponentFallbackProvider<ShowLabels> for NodeVisualizer {

impl TypedComponentFallbackProvider<Radius> for NodeVisualizer {
fn fallback_for(&self, _ctx: &QueryContext<'_>) -> Radius {
Radius(Float32(4.0f32))
FALLBACK_RADIUS.into()
}
}

Expand Down

0 comments on commit 49fb94f

Please sign in to comment.