Transform cage incorrect when layer has zero width

#4619 · open · 2 comments

View on GitHub ↗

0HyperCube

## Reproduction - New document - Draw rectangle - Switch select tool - <kbd>s</kbd> <kbd>x</kbd> <kbd>0</kbd> (or set the scale x to be zero in the properties panel). - Observe transform bounds/cage offset ## Video https://github.com/user-attachments/assets/56e9ec75-549a-435d-8293-a3cf434e7377 ## Relevant code When putting into the click targets, the inverse of the transform is applied. However if det=0 then the identity is used: https://github.com/GraphiteEditor/Graphite/blob/ae321b3409113b238f1482a5ad71cbfff6929602/node-graph/libraries/rendering/src/renderer.rs#L3293 However in the select tool if the transform det=0, a random small number is added to it and the inverse of that transform is used: https://github.com/GraphiteEditor/Graphite/blob/ae321b3409113b238f1482a5ad71cbfff6929602/editor/src/messages/tool/tool_messages/select_tool.rs#L771-L774 This has the effect of applying any translation twice for the bounding box when det=0.

Comments

shubhtrek

I’m thinking of handling the zero-determinant case consistently in both places by removing the `1e-4` workaround and using an identity fallback: ```rust // Select tool let inverse = if transform.matrix2.determinant() == 0. { DAffine2::IDENTITY } else { transform.inverse() }; ``` And keeping the rendering-side behavior consistent: ```rust // Rendering let transform = if transform.matrix2.determinant() == 0. { DAffine2::IDENTITY } else { transform }; ``` I’ll try this approach locally and test whether it fixes the transform cage offset. Does this approach make sense?

0HyperCube

I am happy to review a PR.