Skip to content

Conversation

@jasonstratton
Copy link
Contributor

@jasonstratton jasonstratton commented Jan 23, 2026

Summary

Fixes two issues with gizmo manipulation:

  1. Gizmo redraw failure during drag - Fixed by adding forceAsyncCall=true parameter to ensure render operations are properly queued on the dispatcher
  2. Camera drift when zoomed in close - Fixed by filtering mouse events (left button only) and clearing stale hit state after manipulation

Root Causes

  • Issue 1: Missing forceAsyncCall parameter prevented proper async rendering during drag
  • Issue 2: Gizmo responded to all mouse buttons and retained cached hit data that interfered with camera operations

Changes

  • src/DynamoManipulation/NodeManipulator.cs - Mouse button filtering, pan/orbit detection, ClearHitState call, forceAsyncCall fix
  • src/DynamoManipulation/TranslationGizmo.cs - Added ClearHitState() method
  • test/DynamoCoreWpf2Tests/ViewExtensions/GizmoManipulationTests.cs - Comprehensive test coverage (8 tests, all passing)

Performance

Preserves PR #12614's performance optimization - graph updates occur only on MouseUp, not during drag.

Testing

All 8 new unit tests passed in Visual Studio Test Explorer.

Fixes two issues with gizmo manipulation:
1. Gizmo redraw failure during drag - fixed by adding
   forceAsyncCall=true to render queue
2. Camera drift when zoomed in - fixed by filtering mouse
   events and clearing stale hit state

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 23, 2026 21:53
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-6738

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes two critical issues with gizmo manipulation in Dynamo: redraw failures during drag operations and camera drift when zoomed in close. The fixes ensure proper async rendering during manipulation and prevent mouse event conflicts between gizmo manipulation and camera operations.

Changes:

  • Added mouse button filtering to restrict gizmo manipulation to left-button-only events
  • Implemented ClearHitState() method to clear cached hit data after manipulation
  • Fixed async rendering during drag by adding forceAsyncCall=true parameter

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/DynamoManipulation/NodeManipulator.cs Added mouse button filtering, pan/orbit detection guards, ClearHitState invocation, and forceAsyncCall parameter fix
src/DynamoManipulation/TranslationGizmo.cs Implemented ClearHitState() method to clear hitAxis and hitPlane fields
test/DynamoCoreWpf2Tests/ViewExtensions/GizmoManipulationTests.cs Added comprehensive test suite with 8 tests covering button filtering, pan/orbit detection, and hit state clearing

// Doing this triggers a graph update on scheduler thread
OnGizmoMoved(GizmoInAction, offset);

// redraw manipulator at new position synchronously
Copy link
Contributor

@aparajit-pratap aparajit-pratap Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to update this comment? The fact that it was specifically mentioned synchronously before, I wonder if the behavior should be changed to async in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What bug does this address exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment was not updated when the change was made, but it should have

Changing from synchronous to async was an effort to make sure the gizmo does not stutter when dragging it. In my testing there was a minor lag when dragging. The change did make it more responsive, but did not completely eliminate the lag.

Since it is just a minor improvement, should I revert the change? Or leave it and update the comment? What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, do you agree then that the comment should be updated to "asynchronously"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Either change the comment or revert this change to calling AddGeometryForRenderPackages. Like I said, it was a marginal improvement and might be unnecessary. Based on the comment, it seems pretty intentional that it was supposed to be synchronous. I'm good reverting the change.

Copy link
Contributor

@aparajit-pratap aparajit-pratap Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about deciding between synchronous vs async, or how to assess that. If you feel that the dragging is smoother with the latter, then let's keep the change.

@aparajit-pratap
Copy link
Contributor

aparajit-pratap commented Jan 26, 2026

@jasonstratton, you mention in the description - Gizmo redraw failure during drag. Is there a failure during drag? What exactly is this failure? Is it pointed out in the ticket, or is this a separate bug that you fixed in this PR itself?

Secondly you mention Camera drift when zoomed in close. I could only reproduce the gizmo drift with panning and orbiting of the camera. What do you mean by zoomed in close? Does that also cause the drift?

@jasonstratton
Copy link
Contributor Author

