-
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.
Separate 2d & 3d spaceview classes, removal of
ViewCategory
, `Space…
…ViewClass` driven spawn heuristics (#2716) ### What Fixes #2649 * #2649 Separates the 2D & 3D space views into separate classes, leading to removal of the "navigation mode". Naturally, this means that heuristics that previously defined the navigation mode move to space view creation. Space view creation in turn was previously defined via the outdated `ViewCategory` concept (which assigned each space view class an enum value). Since we wanted to remove it for a while, I went through with that, causing heuristics to spread out further into the Space View Class framework itself. Default space view spawning & populating is now goverend by: * remaining hardcoded heuristics in `space_view_heuristics.rs` (to be phased out!) * `ViewPartSystem::queries_any_components_of` determines which entities a `ViewPartSystem` queries. The default implementation works for everything except `Tensor` (if this case disappears in the future we may consider removing this method again) * `SpaceViewClass::auto_spawn_heuristic` drives whether a Space View Class is spawned for a given root and set of entities. This is fairly basic at the moment and should eventually take over almost everything in `space_view_heuristics`. Interestingly, this already allows to express relatively complex rules like "if there is any log text, default spawn a single text view at the root and don't affect spawning of other space views at all" Noticed that some other space view class icons were wrong and fixed that up as well. <img width="164" alt="image" src="https://github.com/rerun-io/rerun/assets/1220815/9317bbf8-4397-41d0-aa2e-489f24e448cb"> ### 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 [demo.rerun.io](https://demo.rerun.io/pr/2716) (if applicable) - [PR Build Summary](https://build.rerun.io/pr/2716) - [Docs preview](https://rerun.io/preview/pr%3Aandreas%2Fseparate-2d-3d-spaceviews/docs) - [Examples preview](https://rerun.io/preview/pr%3Aandreas%2Fseparate-2d-3d-spaceviews/examples)
- Loading branch information
Showing
54 changed files
with
861 additions
and
713 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,47 @@ | ||
use nohash_hasher::IntSet; | ||
use re_log_types::{EntityPath, Timeline}; | ||
use re_viewer_context::{AutoSpawnHeuristic, SpaceViewClassName, ViewerContext}; | ||
|
||
use crate::{parts::SpatialViewPartData, view_kind::SpatialSpaceViewKind}; | ||
|
||
pub fn auto_spawn_heuristic( | ||
class: &SpaceViewClassName, | ||
ctx: &ViewerContext<'_>, | ||
ent_paths: &IntSet<EntityPath>, | ||
view_kind: SpatialSpaceViewKind, | ||
) -> AutoSpawnHeuristic { | ||
re_tracing::profile_function!(); | ||
|
||
let store = ctx.store_db.store(); | ||
let timeline = Timeline::log_time(); | ||
|
||
let mut score = 0.0; | ||
|
||
let parts = ctx | ||
.space_view_class_registry | ||
.get_system_registry_or_log_error(class) | ||
.new_part_collection(); | ||
let parts_with_view_kind = parts | ||
.iter() | ||
.filter(|part| { | ||
part.data() | ||
.and_then(|d| d.downcast_ref::<SpatialViewPartData>()) | ||
.map_or(false, |data| data.preferred_view_kind == Some(view_kind)) | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
for ent_path in ent_paths { | ||
let Some(components) = store.all_components(&timeline, ent_path) else { | ||
continue; | ||
}; | ||
|
||
for part in &parts_with_view_kind { | ||
if part.queries_any_components_of(store, ent_path, &components) { | ||
score += 1.0; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
AutoSpawnHeuristic::SpawnClassWithHighestScoreForRoot(score) | ||
} |
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
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.