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 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
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 avoids a cyclic relationship where the image plane grows the bounds
// which in turn influence the size of the image plane.
// See: https://github.com/rerun-io/rerun/issues/3728
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 avoids a cyclic relationship where the image plane grows the bounds
// which in turn influence the size of the image plane.
// See: https://github.com/rerun-io/rerun/issues/3728
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 avoids a cyclic relationship where the image plane grows the bounds
// which in turn influence the size of the image plane.
// See: https://github.com/rerun-io/rerun/issues/3728
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