Skip to content

Commit

Permalink
#72 Fixed egui gizmo rendering when viewport is NOTHING
Browse files Browse the repository at this point in the history
The default gizmo viewport is Rect::NOTHING. Egui gizmo
replaces non-finite viewports with the clip rect.
However, the non-finite viewport was being used for egui clipping
even though the gizmo viewport was replaced.
  • Loading branch information
urholaukkarinen committed Jul 27, 2024
1 parent 00be178 commit ce0dc0a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions crates/transform-gizmo-egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ impl GizmoExt for Gizmo {
ui: &Ui,
targets: &[Transform],
) -> Option<(GizmoResult, Vec<Transform>)> {
let config = self.config();

let egui_viewport = egui::Rect {
min: Pos2::new(config.viewport.min.x, config.viewport.min.y),
max: Pos2::new(config.viewport.max.x, config.viewport.max.y),
};

let cursor_pos = ui
.input(|input| input.pointer.hover_pos())
.unwrap_or_default();
Expand All @@ -80,6 +73,11 @@ impl GizmoExt for Gizmo {
viewport = ui.clip_rect();
}

let egui_viewport = Rect {
min: Pos2::new(viewport.min.x, viewport.min.y),
max: Pos2::new(viewport.max.x, viewport.max.y),
};

self.update_config(GizmoConfig {
viewport,
pixels_per_point: ui.ctx().pixels_per_point(),
Expand Down

0 comments on commit ce0dc0a

Please sign in to comment.