Skip to content

Commit

Permalink
Fix ui-scale based point/line sizes incorrectly scaled when zooming b…
Browse files Browse the repository at this point in the history
…ased on horizontal dimension (#2805)

### What

Fixes #2758 
* #2758

### 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/2805) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2805)
- [Docs
preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-ui-scale-for-horizontal-scaling/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-ui-scale-for-horizontal-scaling/examples)
  • Loading branch information
Wumpf authored Jul 25, 2023
1 parent 4b83b60 commit 381a847
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 4 additions & 1 deletion crates/re_renderer/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl RectTransform {
}

pub fn scale(&self) -> glam::Vec2 {
self.region.extent / self.region_of_interest.extent
self.region_of_interest.extent / self.region.extent
}
}

Expand Down Expand Up @@ -122,6 +122,7 @@ mod tests {
scale,
glam::Mat4::from_scale(1.0 / scale_factor.extend(1.0))
);
assert_eq!(rect_transform.scale(), scale_factor);
}

// Translation
Expand All @@ -142,6 +143,7 @@ mod tests {
glam::vec3(-translation_vec.x, translation_vec.y, 0.0) * 2.0
)
);
assert_eq!(rect_transform.scale(), glam::Vec2::ONE);
}

// Scale + translation
Expand All @@ -166,6 +168,7 @@ mod tests {
glam::vec3(-translation_vec.x, translation_vec.y, 0.0) * 2.0
)
);
assert_eq!(rect_transform.scale(), scale_factor);
}
}
}
5 changes: 1 addition & 4 deletions crates/re_renderer/src/view_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,7 @@ impl ViewBuilder {
let projection_from_view = ndc_scale_and_translation * projection_from_view;
// Need to take into account that a smaller portion of the world scale is visible now.
let pixel_world_size_from_camera_distance = pixel_world_size_from_camera_distance
/ ndc_scale_and_translation
.col(0)
.x
.max(ndc_scale_and_translation.col(1).y);
* config.viewport_transformation.scale().max_element();

let mut view_from_world = config.view_from_world.to_mat4();
// For OrthographicCameraMode::TopLeftCorner, we want Z facing forward.
Expand Down

0 comments on commit 381a847

Please sign in to comment.