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

Fix crash on negative radii by instead warning #1654

Merged
merged 2 commits into from
Mar 21, 2023
Merged
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
29 changes: 22 additions & 7 deletions crates/re_viewer/src/ui/view_spatial/scene/scene_part/points3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,27 @@ impl Points3DPart {
Ok(colors)
}

fn process_radii(
entity_view: &EntityView<Point3D>,
) -> Result<impl Iterator<Item = Size> + '_, QueryError> {
Ok(entity_view
.iter_component::<Radius>()?
.map(|radius| radius.map_or(Size::AUTO, |r| Size::new_scene(r.0))))
fn process_radii<'view>(
ent_path: &EntityPath,
entity_view: &'view EntityView<Point3D>,
) -> Result<impl Iterator<Item = Size> + 'view, QueryError> {
let ent_path = ent_path.clone();
Ok(entity_view.iter_component::<Radius>()?.map(move |radius| {
radius.map_or(Size::AUTO, |r| {
if 0.0 <= r.0 && r.0.is_finite() {
Size::new_scene(r.0)
} else {
if r.0 < 0.0 {
re_log::warn_once!("Found point with negative radius in entity {ent_path}");
} else if r.0.is_infinite() {
re_log::warn_once!("Found point with infinite radius in entity {ent_path}");
} else {
re_log::warn_once!("Found point with NaN radius in entity {ent_path}");
}
Size::AUTO
}
})
}))
}

fn process_labels<'a>(
Expand Down Expand Up @@ -178,7 +193,7 @@ impl Points3DPart {
};

let colors = Self::process_colors(entity_view, ent_path, &annotation_infos)?;
let radii = Self::process_radii(entity_view)?;
let radii = Self::process_radii(ent_path, entity_view)?;

if show_labels && instance_path_hashes_for_picking.len() <= self.max_labels {
// Max labels is small enough that we can afford iterating on the colors again.
Expand Down