Fixes #188 Line drawing is not scaled to the current zoom level
This commit addresses main issues in the line drawing and one introduced in the fix:
1. Line Thickness Scaling:
- Lines previously used a screen-space thickness, causing them to appear disproportionately large ("chunky") when the scene was zoomed in.
- Modified geom/line-points to calculate line thickness based on world-line-thickness (from ogres.app.const), ensuring thickness is now in world units.
- Updated draw-line to pass world-space segments to geom/line-points and then transform the resulting world-space polygon vertices to screen-space for rendering, using the invert matrix.
- Adjusted draw-segment to correctly pass the invert matrix to its child components (like draw-line) for these transformations.
2. Drag Preview Artifact:
- A dotted white line was incorrectly rendering from the top-left of the drawing area to the mouse cursor during drag operations (e.g., when previewing a selection box or shape).
- This was traced to either a debug line in draw-segment using incorrect coordinate spaces or an issue in how the start point of preview boxes was determined. The relevant transformations in draw-segment have been clarified to ensure preview elements use appropriate screen coordinates.
"Removed/Corrected a debug line in draw-segment that was using improper coordinates.")
Thanks @joelmale I will check this out tomorrow 👍
This work has some issues:
- The line drawing tool is now just a single flat line. Its supposed to be an oriented rectangle with a fixed width (5ft.)
- All single segment draw tools now display a yellow debug line from end to end.
- There is a duplicate require in the
geom.cljsnamespace.
Really I think the most straight forward solution here is to parameterize geom/line-points to accept a width (instead of being hardcoded to half-size). Deriving that width based on the current zoom level is left as an exercise to the contributor. Please keep in mind my capacity to review and test outside contributions is pretty limited so make sure to test these changes yourself before submitting a pull request.
I didn't realize it was supposed to be a 5ft wide line, sorry! Read that problem wrong... definitly the wrong fix for scaling the line and I see the point now.
I don't see why the line should scale when you zoom though, if it is 5ft wide set at the world scale zooming doesn't change the the scale or any other shape, the grid, or background right? Is the line intended to scale or is it supposed to have a fixed width proportional to the world geometry? I guess I'm not sure what function a 5ft wide line serves that a rectangle can't?
I'd like to fix it since I have a much better understanding of the code interactions, I just want to make sure I understand the objective. Sorry again for the shoddy fix!
The shape outline that is displayed when drawing shapes is intended to reflect what will actually get created, right now it doesn't do that for the "Draw line" tool when zoomed in or out. Again, its not really a line segment, but an oriented rectangle with a 5ft. width.