diff --git a/material_maker/widgets/curve_edit/curve_view.gd b/material_maker/widgets/curve_edit/curve_view.gd index 9ad70c7c..d9afa75b 100644 --- a/material_maker/widgets/curve_edit/curve_view.gd +++ b/material_maker/widgets/curve_edit/curve_view.gd @@ -27,6 +27,7 @@ func _draw(): var p = transform_point(0.25*Vector2(i, i)) draw_line(Vector2(p.x, 0), Vector2(p.x, rect_size.y-1), axes_color) draw_line(Vector2(0, p.y), Vector2(rect_size.x-1, p.y), axes_color) + var points : PoolVector2Array = PoolVector2Array() for i in range(curve.points.size()-1): var p1 = curve.points[i].p var p2 = curve.points[i+1].p @@ -34,6 +35,8 @@ func _draw(): var yac = p1.y+d*curve.points[i].rs var ybc = p2.y-d*curve.points[i+1].ls var p = transform_point(p1) + if points.empty(): + points.push_back(p) var count : int = int(max(1, (transform_point(p2).x-p.x/5.0))) for tt in range(count): var t = (tt+1.0)/count @@ -43,9 +46,9 @@ func _draw(): var t2 = t * t var t3 = t2 * t var x = p1.x+(p2.x-p1.x)*t - var np = transform_point(Vector2(x, p1.y*omt3 + yac*omt2*t*3.0 + ybc*omt*t2*3.0 + p2.y*t3)) - draw_line(p, np, curve_color) - p = np + p = transform_point(Vector2(x, p1.y*omt3 + yac*omt2*t*3.0 + ybc*omt*t2*3.0 + p2.y*t3)) + points.push_back(p) + draw_polyline(points, curve_color) func _on_resize() -> void: update()