@jasonstratton, you mention in the description - Gizmo redraw failure during drag. Is there a failure during drag? What exactly is this failure? Is it pointed out in the ticket, or is this a separate bug that you fixed in this PR itself?

There were 2 issues mentioned in the Jira issue.

  • The gizmo will drift when panning/orbiting
  • The gizmo does not update when being dragged

So the question about the "Gizmo redraw failure during drag" refers to the latter. When clicking on one of the arrows in the gizmo and dragging, the gizmo remains stationary until MouseUp. So the PR will redraw the Gizmo when dragging it so that it follows the cursor motion.

If I understand the PR you located, it was an optimization so that the geometry associated with the selected node does not move. I imagine there was a performance issue when updating the geometry, but the regression after that change was that the Gizmo did not update. Does that sound correct to you?

Secondly you mention Camera drift when zoomed in close. I could only reproduce the gizmo drift with panning and orbiting of the camera. What do you mean by zoomed in close? Does that also cause the drift?

I while fixing the bug I got into a state where the Gizmo drift did not happen, but when I zoomed in and then panned/orbited, the gizmo drift did happen. ... This may have been an issue with my testing, but it did happen multiple times. I then zoomed out and the drift would continue. But if I tried translating the gizmo again and then pan\orbit again, the drift would not occur again until I zoomed in again. I do not recall which line change corrected this behavior.

@aparajit-pratap
Copy link
Contributor

aparajit-pratap commented Jan 26, 2026

@jasonstratton, you mention in the description - Gizmo redraw failure during drag. Is there a failure during drag? What exactly is this failure? Is it pointed out in the ticket, or is this a separate bug that you fixed in this PR itself?

There were 2 issues mentioned in the Jira issue.

  • The gizmo will drift when panning/orbiting
  • The gizmo does not update when being dragged

So the question about the "Gizmo redraw failure during drag" refers to the latter. When clicking on one of the arrows in the gizmo and dragging, the gizmo remains stationary until MouseUp. So the PR will redraw the Gizmo when dragging it so that it follows the cursor motion.

If I understand the PR you located, it was an optimization so that the geometry associated with the selected node does not move. I imagine there was a performance issue when updating the geometry, but the regression after that change was that the Gizmo did not update. Does that sound correct to you?

Secondly you mention Camera drift when zoomed in close. I could only reproduce the gizmo drift with panning and orbiting of the camera. What do you mean by zoomed in close? Does that also cause the drift?

I while fixing the bug I got into a state where the Gizmo drift did not happen, but when I zoomed in and then panned/orbited, the gizmo drift did happen. ... This may have been an issue with my testing, but it did happen multiple times. I then zoomed out and the drift would continue. But if I tried translating the gizmo again and then pan\orbit again, the drift would not occur again until I zoomed in again. I do not recall which line change corrected this behavior.

@jasonstratton, the code changes seem fine to me. However, your observations above are confusing and not what I've experienced. Maybe, we could discuss this online tomorrow?

The PR I located was indeed an optimization so that the geometry associated with the selected node does not move until mouse-up. This may not be that big a deal, but if you have heavy downstream logic that depends on that point position updating, the graph will reexecute that many times for each point position update, which could be repeated performance-heavy computation of largely disposable intermediate results.

The regression after that change was that the Gizmo drifted on panning and orbiting - at least that is what I observed. I also have an explanation for it: the PR introduced changes to the mouse-up handler that executed even after a camera change (pan/orbit) event, which was unnecessary and caused the gizmo to jump.


/// <summary>
/// Verifies that ClearHitState method exists and properly clears hitAxis and hitPlane fields.
/// This is the core fix for Issue 2 (camera drift prevention).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is misleading. ClearHitState is just a guardrail, not the main fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I will update.

{
// Act - MouseUp should not throw and should be ignored in orbit mode
var leftButtonArgs = CreateMouseButtonEventArgs(MouseButton.Left);
Assert.DoesNotThrow(() => mouseUpMethod.Invoke(manipulator, new object[] { null, leftButtonArgs }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does not throwing from the method verify that mouseUp is ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but if it doesn't return, that doesn't mean that it will throw.

Copy link
Contributor

@aparajit-pratap aparajit-pratap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments and questions, then LGTM.

@jasonstratton jasonstratton merged commit f824108 into DynamoDS:master Jan 27, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants