Skip to content

Commit

Permalink
Update walkers to 0.26 (rerun-io#7929)
Browse files Browse the repository at this point in the history
### What

Updates walkers to 0.26
- Changes the `Plugin` API (which unblocks making entities
coverable/selectable, etc)
- Changes the zoom level from f32 to f64
- Bonus: that new version uses one-less-zoom-level tiles to fill in
while full-res tile are downloading, and it makes a hell of a
difference.

### 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/7929?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/7929?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)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7929)
- [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
abey79 authored Oct 29, 2024
1 parent 8ddcdc5 commit d6a3ed6
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 45 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8794,9 +8794,9 @@ dependencies = [

[[package]]
name = "walkers"
version = "0.25.0"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "836a94019e3577a09c8d14077be3e9caf328e9047c2ce297e8f5c6b08855ee8f"
checksum = "7193ce72e3e6a0a2910b60596a444ac0af9d1a76e4cc47ab3e238cd5c2ff84ba"
dependencies = [
"egui",
"egui_extras",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ table ZoomLevel (
"attr.docs.unreleased"
) {
/// Zoom level: 0 being the lowest zoom level (fully zoomed out) and 22 being the highest (fully zoomed in).
zoom: rerun.datatypes.Float32 (order: 100);
zoom: rerun.datatypes.Float64 (order: 100);
}
24 changes: 12 additions & 12 deletions crates/store/re_types/src/blueprint/components/zoom_level.rs

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

21 changes: 21 additions & 0 deletions crates/viewer/re_component_ui/src/datatype_uis/float_drag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,24 @@ fn edit_f32_zero_to_one_raw(ui: &mut egui::Ui, value: &mut MaybeMutRef<'_, f32>)
ui.label(re_format::format_f32(**value))
}
}

// ---

/// Non monomorphized implementation for f64 float editing with a given speed.
pub fn edit_f64_float_raw_with_speed_impl(
ui: &mut egui::Ui,
value: &mut MaybeMutRef<'_, f64>,
range: RangeInclusive<f64>,
speed: f64,
) -> egui::Response {
if let Some(value) = value.as_mut() {
ui.add(
egui::DragValue::new(value)
.clamp_existing_to_range(false)
.range(range)
.speed(speed),
)
} else {
ui.label(re_format::format_f64(**value))
}
}
4 changes: 2 additions & 2 deletions crates/viewer/re_component_ui/src/datatype_uis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ mod view_id;
pub use bool_toggle::edit_bool;
pub use enum_combobox::edit_view_enum;
pub use float_drag::{
edit_f32_float_raw_with_speed_impl, edit_f32_min_to_max_float, edit_f32_zero_to_max,
edit_f32_zero_to_one,
edit_f32_min_to_max_float, edit_f32_zero_to_max, edit_f32_zero_to_one,
edit_f64_float_raw_with_speed_impl,
};
pub use range1d::edit_view_range1d;
pub use singleline_string::{
Expand Down
8 changes: 4 additions & 4 deletions crates/viewer/re_component_ui/src/zoom_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ use re_viewer_context::MaybeMutRef;
// TODO(ab): currently set at 19 because that's what walkers has as hard-coded limit. In the future,
// walkers will need to be more flexible (e.g. depend on the actually max zoom level for the map
// provider). At that point, we will have to set some kind of "max ever" value here.
const MAX_ZOOM_LEVEL: f32 = 19.0;
const MAX_ZOOM_LEVEL: f64 = 19.0;

/// Editor for a [`re_types::blueprint::components::ZoomLevel`].
pub fn edit_zoom_level(
_ctx: &re_viewer_context::ViewerContext<'_>,
ui: &mut egui::Ui,
value: &mut MaybeMutRef<'_, impl std::ops::DerefMut<Target = datatypes::Float32>>,
value: &mut MaybeMutRef<'_, impl std::ops::DerefMut<Target = datatypes::Float64>>,
) -> egui::Response {
let mut value: MaybeMutRef<'_, f32> = match value {
let mut value: MaybeMutRef<'_, f64> = match value {
MaybeMutRef::Ref(value) => MaybeMutRef::Ref(value),
MaybeMutRef::MutRef(value) => MaybeMutRef::MutRef(&mut value.deref_mut().0),
};

super::datatype_uis::edit_f32_float_raw_with_speed_impl(
super::datatype_uis::edit_f64_float_raw_with_speed_impl(
ui,
&mut value,
0.0..=MAX_ZOOM_LEVEL,
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_space_view_map/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ re_viewport_blueprint.workspace = true

egui.workspace = true
itertools.workspace = true
walkers = "0.25.0"
walkers = "0.26.0" # TODO(#7876): move to workspace
2 changes: 1 addition & 1 deletion crates/viewer/re_space_view_map/src/map_space_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Displays geospatial primitives on a map.
if Some(map_memory.zoom()) != blueprint_zoom_level {
map_zoom.save_blueprint_component(
ctx,
&ZoomLevel(re_types::datatypes::Float32(map_memory.zoom())),
&ZoomLevel(re_types::datatypes::Float64(map_memory.zoom())),
);
}

Expand Down
7 changes: 4 additions & 3 deletions crates/viewer/re_space_view_map/src/visualizers/geo_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,16 @@ struct GeoPointsPlugin<'a> {

impl walkers::Plugin for GeoPointsPlugin<'_> {
fn run(
&mut self,
self: Box<Self>,
ui: &mut egui::Ui,
_response: &egui::Response,
painter: egui::Painter,
projector: &walkers::Projector,
) {
for entry in self.map_entries {
// Project it into the position on the screen.
let position = projector.project(entry.position).to_pos2();
painter.circle_filled(position, entry.radius, entry.color);
ui.painter()
.circle_filled(position, entry.radius, entry.color);
}
}
}
5 changes: 3 additions & 2 deletions crates/viewer/re_space_view_map/src/visualizers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ impl GeoSpan {
)
}

pub fn zoom_for_screen_size(&self, screen_size: egui::Vec2) -> Option<f32> {
pub fn zoom_for_screen_size(&self, screen_size: egui::Vec2) -> Option<f64> {
// Thanks, Claude: https://claude.site/artifacts/cb4f7f53-07a6-4ad0-bce3-eee3cb7e3177

if self.min_latitude == self.max_latitude || self.min_longitude == self.max_longitude {
return None;
}

//TODO(ab): should use the actual tile size from the map provider (always 256 in practice)
const TILE_SIZE: f64 = 256.0;

// Convert latitude to y coordinate in mercator projection (scaled to 0..1)
Expand All @@ -68,7 +69,7 @@ impl GeoSpan {
let zoom_y = (screen_size.y as f64 / tiles_y).ln() / 2.0_f64.ln();

// Use the minimum zoom level to ensure the entire range fits
Some(zoom_x.min(zoom_y) as f32)
Some(zoom_x.min(zoom_y))
}
}

Expand Down
24 changes: 12 additions & 12 deletions rerun_cpp/src/rerun/blueprint/components/zoom_level.hpp

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

2 changes: 1 addition & 1 deletion rerun_py/rerun_sdk/rerun/blueprint/archetypes/map_zoom.py

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

8 changes: 4 additions & 4 deletions rerun_py/rerun_sdk/rerun/blueprint/components/zoom_level.py

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

0 comments on commit d6a3ed6

Please sign in to comment.