@@ -109,13 +109,16 @@ public void Update(GameTime gameTime)
109
109
{
110
110
if ( ObjectSnap && Camera . PickByMouse ( out var snappedObject ) )
111
111
{
112
+ if ( snappedObject != SnappedObject )
113
+ Viewer . EditorShapes . BoundingBoxShapes . RemoveAll ( s => s == SnappedObject ) ;
112
114
SnappedObject = snappedObject ;
113
- Viewer . EditorShapes . BoundingBoxShapes . Add ( SnappedObject ) ;
115
+ if ( ! Viewer . EditorShapes . BoundingBoxShapes . Contains ( SnappedObject ) )
116
+ Viewer . EditorShapes . BoundingBoxShapes . Add ( SnappedObject ) ;
114
117
}
115
118
else
116
119
{
120
+ Viewer . EditorShapes . BoundingBoxShapes . RemoveAll ( s => s == SnappedObject ) ;
117
121
SnappedObject = null ;
118
- Viewer . EditorShapes . BoundingBoxShapes . TryTake ( out _ ) ;
119
122
}
120
123
MovedObject . Location . XNAMatrix = GetMovingMatrix ( MovedObjectOriginalPosition , HandleOriginalPosition , HandlePosition ) ;
121
124
Viewer . EditorShapes . MovedObject = MovedObject ;
@@ -438,6 +441,7 @@ void CancelObjectMove()
438
441
HandlePosition . CopyFrom ( HandleOriginalPosition ) ;
439
442
else
440
443
HandlePosition = null ;
444
+ Viewer . EditorShapes . BoundingBoxShapes . Clear ( ) ;
441
445
EditorState = EditorState . ObjectSelected ;
442
446
}
443
447
@@ -457,6 +461,7 @@ void ApplyObjectMove()
457
461
458
462
DeltaContext = UndoStack . Peek ( ) ;
459
463
MovedObject = null ;
464
+ Viewer . EditorShapes . BoundingBoxShapes . Clear ( ) ;
460
465
EditorState = EditorState . ObjectSelected ;
461
466
}
462
467
@@ -472,12 +477,14 @@ void CancelHandleMove()
472
477
{
473
478
HandlePosition = null ;
474
479
HandleOriginalPosition = null ;
480
+ Viewer . EditorShapes . BoundingBoxShapes . Clear ( ) ;
475
481
EditorState = EditorState . ObjectSelected ;
476
482
}
477
483
478
484
void ApplyHandleMove ( )
479
485
{
480
486
HandleOriginalPosition = new WorldPosition ( HandlePosition ) ;
487
+ Viewer . EditorShapes . BoundingBoxShapes . Clear ( ) ;
481
488
EditorState = EditorState . ObjectSelected ;
482
489
}
483
490
@@ -486,8 +493,7 @@ void SelectedObjectChanged()
486
493
Viewer . EditorShapes . SelectedObject = SelectedObject ;
487
494
Viewer . EditorShapes . MovedObject = null ;
488
495
Viewer . EditorShapes . HandleLocation = null ;
489
- while ( ! Viewer . EditorShapes . BoundingBoxShapes . IsEmpty )
490
- Viewer . EditorShapes . BoundingBoxShapes . TryTake ( out _ ) ;
496
+ Viewer . EditorShapes . BoundingBoxShapes . Clear ( ) ;
491
497
HandlePosition = null ;
492
498
HandleOriginalPosition = null ;
493
499
SnappedObject = null ;
0 commit comments