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

Only grow 3D view bounds with projected image if image plane has been user-edited #3749

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion crates/re_space_view_spatial/src/heuristics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ fn update_pinhole_property_heuristics(
let default_image_plane_distance = if scene_size.is_finite() && scene_size > 0.0 {
scene_size * 0.02 // Works pretty well for `examples/python/open_photogrammetry_format/main.py --no-frames`
} else {
1.0
// This value somewhat arbitrary. In almost all cases where the scene has defined bounds
// the heuristic will change it or it will be user edited. In the case of non-defined bounds
// this value works better with the default camera setup.
0.3
};
properties.pinhole_image_plane_distance =
EditableAutoValue::Auto(default_image_plane_distance);
Expand Down
28 changes: 23 additions & 5 deletions crates/re_space_view_spatial/src/parts/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl ImagesPart {
&mut self,
ctx: &ViewerContext<'_>,
transforms: &TransformContext,
_ent_props: &EntityProperties,
ent_props: &EntityProperties,
arch_view: &ArchetypeView<Image>,
ent_path: &EntityPath,
ent_context: &SpatialSceneEntityContext<'_>,
Expand Down Expand Up @@ -273,7 +273,13 @@ impl ImagesPart {
meaning,
color.into(),
) {
self.extend_bbox(&textured_rect);
// Only update the bounding box if the image_plane_distance is not auto.
// This is because in auto mode the bounds will change the image plane heuristic,
// and there's no good reason to grow the size of the bounds only to the shrink
// the image plane as a result.
Copy link
Member

Choose a reason for hiding this comment

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

More to the point: it causes a cyclic relationship, where the auto-distance depend on the bounding box, and the bounding box is affected by the distance

Copy link
Member Author

Choose a reason for hiding this comment

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

It's only lightly cyclic though -- since net result is to shrink the plane it doesn't continue the cycle.

if !ent_props.pinhole_image_plane_distance.is_auto() {
self.extend_bbox(&textured_rect);
}

self.images.push(ViewerImage {
ent_path: ent_path.clone(),
Expand Down Expand Up @@ -393,7 +399,13 @@ impl ImagesPart {
meaning,
color.into(),
) {
self.extend_bbox(&textured_rect);
// Only update the bounding box if the image_plane_distance is not auto.
// This is because in auto mode the bounds will change the image plane heuristic,
// and there's no good reason to grow the size of the bounds only to the shrink
// the image plane as a result.
if !ent_props.pinhole_image_plane_distance.is_auto() {
self.extend_bbox(&textured_rect);
}

self.images.push(ViewerImage {
ent_path: ent_path.clone(),
Expand All @@ -414,7 +426,7 @@ impl ImagesPart {
&mut self,
ctx: &ViewerContext<'_>,
transforms: &TransformContext,
_ent_props: &EntityProperties,
ent_props: &EntityProperties,
arch_view: &ArchetypeView<SegmentationImage>,
ent_path: &EntityPath,
ent_context: &SpatialSceneEntityContext<'_>,
Expand Down Expand Up @@ -481,7 +493,13 @@ impl ImagesPart {
meaning,
color.into(),
) {
self.extend_bbox(&textured_rect);
// Only update the bounding box if the image_plane_distance is not auto.
// This is because in auto mode the bounds will change the image plane heuristic,
// and there's no good reason to grow the size of the bounds only to the shrink
// the image plane as a result.
if !ent_props.pinhole_image_plane_distance.is_auto() {
self.extend_bbox(&textured_rect);
}

self.images.push(ViewerImage {
ent_path: ent_path.clone(),
Expand Down
Loading