Skip to content

Commit f824108

Browse files
DYN-6738: Fix gizmo redraw and camera drift issues (#16852)
1 parent 4a65a8a commit f824108

File tree

3 files changed

+475
-1
lines changed

3 files changed

+475
-1
lines changed

src/DynamoManipulation/NodeManipulator.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,21 @@ protected virtual void MouseDown(object sender, MouseButtonEventArgs mouseButton
185185
{
186186
if (!IsValidNode) return;
187187

188+
// Skip processing if user is panning or orbiting the camera.
189+
// This prevents the manipulator from capturing mouse events intended for camera navigation.
190+
if (BackgroundPreviewViewModel is DefaultWatch3DViewModel viewModel)
191+
{
192+
if (viewModel.IsPanning || viewModel.IsOrbiting)
193+
return;
194+
}
195+
196+
// Only process left mouse button presses for gizmo manipulation
197+
// Right/middle button presses are for camera navigation (pan/orbit)
198+
if (mouseButtonEventArgs.ChangedButton != MouseButton.Left)
199+
{
200+
return;
201+
}
202+
188203
active = UpdatePosition();
189204
if (Origin != null )
190205
{
@@ -228,6 +243,21 @@ protected virtual void MouseDown(object sender, MouseButtonEventArgs mouseButton
228243
/// <param name="e"></param>
229244
protected virtual void MouseUp(object sender, MouseButtonEventArgs e)
230245
{
246+
// Skip processing if user is panning or orbiting the camera.
247+
// This prevents the manipulator from capturing mouse events intended for camera navigation.
248+
if (BackgroundPreviewViewModel is DefaultWatch3DViewModel viewModel)
249+
{
250+
if (viewModel.IsPanning || viewModel.IsOrbiting)
251+
return;
252+
}
253+
254+
// Only process left mouse button releases for gizmo manipulation
255+
// Right/middle button releases are for camera navigation (pan/orbit)
256+
if (e.ChangedButton != MouseButton.Left)
257+
{
258+
return;
259+
}
260+
231261
GizmoInAction = null;
232262

233263
if (originBeforeMove != null && originAfterMove != null)
@@ -249,6 +279,13 @@ protected virtual void MouseUp(object sender, MouseButtonEventArgs e)
249279
foreach (var gizmo in gizmos)
250280
{
251281
gizmo.UpdateGizmoGraphics();
282+
283+
// Clear hit state to prevent drift during subsequent camera operations
284+
// This ensures stale axis/plane hit data doesn't affect pan/orbit movements
285+
if (gizmo is TranslationGizmo translationGizmo)
286+
{
287+
translationGizmo.ClearHitState();
288+
}
252289
}
253290
}
254291

src/DynamoManipulation/TranslationGizmo.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,20 @@ private Line GetRayGeometry(Point source, Vector direction)
276276
public CoordinateSystem ReferenceCoordinateSystem { get; set; }
277277

278278
/// <summary>
279-
/// Performs hit test on Gizmo to find out hit object. The returned
279+
/// Clears the cached hit axis and plane after manipulation is complete.
280+
/// This prevents stale hit state from affecting subsequent camera operations.
281+
/// This method is called automatically by <c>NodeManipulator.MouseUp</c> when a
282+
/// manipulation operation finishes; it typically does not need to be invoked
283+
/// directly except in custom manipulation workflows.
284+
/// </summary>
285+
public void ClearHitState()
286+
{
287+
hitAxis = null;
288+
hitPlane = null;
289+
}
290+
291+
/// <summary>
292+
/// Performs hit test on Gizmo to find out hit object. The returned
280293
/// hitObject could be either axis vector or a plane.
281294
/// </summary>
282295
/// <param name="source">Mouse click source for hit test</param>

0 commit comments

Comments
 (0)