Skip to content

Commit

Permalink
Expose ui point radii to logging & blueprint, remove old default radi…
Browse files Browse the repository at this point in the history
…us settings in favor of blueprint default components (rerun-io#6678)

### What
* Fixes rerun-io#6540


https://github.com/rerun-io/rerun/assets/1220815/07d736d9-5ba8-4563-8c70-b597e4c33a56

Also cleans up all the way down to re_renderer, removing the special
auto size values we used to check for at rendering time.

Adds 4 new code snippets: ui vs scene radius for
point2d/point3d/line2d/line3d. It can be used with even more components
but this should be enough to make it discoverable

### 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/6678?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/6678?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/6678)
- [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 Jul 2, 2024
1 parent 888e3cc commit 29eb75a
Show file tree
Hide file tree
Showing 86 changed files with 1,325 additions and 358 deletions.
4 changes: 2 additions & 2 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Update instructions:
| Crate | Description |
|-----------------------------|-------------------------------------------------------------------------------------------------------------|
| re_blueprint_tree | The UI for the blueprint tree in the left panel. |
| re_edit_ui | Provides ui editors for Rerun component data for registration with the Rerun Viewer component ui registry. |
| re_edit_ui | Provides UI editors for Rerun component data for registration with the Rerun Viewer component UI registry. |
| re_selection_panel | The UI for the selection panel. |
| re_space_view | Types & utilities for defining Space View classes and communicating with the Viewport. |
| re_space_view_bar_chart | A Space View that shows a single bar chart. |
Expand All @@ -148,7 +148,7 @@ Update instructions:
| Crate | Description |
|-----------------------|----------------------------------------------------------------------|
| re_context_menu | Support crate for context menu and actions. |
| re_data_ui | Provides ui elements for Rerun component data for the Rerun Viewer. |
| re_data_ui | Provides UI elements for Rerun component data for the Rerun Viewer. |
| re_renderer | A wgpu-based renderer for all your visualization needs. |
| re_ui | Rerun GUI theme and helpers, built around egui |
| re_viewer_context | Rerun Viewer state that is shared with the viewer's code components. |
Expand Down
16 changes: 8 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ As always there's a lot going on under the hood:
#### 🪳 Bug Fixes
- Fix silently interpreting zero time range as latest-at query [#6172](https://github.com/rerun-io/rerun/pull/6172)
- Fix not being able to click suggestions in space origin selection dropdown [#6200](https://github.com/rerun-io/rerun/pull/6200)
- Fix bug in origin selection ui [#6199](https://github.com/rerun-io/rerun/pull/6199)
- Fix bug in origin selection UI [#6199](https://github.com/rerun-io/rerun/pull/6199)
- Fix out-of-bounds crash in origin selection popup [#6202](https://github.com/rerun-io/rerun/pull/6202)
- Fix rare crash [#6251](https://github.com/rerun-io/rerun/pull/6251)
- Fix visual glitch when extending the time panel [#6255](https://github.com/rerun-io/rerun/pull/6255)
Expand All @@ -92,7 +92,7 @@ As always there's a lot going on under the hood:
- New data APIs 11: port all range-only views (plots, logs…) [#5992](https://github.com/rerun-io/rerun/pull/5992)
- New data APIs 12: port all spatial views [#5993](https://github.com/rerun-io/rerun/pull/5993)
- New data APIs 14: port everything that used to be uncached [#6035](https://github.com/rerun-io/rerun/pull/6035)
- Make visible time range ui aware of latest-at & `QueryRange` [#6176](https://github.com/rerun-io/rerun/pull/6176)
- Make visible time range UI aware of latest-at & `QueryRange` [#6176](https://github.com/rerun-io/rerun/pull/6176)
- Visible time ranges are now specified per timeline, not per timeline type [#6204](https://github.com/rerun-io/rerun/pull/6204)
- Send TCP protocol header to ignore non-rerun clients [#6253](https://github.com/rerun-io/rerun/pull/6253) (thanks [@gurry](https://github.com/gurry)!)

Expand Down Expand Up @@ -615,7 +615,7 @@ Check out our [migration guide](https://www.rerun.io/docs/reference/migration/mi
- Improve the UI for the entity query [#5022](https://github.com/rerun-io/rerun/pull/5022)
- Don't show the Blueprint header when on the welcome screen [#5046](https://github.com/rerun-io/rerun/pull/5046)
- Move Visible Time Range higher in the Selection Panel [#5036](https://github.com/rerun-io/rerun/pull/5036)
- Clean up time range ui [#5089](https://github.com/rerun-io/rerun/pull/5089)
- Clean up time range UI [#5089](https://github.com/rerun-io/rerun/pull/5089)
- Improve preview UI for Component data [#5093](https://github.com/rerun-io/rerun/pull/5093)
- Paint closest labels on top of labels further away [#5124](https://github.com/rerun-io/rerun/pull/5124)

Expand Down Expand Up @@ -760,7 +760,7 @@ Check out our [migration guide](https://www.rerun.io/docs/reference/migration/mi
- Show connection status in top bar [#4443](https://github.com/rerun-io/rerun/pull/4443)
- Add the possibility to add empty space views of all registered types [#4467](https://github.com/rerun-io/rerun/pull/4467)
- Add experimental Dataframe Space View [#4468](https://github.com/rerun-io/rerun/pull/4468)
- Show e2e latency in metric ui in top panel [#4502](https://github.com/rerun-io/rerun/pull/4502)
- Show e2e latency in metric UI in top panel [#4502](https://github.com/rerun-io/rerun/pull/4502)
- Show leading slash when formatting entity paths [#4537](https://github.com/rerun-io/rerun/pull/4537)
- Improve entity size stats: include whole subtree [#4542](https://github.com/rerun-io/rerun/pull/4542)
- Add support for modal Windows to `re_ui` and use it for the Space View entity picker [#4577](https://github.com/rerun-io/rerun/pull/4577)
Expand Down Expand Up @@ -1763,7 +1763,7 @@ here's a smaller release packed with useful improvements 🎉
- Move `Caches` to `re_viewer_ctx` and make it generic [#2043](https://github.com/rerun-io/rerun/pull/2043)
- Move time control to re_viewer_context [#2045](https://github.com/rerun-io/rerun/pull/2045)
- Move `ViewerContext` & `ComponentUiRegistry` to `viewer_context` [#2047](https://github.com/rerun-io/rerun/pull/2047)
- Move data ui to new `re_data_ui` crate [#2048](https://github.com/rerun-io/rerun/pull/2048)
- Move data UI to new `re_data_ui` crate [#2048](https://github.com/rerun-io/rerun/pull/2048)
- Use instant for `Time::now()` [#2090](https://github.com/rerun-io/rerun/pull/2090)
- Move from `instant` -> `web_time` [#2093](https://github.com/rerun-io/rerun/pull/2093)
- "namespace" flag parameters for linestrip & point cloud shader flags [#2033](https://github.com/rerun-io/rerun/pull/2033)
Expand Down Expand Up @@ -2114,7 +2114,7 @@ We now host an experimental and unpolished web-viewer at <https://app.rerun.io/>
- Allow rolling 3D camera with primary mouse button + alt modifier [#1659](https://github.com/rerun-io/rerun/pull/1659)
- Name space views after the space and indicate duplicate names [#1653](https://github.com/rerun-io/rerun/pull/1653)
- Add banner about mobile browsers being unsupported [#1674](https://github.com/rerun-io/rerun/pull/1674)
- Improve ui for tensors and color map selection [#1683](https://github.com/rerun-io/rerun/pull/1683)
- Improve UI for tensors and color map selection [#1683](https://github.com/rerun-io/rerun/pull/1683)
- Only show the mobile OS warning banner on web [#1685](https://github.com/rerun-io/rerun/pull/1685)
- Improve the depth backprojection feature [#1690](https://github.com/rerun-io/rerun/pull/1690)
- Swap overlay order of selection & hover outlines [#1705](https://github.com/rerun-io/rerun/pull/1705)
Expand All @@ -2133,7 +2133,7 @@ We now host an experimental and unpolished web-viewer at <https://app.rerun.io/>
- Warn when most of the RAM has been used up by Rerun [#1651](https://github.com/rerun-io/rerun/pull/1651)
- Apply color maps to all types of depth tensors [#1686](https://github.com/rerun-io/rerun/pull/1686)
- Size boosted outlines for points & lines, color & size tweaking [#1667](https://github.com/rerun-io/rerun/pull/1667)
- Default point radius to 1.5 ui points [#1706](https://github.com/rerun-io/rerun/pull/1706)
- Default point radius to 1.5 UI points [#1706](https://github.com/rerun-io/rerun/pull/1706)
- When streaming an rrd from http: play it, don't follow it [#1707](https://github.com/rerun-io/rerun/pull/1707)
#### 🕸️ Web
Expand Down Expand Up @@ -2311,7 +2311,7 @@ Meanwhile, we did a bunch of improvements to our manual. If you had trouble runn
* Replace `reqwest` with `ureq` [#1407](https://github.com/rerun-io/rerun/pull/1407)
* Remove derive_more dependency [#1406](https://github.com/rerun-io/rerun/pull/1406)
* Use different artifact names for wasm/js in debug builds [#1428](https://github.com/rerun-io/rerun/pull/1428)
* Separate Mac wheels & trigger wheel build from ui [#1499](https://github.com/rerun-io/rerun/pull/1499)
* Separate Mac wheels & trigger wheel build from UI [#1499](https://github.com/rerun-io/rerun/pull/1499)
* Add spell checking to CI [#1492](https://github.com/rerun-io/rerun/pull/1492)
* Repo size
* Always create new orphaned branch for gh-pages [#1490](https://github.com/rerun-io/rerun/pull/1490)
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Part of the [`rerun`](https://github.com/rerun-io/rerun) family of crates.
![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
![Apache](https://img.shields.io/badge/license-Apache-blue.svg)

Provides ui elements for Rerun component data for the Rerun Viewer.
Provides UI elements for Rerun component data for the Rerun Viewer.
2 changes: 1 addition & 1 deletion crates/re_edit_ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Part of the [`rerun`](https://github.com/rerun-io/rerun) family of crates.
![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
![Apache](https://img.shields.io/badge/license-Apache-blue.svg)

Provides ui editors for Rerun component data for registration with the Rerun Viewer component ui registry.
Provides UI editors for Rerun component data for registration with the Rerun Viewer component UI registry.
6 changes: 4 additions & 2 deletions crates/re_edit_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod color;
mod datatype_editors;
mod marker_shape;
mod material;
mod radius;
mod range1d;
mod response_utils;
mod visual_bounds2d;
Expand All @@ -20,7 +21,7 @@ use re_types::{
components::{
AggregationPolicy, AxisLength, Color, Colormap, DepthMeter, DrawOrder, FillRatio,
GammaCorrection, ImagePlaneDistance, MagnificationFilter, MarkerSize, Name, Opacity,
Radius, StrokeWidth, Text,
StrokeWidth, Text,
},
Loggable as _,
};
Expand All @@ -35,6 +36,8 @@ pub fn register_editors(registry: &mut re_viewer_context::ComponentUiRegistry) {
registry.add_singleline_editor_ui(color::edit_color_ui);
registry.add_display_ui(Color::name(), Box::new(color::display_color_ui));

registry.add_singleline_editor_ui(radius::edit_radius_ui);

registry.add_singleline_editor_ui(marker_shape::edit_marker_shape_ui);
registry.add_singleline_editor_ui(material::edit_material_ui);
registry.add_singleline_editor_ui(range1d::edit_range1d);
Expand All @@ -48,7 +51,6 @@ pub fn register_editors(registry: &mut re_viewer_context::ComponentUiRegistry) {

registry.add_singleline_editor_ui::<DepthMeter>(edit_f32_zero_to_max_float_raw);
registry.add_singleline_editor_ui::<MarkerSize>(edit_f32_zero_to_max_float_raw);
registry.add_singleline_editor_ui::<Radius>(edit_f32_zero_to_max_float_raw);
registry.add_singleline_editor_ui::<StrokeWidth>(edit_f32_zero_to_max_float_raw);

registry.add_singleline_editor_ui::<Opacity>(edit_f32_zero_to_one);
Expand Down
66 changes: 66 additions & 0 deletions crates/re_edit_ui/src/radius.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
use egui::NumExt as _;
use re_types::components::Radius;
use re_viewer_context::ViewerContext;

use crate::response_utils::response_with_changes_of_inner;

pub fn edit_radius_ui(
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
value: &mut Radius,
) -> egui::Response {
let mut abs_value = value.0.abs();
let speed = (abs_value * 0.01).at_least(0.001);

let drag_response = ui.add(
egui::DragValue::new(&mut abs_value)
.range(0.0..=f32::INFINITY)
.speed(speed),
);

let mut is_scene_units = value.scene_units().is_some();
let selected_label = label_for_unit(is_scene_units);

if ui.is_enabled() {
let combobox_response = egui::ComboBox::from_id_source("units")
.selected_text(selected_label)
.show_ui(ui, |ui| {
ui.selectable_value(&mut is_scene_units, true, label_for_unit(true))
| ui.selectable_value(&mut is_scene_units, false, label_for_unit(false))
});

if combobox_response
.inner
.as_ref()
.map_or(false, |r| r.changed())
{
// When we change the type of units,the value is likely going to be _very wrong_.
// Unfortunately, we don't have knowledge of a fallback here, so we use hardcoded "reasonable" values.
if is_scene_units {
abs_value = 0.5;
} else {
abs_value = 2.5;
};
}

if is_scene_units {
*value = Radius::new_scene_units(abs_value);
} else {
*value = Radius::new_ui_points(abs_value);
}

drag_response | response_with_changes_of_inner(combobox_response)
} else {
// Don't show the combo box drop down if this is disabled ui.
// TODO(#6661): This shouldn't happen on disabled ui, but rather when this is simply not editable.
ui.selectable_label(false, selected_label)
}
}

fn label_for_unit(is_scene_units: bool) -> &'static str {
if is_scene_units {
"scene units"
} else {
"ui points"
}
}
3 changes: 1 addition & 2 deletions crates/re_renderer/shader/depth_cloud.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ fn vs_main(@builtin(vertex_index) vertex_idx: u32) -> VertexOut {
// Span quad
let camera_distance = distance(frame.camera_position, point_data.pos_in_world);
let world_scale_factor = average_scale_from_transform(depth_cloud_info.world_from_rdf); // TODO(andreas): somewhat costly, should precompute this
let world_radius = unresolved_size_to_world(point_data.unresolved_radius, camera_distance,
frame.auto_size_points, world_scale_factor) +
let world_radius = unresolved_size_to_world(point_data.unresolved_radius, camera_distance, world_scale_factor) +
world_size_from_point_size(depth_cloud_info.radius_boost_in_ui_points, camera_distance);
let quad = sphere_or_circle_quad_span(vertex_idx, point_data.pos_in_world, world_radius, false);
out.pos_in_clip = frame.projection_from_world * vec4f(quad.pos_in_world, 1.0);
Expand Down
7 changes: 1 addition & 6 deletions crates/re_renderer/shader/global_bindings.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ struct FrameUniformBuffer {
/// (tan(fov_y / 2) * aspect_ratio, tan(fov_y /2)), i.e. half ratio of screen dimension to screen distance in x & y.
/// Both values are set to f32max for orthographic projection
tan_half_fov: vec2f,

// Size used for all point radii given with Size::AUTO.
auto_size_points: f32,

// Size used for all line radii given with Size::AUTO.
auto_size_lines: f32,
_padding: vec2f,

/// re_renderer defined device tier.
device_tier: u32,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_renderer/shader/lines.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ fn vs_main(@builtin(vertex_index) vertex_idx: u32) -> VertexOut {
}
let camera_distance = distance(camera_ray.origin, center_position);
let world_scale_factor = average_scale_from_transform(batch.world_from_obj); // TODO(andreas): somewhat costly, should precompute this
var strip_radius = unresolved_size_to_world(strip_data.unresolved_radius, camera_distance, frame.auto_size_lines, world_scale_factor);
var strip_radius = unresolved_size_to_world(strip_data.unresolved_radius, camera_distance, world_scale_factor);

// If the triangle cap is longer than the quad would be otherwise, we need to stunt it, otherwise we'd get artifacts.
var triangle_cap_length = batch.triangle_cap_length_factor * strip_radius;
Expand Down
3 changes: 1 addition & 2 deletions crates/re_renderer/shader/point_cloud.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ fn vs_main(@builtin(vertex_index) vertex_idx: u32) -> VertexOut {
// Span quad
let camera_distance = distance(frame.camera_position, point_data.pos);
let world_scale_factor = average_scale_from_transform(batch.world_from_obj); // TODO(andreas): somewhat costly, should precompute this
let world_radius = unresolved_size_to_world(point_data.unresolved_radius, camera_distance,
frame.auto_size_points, world_scale_factor) +
let world_radius = unresolved_size_to_world(point_data.unresolved_radius, camera_distance, world_scale_factor) +
world_size_from_point_size(draw_data.radius_boost_in_ui_points, camera_distance);
let quad = sphere_or_circle_quad_span(vertex_idx, point_data.pos, world_radius,
has_any_flag(batch.flags, FLAG_DRAW_AS_CIRCLES));
Expand Down
15 changes: 1 addition & 14 deletions crates/re_renderer/shader/utils/size.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,7 @@ fn world_size_from_point_size(size_in_points: f32, camera_distance: f32) -> f32
// world_size_scale:
// Scale factor that is applied iff the size is a world size.
// This is usually part of your object->world transform.
fn unresolved_size_to_world(_unresolved_size: f32, camera_distance: f32, auto_size: f32, world_size_scale: f32) -> f32 {
// Resolve auto size.
var unresolved_size: f32;
if _unresolved_size >= f32max {
// positive max for small auto size
unresolved_size = auto_size;
} else if _unresolved_size <= f32min {
// negative max for large auto size
let large_factor = 1.33;
unresolved_size = auto_size * large_factor;
} else {
unresolved_size = _unresolved_size;
}

fn unresolved_size_to_world(unresolved_size: f32, camera_distance: f32, world_size_scale: f32) -> f32 {
// Is it a world size?
if unresolved_size > 0.0 {
return unresolved_size * world_size_scale;
Expand Down
8 changes: 1 addition & 7 deletions crates/re_renderer/src/global_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@ pub struct FrameUniformBuffer {

/// (tan(fov_y / 2) * aspect_ratio, tan(fov_y /2)), i.e. half ratio of screen dimension to screen distance in x & y.
/// Both values are set to f32max for orthographic projection
pub tan_half_fov: wgpu_buffer_types::Vec2,

// Size used for all point radii given with Size::AUTO.
pub auto_size_points: f32,

// Size used for all line radii given with Size::AUTO.
pub auto_size_lines: f32,
pub tan_half_fov: wgpu_buffer_types::Vec2RowPadded,

/// re_renderer defined device tier.
pub device_tier: wgpu_buffer_types::U32RowPadded,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_renderer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub use queuable_draw_data::QueueableDrawData;
pub use rect::{RectF32, RectInt};
pub use size::Size;
pub use transform::RectTransform;
pub use view_builder::{AutoSizeConfig, ViewBuilder};
pub use view_builder::ViewBuilder;
pub use wgpu_resources::WgpuResourcePoolStatistics;

use draw_phases::DrawPhase;
Expand Down
4 changes: 3 additions & 1 deletion crates/re_renderer/src/point_cloud_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ impl<'a, 'ctx> PointCloudBatchBuilder<'a, 'ctx> {
// But it's surprisingly tricky to do this effectively.
let vertices = izip!(
positions.iter().copied(),
radii.iter().copied().chain(std::iter::repeat(Size::AUTO))
radii.iter().copied().chain(std::iter::repeat(
*radii.last().unwrap_or(&Size::ONE_UI_POINT)
))
)
.map(|(pos, radius)| PositionRadius { pos, radius })
.collect_vec();
Expand Down
2 changes: 1 addition & 1 deletion crates/re_renderer/src/renderer/lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub mod gpu_data {
impl Default for LineStripInfo {
fn default() -> Self {
Self {
radius: crate::Size::AUTO.into(),
radius: crate::Size::new_ui_points(1.5).into(),
color: Color32::WHITE,
stippling: 0,
flags: LineStripFlags::empty(),
Expand Down
Loading

0 comments on commit 29eb75a

Please sign in to comment.