godot
godot copied to clipboard
Refactor `CurveEdit` to use consistent world/view transforms
Currently, CurveEdit
uses a couple of different ways to ensure that points and lines are drawn in the right space. This makes the code harder to understand and maintain.
This PR makes the curve be drawn in view coordinates by transforming every point from world/curve-space into view-space. This ensures there is a single way to scale from curve-space to view-space and vice-versa. By drawing in view-space, we can keep anti-aliasing, which was the main point of the previous changes! 🥳
Other minor changes, resulting in fewer lines of code overall:
- Removed CanvasItemPlotCurve, since it was only used in a single place
- Moved
plot_curve_accurate
toCurveEdit
so it can make use of_world_to_view
transform and related functions - Did a pass to make sure vectors are passed around as
const Vector2 &