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 d858a27
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/transform-gizmo-egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ impl GizmoExt for Gizmo {
) -> 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 +75,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 d858a27

Please sign in to comment.