Skip to content

Commit

Permalink
Remove option to enable/disable depth projection from ui (#6550)
Browse files Browse the repository at this point in the history
### What

* Part of:  #5067
* Based on (for merge conflict reduction):  #6549

This will soon be handled by enabling/disabling visualizers instead.
A sideeffect of this is that the option to change the depth image
colormap also shows up in 2D views (as it should). But we're going to do
a pass over how this ui is generated soon anyways which would have also
caught this.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6550?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6550?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/6550)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
Wumpf authored Jun 13, 2024
1 parent 010ed34 commit 284c761
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 68 deletions.
12 changes: 0 additions & 12 deletions crates/re_entity_db/src/entity_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@ pub struct EntityProperties {
// TODO(#5067): Test property used so we don't have to continuously adjust existing tests while we're dismantling `EntityProperties`.
pub test_property: bool,

/// Should the depth texture be backprojected into a point cloud?
///
/// Only applies to tensors with meaning=depth that are affected by a pinhole transform.
///
/// The default for 3D views is `true`, but for 2D views it is `false`.
pub backproject_depth: EditableAutoValue<bool>, // TODO(andreas): should be a component on the DepthImage archetype.

/// How many depth units per world-space unit. e.g. 1000 for millimeters.
///
/// This corresponds to `re_components::Tensor::meter`.
Expand All @@ -121,7 +114,6 @@ impl Default for EntityProperties {
fn default() -> Self {
Self {
test_property: true,
backproject_depth: EditableAutoValue::Auto(true),
depth_from_world_scale: EditableAutoValue::Auto(1.0),
backproject_radius_scale: EditableAutoValue::Auto(1.0),
time_series_aggregator: EditableAutoValue::Auto(TimeSeriesAggregator::default()),
Expand All @@ -136,7 +128,6 @@ impl EntityProperties {
Self {
test_property: self.test_property && child.test_property,

backproject_depth: self.backproject_depth.or(&child.backproject_depth).clone(),
depth_from_world_scale: self
.depth_from_world_scale
.or(&child.depth_from_world_scale)
Expand Down Expand Up @@ -164,7 +155,6 @@ impl EntityProperties {
Self {
test_property: other.test_property,

backproject_depth: other.backproject_depth.or(&self.backproject_depth).clone(),
depth_from_world_scale: other
.depth_from_world_scale
.or(&self.depth_from_world_scale)
Expand All @@ -185,14 +175,12 @@ impl EntityProperties {
pub fn has_edits(&self, other: &Self) -> bool {
let Self {
test_property,
backproject_depth,
depth_from_world_scale,
backproject_radius_scale,
time_series_aggregator,
} = self;

test_property != &other.test_property
|| backproject_depth.has_edits(&other.backproject_depth)
|| depth_from_world_scale.has_edits(&other.depth_from_world_scale)
|| backproject_radius_scale.has_edits(&other.backproject_radius_scale)
|| time_series_aggregator.has_edits(&other.time_series_aggregator)
Expand Down
46 changes: 13 additions & 33 deletions crates/re_selection_panel/src/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1416,41 +1416,21 @@ fn depth_props_ui(
.latest_at_component_at_closest_ancestor::<PinholeProjection>(entity_path, &query)?
.0;

let mut backproject_depth = *entity_props.backproject_depth;

if ui
.re_checkbox(&mut 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.",
)
.changed()
{
entity_props.backproject_depth = EditableAutoValue::UserEdited(backproject_depth);
}
ui.label("Pinhole");
item_ui::entity_path_button(
ctx.viewer_ctx,
&query,
db,
ui,
None,
&image_projection_ent_path,
)
.on_hover_text("The entity path of the pinhole transform being used to do the backprojection.");
ui.end_row();

if backproject_depth {
ui.label("Pinhole");
item_ui::entity_path_button(
ctx.viewer_ctx,
&query,
db,
ui,
None,
&image_projection_ent_path,
)
.on_hover_text(
"The entity path of the pinhole transform being used to do the backprojection.",
);
ui.end_row();

depth_from_world_scale_ui(ui, &mut entity_props.depth_from_world_scale);

backproject_radius_scale_ui(ui, &mut entity_props.backproject_radius_scale);

colormap_props_ui(ctx, ui, data_result);
}
depth_from_world_scale_ui(ui, &mut entity_props.depth_from_world_scale);
backproject_radius_scale_ui(ui, &mut entity_props.backproject_radius_scale);
colormap_props_ui(ctx, ui, data_result);

Some(())
}
Expand Down
12 changes: 1 addition & 11 deletions crates/re_space_view_spatial/src/heuristics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,13 @@ use crate::{
pub fn generate_auto_legacy_properties(
ctx: &ViewerContext<'_>,
per_system_entities: &PerSystemEntities,
spatial_kind: SpatialSpaceViewKind,
) -> re_entity_db::EntityPropertyMap {
re_tracing::profile_function!();

let mut auto_properties = re_entity_db::EntityPropertyMap::default();

// Do pinhole properties before, since they may be used in transform3d heuristics.
update_depth_cloud_property_heuristics(
ctx,
per_system_entities,
&mut auto_properties,
spatial_kind,
);
update_depth_cloud_property_heuristics(ctx, per_system_entities, &mut auto_properties);

auto_properties
}
Expand Down Expand Up @@ -67,7 +61,6 @@ fn update_depth_cloud_property_heuristics(
ctx: &ViewerContext<'_>,
per_system_entities: &PerSystemEntities,
auto_properties: &mut re_entity_db::EntityPropertyMap,
spatial_kind: SpatialSpaceViewKind,
) {
// TODO(andreas): There should be a depth cloud system
for ent_path in per_system_entities
Expand All @@ -92,9 +85,6 @@ fn update_depth_cloud_property_heuristics(
.map(|meter| meter.value.0);

let mut properties = auto_properties.get(ent_path);
properties.backproject_depth = EditableAutoValue::Auto(
meaning == TensorDataMeaning::Depth && spatial_kind == SpatialSpaceViewKind::ThreeD,
);

if meaning == TensorDataMeaning::Depth {
let auto = meter.unwrap_or_else(|| {
Expand Down
3 changes: 1 addition & 2 deletions crates/re_space_view_spatial/src/view_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ impl SpaceViewClass for SpatialSpaceView2D {
let Ok(_state) = state.downcast_mut::<SpatialSpaceViewState>() else {
return;
};
*auto_properties =
generate_auto_legacy_properties(ctx, ent_paths, SpatialSpaceViewKind::TwoD);
*auto_properties = generate_auto_legacy_properties(ctx, ent_paths);
}

fn spawn_heuristics(
Expand Down
3 changes: 1 addition & 2 deletions crates/re_space_view_spatial/src/view_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,7 @@ impl SpaceViewClass for SpatialSpaceView3D {
let Ok(_state) = state.downcast_mut::<SpatialSpaceViewState>() else {
return;
};
*auto_properties =
generate_auto_legacy_properties(ctx, ent_paths, SpatialSpaceViewKind::ThreeD);
*auto_properties = generate_auto_legacy_properties(ctx, ent_paths);
}

fn selection_ui(
Expand Down
16 changes: 9 additions & 7 deletions crates/re_space_view_spatial/src/visualizers/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,15 @@ impl ImageVisualizer {
return;
}

let is_3d_view =
ent_context.space_view_class_identifier == SpatialSpaceView3D::identifier();

// Parent pinhole should only be relevant to 3D views
let parent_pinhole_path =
if ent_context.space_view_class_identifier == SpatialSpaceView3D::identifier() {
transforms.parent_pinhole(entity_path)
} else {
None
};
let parent_pinhole_path = if is_3d_view {
transforms.parent_pinhole(entity_path)
} else {
None
};

let meaning = TensorDataMeaning::Depth;

Expand Down Expand Up @@ -462,7 +464,7 @@ impl ImageVisualizer {
.copied()
.unwrap_or_else(|| self.fallback_for(ctx));

if *ent_props.backproject_depth {
if is_3d_view {
if let Some(parent_pinhole_path) = transforms.parent_pinhole(entity_path) {
// NOTE: we don't pass in `world_from_obj` because this corresponds to the
// transform of the projection plane, which is of no use to us here.
Expand Down
6 changes: 5 additions & 1 deletion rerun_py/rerun_sdk/rerun/components/colormap.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 284c761

Please sign in to comment.