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 ui-scale based point/line sizes incorrectly scaled when zooming based on horizontal dimension #2805

Merged
merged 1 commit into from
Jul 25, 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_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