@@ -419,11 +419,11 @@ pub struct BenchUpApp {
419419 gesture : Option < Gesture > ,
420420 section_drag : Option < section_gizmo:: SectionDrag > ,
421421 orbit_origin : sidebar:: OrbitOrigin ,
422+ setting_orbit_focus : bool ,
422423 drawing_orbit_down : bool ,
423424 drawing_orbit_pivot : Option < DVec3 > ,
424425 viewport_pointer : Option < Pos2 > ,
425426 viewport : Rect ,
426- setting_orbit_focus : bool ,
427427 viewports : viewports:: Workspace ,
428428 inspector : bool ,
429429 inspector_width : f32 ,
@@ -612,12 +612,12 @@ impl BenchUpApp {
612612 gesture : None ,
613613 section_drag : None ,
614614 orbit_origin : Default :: default ( ) ,
615+ setting_orbit_focus : false ,
615616 drawing_orbit_down : false ,
616617 drawing_orbit_pivot : None ,
617618 viewport_pointer : None ,
618619 viewport : Rect :: NOTHING ,
619620 viewports : viewports:: Workspace :: default ( ) ,
620- setting_orbit_focus : false ,
621621 inspector : true ,
622622 inspector_width : 300. ,
623623 inspector_preferences : sidebar:: InspectorPreferences :: default ( ) ,
@@ -4448,6 +4448,11 @@ impl BenchUpApp {
44484448 }
44494449
44504450 fn update_pointer ( & mut self , pos : Pos2 ) {
4451+ if self . tool == Tool :: Orbit && self . setting_orbit_focus && !self . navigating ( ) {
4452+ self . hover = self . pick_at ( dv ( pos - self . viewport . min ) , dv ( self . viewport . size ( ) ) , true ) ;
4453+ self . flip_hover = None ;
4454+ return ;
4455+ }
44514456 // Navigation and selection rectangles do not need hover queries.
44524457 // Keep their feedback responsive on large imported models.
44534458 let selecting_box = self . gesture . as_ref ( ) . is_some_and ( |gesture| {
@@ -4569,11 +4574,6 @@ impl BenchUpApp {
45694574 if self . drawing . is_some ( ) && self . paste_preview . is_none ( ) {
45704575 if self . lock . is_none ( )
45714576 && let Some ( drawing) = & mut self . drawing
4572- if self . tool == Tool :: Orbit && self . setting_orbit_focus && !self . navigating ( ) {
4573- self . hover = self . pick_at ( dv ( pos - self . viewport . min ) , dv ( self . viewport . size ( ) ) , true ) ;
4574- self . flip_hover = None ;
4575- return ;
4576- }
45774577 {
45784578 // Inferred planes belong to the current snap only. Start
45794579 // each query on the original plane so leaving a target
@@ -4626,6 +4626,7 @@ impl BenchUpApp {
46264626 }
46274627 fn orbit_center ( & mut self ) -> DVec3 {
46284628 match self . orbit_origin {
4629+ sidebar:: OrbitOrigin :: Focused => return self . doc . orbit_focus . unwrap_or ( self . doc . camera . target ) ,
46294630 sidebar:: OrbitOrigin :: World => return DVec3 :: ZERO ,
46304631 sidebar:: OrbitOrigin :: View => return self . doc . camera . target ,
46314632 sidebar:: OrbitOrigin :: Selection => {
@@ -4747,7 +4748,6 @@ impl BenchUpApp {
47474748 return ;
47484749 } ;
47494750 if !matches ! (
4750- sidebar:: OrbitOrigin :: Focused => return self . doc. orbit_focus. unwrap_or( self . doc. camera. target) ,
47514751 gesture. button,
47524752 egui:: PointerButton :: Primary | egui:: PointerButton :: Middle
47534753 ) {
@@ -4934,6 +4934,22 @@ impl BenchUpApp {
49344934 }
49354935 continue ;
49364936 }
4937+ if self . tool == Tool :: Orbit && self . setting_orbit_focus {
4938+ if button == egui:: PointerButton :: Primary {
4939+ self . prepare_picking ( ) ;
4940+ if let Some ( snap) = self . infer_snap ( pos, None , None , false ) {
4941+ self . doc . orbit_focus = Some ( snap. point ) ;
4942+ self . orbit_origin = sidebar:: OrbitOrigin :: Focused ;
4943+ self . setting_orbit_focus = false ;
4944+ self . camera_changed ( ctx) ;
4945+ }
4946+ continue ;
4947+ }
4948+ if button == egui:: PointerButton :: Secondary {
4949+ self . setting_orbit_focus = false ;
4950+ continue ;
4951+ }
4952+ }
49374953 self . update_drawing_orbit ( modifiers) ;
49384954 if button == egui:: PointerButton :: Secondary {
49394955 self . solid_first = None ;
@@ -5055,22 +5071,6 @@ impl BenchUpApp {
50555071 self . viewport_pointer = in_viewport. then_some ( pos) ;
50565072 if let Some ( mut gesture) = self . gesture . take ( ) {
50575073 self . update_compass_orbit ( ctx, & mut gesture, pos) ;
5058- if self . tool == Tool :: Orbit && self . setting_orbit_focus {
5059- if button == egui:: PointerButton :: Primary {
5060- self . prepare_picking ( ) ;
5061- if let Some ( snap) = self . infer_snap ( pos, None , None , false ) {
5062- self . doc . orbit_focus = Some ( snap. point ) ;
5063- self . orbit_origin = sidebar:: OrbitOrigin :: Focused ;
5064- self . setting_orbit_focus = false ;
5065- self . camera_changed ( ctx) ;
5066- }
5067- continue ;
5068- }
5069- if button == egui:: PointerButton :: Secondary {
5070- self . setting_orbit_focus = false ;
5071- continue ;
5072- }
5073- }
50745074 match & mut gesture. kind {
50755075 GestureKind :: Navigate { pivot } => {
50765076 self . navigate ( ctx, dv ( pos - gesture. last ) , pivot) ;
@@ -5343,6 +5343,19 @@ impl BenchUpApp {
53435343 {
53445344 return ;
53455345 }
5346+ if self . tool == Tool :: Orbit && self . setting_orbit_focus && !self . navigating ( ) {
5347+ #[ cfg( target_arch = "wasm32" ) ]
5348+ if crate :: tool_cursor:: show_focus ( ctx) {
5349+ ctx. set_cursor_icon ( egui:: CursorIcon :: None ) ;
5350+ return ;
5351+ }
5352+ let painter = ctx. layer_painter ( egui:: LayerId :: new (
5353+ egui:: Order :: Tooltip , egui:: Id :: unique ( "viewport_tool_cursor" ) ,
5354+ ) ) ;
5355+ ctx. set_cursor_icon ( egui:: CursorIcon :: None ) ;
5356+ icons:: origin_target ( & painter, pos, if ctx. global_style ( ) . visuals . dark_mode { Color32 :: WHITE } else { Color32 :: BLACK } ) ;
5357+ return ;
5358+ }
53465359 let tool = if self . navigating ( ) {
53475360 Tool :: Orbit
53485361 } else {
@@ -5464,19 +5477,6 @@ impl BenchUpApp {
54645477 pair[ 0 ] ,
54655478 pair[ 1 ] ,
54665479 2.2 ,
5467- if self . tool == Tool :: Orbit && self . setting_orbit_focus && !self . navigating ( ) {
5468- #[ cfg( target_arch = "wasm32" ) ]
5469- if crate :: tool_cursor:: show_focus ( ctx) {
5470- ctx. set_cursor_icon ( egui:: CursorIcon :: None ) ;
5471- return ;
5472- }
5473- let painter = ctx. layer_painter ( egui:: LayerId :: new (
5474- egui:: Order :: Tooltip , egui:: Id :: unique ( "viewport_tool_cursor" ) ,
5475- ) ) ;
5476- ctx. set_cursor_icon ( egui:: CursorIcon :: None ) ;
5477- icons:: origin_target ( & painter, pos, if ctx. global_style ( ) . visuals . dark_mode { Color32 :: WHITE } else { Color32 :: BLACK } ) ;
5478- return ;
5479- }
54805480 self . lock
54815481 . map ( |axis| self . axis_color ( axis) )
54825482 . unwrap_or ( ACCENT ) ,
0 commit comments