Skip to content

Exclude viewport zoom from influencing the Transform node set by the drawing tools#4260

Open
Keavon wants to merge 2 commits into
masterfrom
drawing-tools-document-space-transform
Open

Exclude viewport zoom from influencing the Transform node set by the drawing tools#4260
Keavon wants to merge 2 commits into
masterfrom
drawing-tools-document-space-transform

Conversation

@Keavon

@Keavon Keavon commented Jun 21, 2026

Copy link
Copy Markdown
Member

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors shape and drawing tools (such as Arc, Circle, Ellipse, Grid, Polygon, Rectangle, Spiral, Star, Freehand, Pen, Spline, and Text) to use centralized transformation helper functions (viewport_zoom, window_aligned_transform, window_aligned_transform_set, and translation_transform_set) defined in resize.rs. This ensures consistent handling of viewport zoom, tilt, and flip across all tools. The review feedback focuses on optimizing these new helper functions and their usages by simplifying the underlying matrix mathematics, which avoids redundant matrix inversions, point transformations, and multiplications to improve performance and numerical stability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread editor/src/messages/tool/common_functionality/resize.rs
Comment thread editor/src/messages/tool/common_functionality/resize.rs
Comment thread editor/src/messages/tool/common_functionality/resize.rs
Comment thread editor/src/messages/tool/tool_messages/text_tool.rs Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

4 issues found across 14 files

Confidence score: 3/5

  • In editor/src/messages/tool/tool_messages/spline_tool.rs (DragStop), translation is still computed in viewport space while PointerMove was switched to document-space, so ending a drag can apply a different delta and cause visible jump/drift at mouse-up—update DragStop to use the same document_to_viewport.inverse().transform_vector2(...) path before merging.
  • In editor/src/messages/tool/common_functionality/resize.rs, there are a few algebraically redundant inverse/transform steps (duplicate .inverse(), inverse-then-multiply round-trip, and a simplifiable composed transform) that add avoidable matrix work and make the math harder to audit—fold these into the simplified forms and reuse cached inverses to reduce risk of future coordinate bugs.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread editor/src/messages/tool/tool_messages/spline_tool.rs
Comment thread editor/src/messages/tool/common_functionality/resize.rs Outdated
Comment thread editor/src/messages/tool/common_functionality/resize.rs Outdated
Comment thread editor/src/messages/tool/common_functionality/resize.rs Outdated
@Keavon Keavon changed the title Keep viewport zoom out of drawing tools' Transform node Exclude viewport zoom from influencing the Transform node set by the drawing tools Jun 21, 2026
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.

1 participant