Skip to content

Commit

Permalink
comment and naming fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Feb 12, 2024
1 parent 015ba75 commit bf16bd5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use re_data_store::{StoreSubscriber, StoreSubscriberHandle};
use re_log_types::{EntityPath, StoreId};
use re_types::{components::TensorData, Loggable};

#[derive(Default, Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Default, Debug, Clone, Clone, PartialEq, Eq, Hash)]
pub struct ImageDimensions {
pub height: u64,
pub width: u64,
Expand Down
18 changes: 10 additions & 8 deletions crates/re_space_view_spatial/src/space_view_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl SpaceViewClass for SpatialSpaceView2D {
.cloned()
.collect();

// For explicit 2D pinholes start at the origin, otherwise start at the common ancestor.
// For explicit 2D spaces (typically indicated by a pinhole or similar) start at the origin, otherwise start at the common ancestor.
// This generally avoids the `/` root entity unless it's required as a common ancestor.
let recommended_root =
if subspace.dimensionality == SubSpaceDimensionality::TwoD {
Expand Down Expand Up @@ -257,9 +257,9 @@ impl SpaceViewClass for SpatialSpaceView2D {
}
}

// Count the number of entities with the given component exist that aren't
// Count the number of image entities with the given component exist that aren't
// children of other entities in the bucket.
fn count_non_nested_entities_with_component(
fn count_non_nested_images_with_component(
image_dimensions: &IntMap<EntityPath, ImageDimensions>,
entity_bucket: &IntSet<EntityPath>,
subtree: &EntityTree,
Expand All @@ -278,7 +278,7 @@ fn count_non_nested_entities_with_component(
.children
.values()
.map(|child| {
count_non_nested_entities_with_component(
count_non_nested_images_with_component(
image_dimensions,
entity_bucket,
child,
Expand All @@ -298,11 +298,11 @@ fn find_non_nested_image_dimensions(
image_dimensions: &IntMap<EntityPath, ImageDimensions>,
entity_bucket: &IntSet<EntityPath>,
subtree: &EntityTree,
found_image_dimensions: &mut HashSet<(u64, u64)>,
found_image_dimensions: &mut HashSet<[u64; 2]>,
) {
if let Some(dimensions) = image_dimensions.get(&subtree.path) {
// If we found an image entity, add its dimensions to the set.
found_image_dimensions.insert((dimensions.height, dimensions.width));
found_image_dimensions.insert([dimensions.height, dimensions.width]);
} else if entity_bucket
.iter()
.any(|e| e.is_descendant_of(&subtree.path))
Expand All @@ -326,6 +326,8 @@ fn recommended_space_views_with_image_splits(
entities: &IntSet<EntityPath>,
recommended: &mut Vec<RecommendedSpaceView>,
) {
re_tracing::profile_function!();

let tree = ctx.entity_db.tree();

let Some(subtree) = tree.subtree(recommended_root) else {
Expand All @@ -344,14 +346,14 @@ fn recommended_space_views_with_image_splits(
&mut found_image_dimensions,
);

let image_count = count_non_nested_entities_with_component(
let image_count = count_non_nested_images_with_component(
image_dimensions,
entities,
subtree,
&Image::indicator().name(),
);

let depth_count = count_non_nested_entities_with_component(
let depth_count = count_non_nested_images_with_component(
image_dimensions,
entities,
subtree,
Expand Down

0 comments on commit bf16bd5

Please sign in to comment.