Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix heuristic object properties being broken in some cases / fix DepthMeter being ignored sometimes #4679

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion crates/re_entity_db/src/entity_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ impl EntityPropertyMap {
}
}

/// Overrides the properties for a given entity path.
///
/// Like `update`, but auto properties are always updated.
pub fn overwrite_properties(&mut self, entity_path: EntityPath, prop: EntityProperties) {
if prop == EntityProperties::default() {
self.props.remove(&entity_path); // save space
} else {
self.props.insert(entity_path, prop);
}
}

#[inline]
pub fn iter(&self) -> impl Iterator<Item = (&EntityPath, &EntityProperties)> {
self.props.iter()
Expand Down Expand Up @@ -136,7 +147,7 @@ impl Default for EntityProperties {
color_mapper: EditableAutoValue::default(),
pinhole_image_plane_distance: EditableAutoValue::default(),
backproject_depth: EditableAutoValue::Auto(true),
depth_from_world_scale: EditableAutoValue::default(),
depth_from_world_scale: EditableAutoValue::Auto(1.0),
backproject_radius_scale: EditableAutoValue::Auto(1.0),
transform_3d_visible: EditableAutoValue::Auto(false),
transform_3d_size: EditableAutoValue::Auto(1.0),
Expand Down
6 changes: 3 additions & 3 deletions crates/re_space_view_spatial/src/heuristics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn update_pinhole_property_heuristics(
};
properties.pinhole_image_plane_distance =
EditableAutoValue::Auto(default_image_plane_distance);
entity_properties.update(ent_path.clone(), properties);
entity_properties.overwrite_properties(ent_path.clone(), properties);
}
}
}
Expand Down Expand Up @@ -186,7 +186,7 @@ fn update_depth_cloud_property_heuristics(
properties.backproject_radius_scale = EditableAutoValue::Auto(1.0);
}

entity_properties.update(ent_path.clone(), properties);
entity_properties.overwrite_properties(ent_path.clone(), properties);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like the opposite of what we want. If an entity has both a depth heuristic and a pinhole heuristic, only one of these is going to end up being applied.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's true. Each time we first retrieve properties via entity_properties.get which will have the updated value. None of the things we set here overwrite each other directly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh -- I needed to expand to see the context that this is a read-edit-write loop and not just a blind update. Still feels fragile, but as I've mentioned, hopefully this is all going away soon enough when we split properties into their own components.

}
}
}
Expand Down Expand Up @@ -256,6 +256,6 @@ fn update_transform3d_lines_heuristics(
}
}

entity_properties.update(ent_path.clone(), properties);
entity_properties.overwrite_properties(ent_path.clone(), properties);
}
}
Loading