-
Notifications
You must be signed in to change notification settings - Fork 373
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
Integrate depth clouds into Rerun #1421
Changes from 23 commits
db87ebf
ea87f88
931b468
0ee30e1
66729fe
981ddfc
90ecd3d
f8bd1fc
ad9b19e
3d79fd6
85f40ca
5e84d89
6dd8819
e564ce3
2114e22
d12a5b9
0335097
2356b33
e157911
cb9d705
7cf4fd0
6581a98
007c81b
3588352
4c0ad58
a9c1fb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
use egui::NumExt as _; | ||
use re_data_store::{query_latest_single, EditableAutoValue, EntityPath, EntityProperties}; | ||
use re_log_types::{TimeType, Transform}; | ||
use re_log_types::{ | ||
component_types::{Tensor, TensorData, TensorDataMeaning}, | ||
TimeType, Transform, | ||
}; | ||
|
||
use crate::{ | ||
ui::{view_spatial::SpatialNavigationMode, Blueprint}, | ||
|
@@ -371,8 +375,6 @@ fn entity_props_ui( | |
entity_props: &mut EntityProperties, | ||
view_state: &ViewState, | ||
) { | ||
use egui::NumExt; | ||
|
||
ui.checkbox(&mut entity_props.visible, "Visible"); | ||
ui.checkbox(&mut entity_props.interactive, "Interactive") | ||
.on_hover_text("If disabled, the entity will not react to any mouse interaction"); | ||
|
@@ -407,31 +409,135 @@ fn entity_props_ui( | |
} | ||
ui.end_row(); | ||
|
||
// pinhole_image_plane_distance | ||
if view_state.state_spatial.nav_mode == SpatialNavigationMode::ThreeD { | ||
if let Some(entity_path) = entity_path { | ||
let query = ctx.current_query(); | ||
if let Some(re_log_types::Transform::Pinhole(_)) = | ||
query_latest_single::<Transform>(&ctx.log_db.entity_db, entity_path, &query) | ||
{ | ||
ui.label("Image plane distance"); | ||
let mut distance = *entity_props.pinhole_image_plane_distance.get(); | ||
let speed = (distance * 0.05).at_least(0.01); | ||
if ui | ||
.add( | ||
egui::DragValue::new(&mut distance) | ||
.clamp_range(0.0..=1.0e8) | ||
.speed(speed), | ||
) | ||
.on_hover_text("Controls how far away the image plane is.") | ||
.changed() | ||
{ | ||
entity_props.pinhole_image_plane_distance = | ||
EditableAutoValue::UserEdited(distance); | ||
} | ||
ui.end_row(); | ||
} | ||
pinhole_props_ui(ctx, ui, entity_path, entity_props); | ||
depth_props_ui(ctx, ui, entity_path, entity_props); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
fn pinhole_props_ui( | ||
ctx: &mut ViewerContext<'_>, | ||
ui: &mut egui::Ui, | ||
entity_path: &EntityPath, | ||
entity_props: &mut EntityProperties, | ||
) { | ||
let query = ctx.current_query(); | ||
if let Some(re_log_types::Transform::Pinhole(_)) = | ||
query_latest_single::<Transform>(&ctx.log_db.entity_db, entity_path, &query) | ||
{ | ||
ui.label("Image plane distance"); | ||
let mut distance = *entity_props.pinhole_image_plane_distance.get(); | ||
let speed = (distance * 0.05).at_least(0.01); | ||
if ui | ||
.add( | ||
egui::DragValue::new(&mut distance) | ||
.clamp_range(0.0..=1.0e8) | ||
.speed(speed), | ||
) | ||
.on_hover_text("Controls how far away the image plane is.") | ||
.changed() | ||
{ | ||
entity_props.pinhole_image_plane_distance = EditableAutoValue::UserEdited(distance); | ||
} | ||
ui.end_row(); | ||
} | ||
} | ||
|
||
fn depth_props_ui( | ||
ctx: &mut ViewerContext<'_>, | ||
ui: &mut egui::Ui, | ||
entity_path: &EntityPath, | ||
entity_props: &mut EntityProperties, | ||
) { | ||
let query = ctx.current_query(); | ||
|
||
// Find closest pinhole transform, if any. | ||
let mut pinhole_ent_path = None; | ||
let mut cur_path = Some(entity_path.clone()); | ||
while let Some(path) = cur_path { | ||
if let Some(re_log_types::Transform::Pinhole(_)) = | ||
query_latest_single::<Transform>(&ctx.log_db.entity_db, &path, &query) | ||
{ | ||
pinhole_ent_path = Some(path); | ||
break; | ||
} | ||
cur_path = path.parent(); | ||
} | ||
|
||
// Early out if there's no pinhole transform upwards in the tree. | ||
let Some(pinhole_ent_path) = pinhole_ent_path else { return; }; | ||
|
||
entity_props.backproject_pinhole_ent_path = Some(pinhole_ent_path.clone()); | ||
|
||
let tensor = query_latest_single::<Tensor>(&ctx.log_db.entity_db, entity_path, &query); | ||
if tensor.as_ref().map(|t| t.meaning) == Some(TensorDataMeaning::Depth) { | ||
let tensor = tensor.as_ref().unwrap(); | ||
|
||
ui.checkbox(&mut entity_props.backproject_depth, "Backproject Depth") | ||
.on_hover_text( | ||
"If enabled, the depth texture will be backprojected into a point cloud rather \ | ||
than simply displayed as an image.", | ||
); | ||
ui.end_row(); | ||
|
||
if entity_props.backproject_depth { | ||
teh-cmc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ui.label("Pinhole"); | ||
ctx.entity_path_button(ui, None, &pinhole_ent_path) | ||
.on_hover_text( | ||
"The entity path of the pinhole transform being used to do the backprojection.", | ||
); | ||
ui.end_row(); | ||
|
||
// Compute Auto scale values | ||
let mut scale = *entity_props | ||
.backproject_scale | ||
.or(&re_data_store::EditableAutoValue::Auto( | ||
tensor.meter.map_or_else( | ||
|| match &tensor.data { | ||
TensorData::U16(_) => 1.0 / u16::MAX as f32, | ||
_ => 1.0, | ||
}, | ||
|meter| match &tensor.data { | ||
TensorData::U16(_) => 1.0 / meter * u16::MAX as f32, | ||
_ => meter, | ||
}, | ||
), | ||
)) | ||
.get(); | ||
let mut radius_scale = *entity_props | ||
.backproject_radius_scale | ||
.or(&re_data_store::EditableAutoValue::Auto(0.02)) | ||
.get(); | ||
|
||
ui.label("Backproject scale"); | ||
let speed = (scale * 0.05).at_least(0.01); | ||
ui.add( | ||
egui::DragValue::new(&mut scale) | ||
.clamp_range(0.0..=1.0e8) | ||
.speed(speed), | ||
) | ||
.on_hover_text("Scales the backprojected point cloud"); | ||
ui.end_row(); | ||
|
||
ui.label("Backproject radius scale"); | ||
let speed = (radius_scale * 0.05).at_least(0.01); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I tried it I found it a bit too sensitive still There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [out of scope] Also I noticed that units in points might be nice as well after all. That requires much deeper changes tho and I don't know how to make the ui story for that ok - probably we need to make the setting thing we have on for point & line sizes on the space view "a thing" and re-use it here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels pretty good with the new sensitivity I've just set |
||
ui.add( | ||
egui::DragValue::new(&mut radius_scale) | ||
.clamp_range(0.0..=1.0e8) | ||
.speed(speed), | ||
) | ||
.on_hover_text("Scales the radii of the points in the backprojected point cloud"); | ||
ui.end_row(); | ||
|
||
// We actually want these to update anyhow, as this might be the first tick, where we | ||
// compute the initial Auto value. | ||
entity_props.backproject_scale = EditableAutoValue::UserEdited(scale); | ||
entity_props.backproject_radius_scale = EditableAutoValue::UserEdited(radius_scale); | ||
teh-cmc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
entity_props.backproject_pinhole_ent_path = None; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given that the way you wrote the matrix up seems to be the "normal way" and that you moved out the transpose from the shader, maybe the transpose should be on
renderer/depth_cloud.rs
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm writing the matrix as if the constructor accepted rows rather than columns (cause I find it easier to read), so i should be the one transposing back no?