@@ -109,13 +109,16 @@ public void Update(GameTime gameTime)
109109 {
110110 if ( ObjectSnap && Camera . PickByMouse ( out var snappedObject ) )
111111 {
112+ if ( snappedObject != SnappedObject )
113+ Viewer . EditorShapes . BoundingBoxShapes . RemoveAll ( s => s == SnappedObject ) ;
112114 SnappedObject = snappedObject ;
113- Viewer . EditorShapes . BoundingBoxShapes . Add ( SnappedObject ) ;
115+ if ( ! Viewer . EditorShapes . BoundingBoxShapes . Contains ( SnappedObject ) )
116+ Viewer . EditorShapes . BoundingBoxShapes . Add ( SnappedObject ) ;
114117 }
115118 else
116119 {
120+ Viewer . EditorShapes . BoundingBoxShapes . RemoveAll ( s => s == SnappedObject ) ;
117121 SnappedObject = null ;
118- Viewer . EditorShapes . BoundingBoxShapes . TryTake ( out _ ) ;
119122 }
120123 MovedObject . Location . XNAMatrix = GetMovingMatrix ( MovedObjectOriginalPosition , HandleOriginalPosition , HandlePosition ) ;
121124 Viewer . EditorShapes . MovedObject = MovedObject ;
@@ -438,6 +441,7 @@ void CancelObjectMove()
438441 HandlePosition . CopyFrom ( HandleOriginalPosition ) ;
439442 else
440443 HandlePosition = null ;
444+ Viewer . EditorShapes . BoundingBoxShapes . Clear ( ) ;
441445 EditorState = EditorState . ObjectSelected ;
442446 }
443447
@@ -457,6 +461,7 @@ void ApplyObjectMove()
457461
458462 DeltaContext = UndoStack . Peek ( ) ;
459463 MovedObject = null ;
464+ Viewer . EditorShapes . BoundingBoxShapes . Clear ( ) ;
460465 EditorState = EditorState . ObjectSelected ;
461466 }
462467
@@ -472,12 +477,14 @@ void CancelHandleMove()
472477 {
473478 HandlePosition = null ;
474479 HandleOriginalPosition = null ;
480+ Viewer . EditorShapes . BoundingBoxShapes . Clear ( ) ;
475481 EditorState = EditorState . ObjectSelected ;
476482 }
477483
478484 void ApplyHandleMove ( )
479485 {
480486 HandleOriginalPosition = new WorldPosition ( HandlePosition ) ;
487+ Viewer . EditorShapes . BoundingBoxShapes . Clear ( ) ;
481488 EditorState = EditorState . ObjectSelected ;
482489 }
483490
@@ -486,8 +493,7 @@ void SelectedObjectChanged()
486493 Viewer . EditorShapes . SelectedObject = SelectedObject ;
487494 Viewer . EditorShapes . MovedObject = null ;
488495 Viewer . EditorShapes . HandleLocation = null ;
489- while ( ! Viewer . EditorShapes . BoundingBoxShapes . IsEmpty )
490- Viewer . EditorShapes . BoundingBoxShapes . TryTake ( out _ ) ;
496+ Viewer . EditorShapes . BoundingBoxShapes . Clear ( ) ;
491497 HandlePosition = null ;
492498 HandleOriginalPosition = null ;
493499 SnappedObject = null ;
0 commit comments