You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
CanvasItem::draw_polyline Support thin polylines drawn using line strip
This commit is contained in:
@@ -821,6 +821,38 @@ void RendererCanvasCull::canvas_item_add_polyline(RID p_item, const Vector<Point
|
||||
|
||||
Vector<int> indices;
|
||||
int point_count = p_points.size();
|
||||
|
||||
Item::CommandPolygon *pline = canvas_item->alloc_command<Item::CommandPolygon>();
|
||||
ERR_FAIL_COND(!pline);
|
||||
|
||||
if (p_width < 0) {
|
||||
if (p_antialiased) {
|
||||
WARN_PRINT("Antialiasing is not supported for thin polylines drawn using line strips (`p_width < 0`).");
|
||||
}
|
||||
|
||||
pline->primitive = RS::PRIMITIVE_LINE_STRIP;
|
||||
|
||||
if (p_colors.size() == 1 || p_colors.size() == point_count) {
|
||||
pline->polygon.create(indices, p_points, p_colors);
|
||||
} else {
|
||||
Vector<Color> colors;
|
||||
if (p_colors.is_empty()) {
|
||||
colors.push_back(color);
|
||||
} else {
|
||||
colors.resize(point_count);
|
||||
Color *colors_ptr = colors.ptrw();
|
||||
for (int i = 0; i < point_count; i++) {
|
||||
if (i < p_colors.size()) {
|
||||
color = p_colors[i];
|
||||
}
|
||||
colors_ptr[i] = color;
|
||||
}
|
||||
}
|
||||
pline->polygon.create(indices, p_points, colors);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int polyline_point_count = point_count * 2;
|
||||
|
||||
bool loop = p_points[0].is_equal_approx(p_points[point_count - 1]);
|
||||
@@ -845,9 +877,6 @@ void RendererCanvasCull::canvas_item_add_polyline(RID p_item, const Vector<Point
|
||||
}
|
||||
}
|
||||
|
||||
Item::CommandPolygon *pline = canvas_item->alloc_command<Item::CommandPolygon>();
|
||||
ERR_FAIL_COND(!pline);
|
||||
|
||||
PackedColorArray colors;
|
||||
PackedVector2Array points;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user