-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Double click on entity in blueprint & timepanel focuses camera on it …
…in 3D space views (#4799) ### What * Fixes #918 * Fixes #917 This PR introduces on-the-fly determined per-entity bounding boxes and unifies a lot of behavior under the hood: A double click of a hovered item (pretty much everywhere) causes now a "focused" event for that item. Focuses are right now set on the viewer context for a single frame, so each part of the viewer can react on it as it pleases. The 3D Space view reacts by focusing the camera on the entity (using the new bounding box) and tracks cameras. Tracking of entities has been unified - originally this PR tracked entities as well, but I found this a bit too confusing for this action, we should instead have something more explicit (this was disabled in 86ddf0d so it's easy to get it back). https://github.com/rerun-io/rerun/assets/1220815/b6077865-d500-4bc9-b112-8ff41b370fe0 Tradeoffs: * can't focus on instances -> before focused on 3D positions (without knowing anything about the object under it) now focusing on entities; different behavior, _sometimes_ worse, sometimes better -> note that tracking an instance rarely what you want here (e.g. point instance ids vary widely) * tracking an entity is not always what you want -> disabled it * it's very hard to tell that we're tracking something, can sometimes be surprising * Alternative design of `focus`: Send a focus event to space views that should be interested in it. This makes would unify the dispatching code for this which is nicer going forward. But for the moment it was just a lot easier to implement it the way I did. I'm fairly sure though about making focus not sticky in the global state since this way we'd end up with two levels of selection. ### 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 newly built examples: [app.rerun.io](https://app.rerun.io/pr/4799/index.html) * Using examples from latest `main` build: [app.rerun.io](https://app.rerun.io/pr/4799/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [app.rerun.io](https://app.rerun.io/pr/4799/index.html?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 - [PR Build Summary](https://build.rerun.io/pr/4799) - [Docs preview](https://rerun.io/preview/7183423673682ce3d9c0c68fcb335689b8c13693/docs) <!--DOCS-PREVIEW--> - [Examples preview](https://rerun.io/preview/7183423673682ce3d9c0c68fcb335689b8c13693/examples) <!--EXAMPLES-PREVIEW--> - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
- Loading branch information
Showing
31 changed files
with
428 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use nohash_hasher::IntMap; | ||
use re_log_types::EntityPathHash; | ||
use re_viewer_context::VisualizerCollection; | ||
|
||
use crate::visualizers::SpatialViewVisualizerData; | ||
|
||
#[derive(Clone)] | ||
pub struct SceneBoundingBoxes { | ||
/// Accumulated bounding box over several frames. | ||
pub accumulated: macaw::BoundingBox, | ||
|
||
/// Overall bounding box of the scene for the current query. | ||
pub current: macaw::BoundingBox, | ||
|
||
/// Per-entity bounding boxes for the current query. | ||
pub per_entity: IntMap<EntityPathHash, macaw::BoundingBox>, | ||
} | ||
|
||
impl Default for SceneBoundingBoxes { | ||
fn default() -> Self { | ||
Self { | ||
accumulated: macaw::BoundingBox::nothing(), | ||
current: macaw::BoundingBox::nothing(), | ||
per_entity: IntMap::default(), | ||
} | ||
} | ||
} | ||
|
||
impl SceneBoundingBoxes { | ||
pub fn update(&mut self, visualizers: &VisualizerCollection) { | ||
re_tracing::profile_function!(); | ||
|
||
self.current = macaw::BoundingBox::nothing(); | ||
self.per_entity.clear(); | ||
|
||
for visualizer in visualizers.iter() { | ||
if let Some(data) = visualizer | ||
.data() | ||
.and_then(|d| d.downcast_ref::<SpatialViewVisualizerData>()) | ||
{ | ||
for (entity, bbox) in &data.bounding_boxes { | ||
self.per_entity | ||
.entry(*entity) | ||
.and_modify(|bbox_entry| *bbox_entry = bbox_entry.union(*bbox)) | ||
.or_insert(*bbox); | ||
} | ||
} | ||
} | ||
|
||
for bbox in self.per_entity.values() { | ||
self.current = self.current.union(*bbox); | ||
} | ||
|
||
if self.accumulated.is_nothing() || !self.accumulated.size().is_finite() { | ||
self.accumulated = self.current; | ||
} else { | ||
self.accumulated = self.accumulated.union(self.current); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.