summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-12-03 07:51:16 +0100
committerGitHub <noreply@github.com>2019-12-03 07:51:16 +0100
commit10bae7c05b18b73b39fbaf5c118780512832f0b3 (patch)
treebc6c63143e6f26b86dd9c9bf029efbdd862dc4e1 /scene/2d
parent65e6efaa3bb51b69f5b62b5ae67d480ba22aa39d (diff)
parente6ebc43d725710f69094afa6ff47d91e50cce1ad (diff)
Merge pull request #33857 from nekomatata/polygon-2d-antialiasing
Fixed antialiased option for Polygon2D
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/line_2d.cpp18
-rw-r--r--scene/2d/line_2d.h4
-rw-r--r--scene/2d/polygon_2d.cpp4
3 files changed, 22 insertions, 4 deletions
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index ad405fabbb..af3ed671aa 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -47,6 +47,7 @@ Line2D::Line2D() {
_texture_mode = LINE_TEXTURE_NONE;
_sharp_limit = 2.f;
_round_precision = 8;
+ _antialiased = false;
}
Rect2 Line2D::_edit_get_rect() const {
@@ -260,6 +261,15 @@ int Line2D::get_round_precision() const {
return _round_precision;
}
+void Line2D::set_antialiased(bool p_antialiased) {
+ _antialiased = p_antialiased;
+ update();
+}
+
+bool Line2D::get_antialiased() const {
+ return _antialiased;
+}
+
void Line2D::_draw() {
if (_points.size() <= 1 || _width == 0.f)
return;
@@ -305,8 +315,8 @@ void Line2D::_draw() {
lb.vertices,
lb.colors,
lb.uvs, Vector<int>(), Vector<float>(),
-
- texture_rid);
+ texture_rid, -1, RID(),
+ _antialiased);
// DEBUG
// Draw wireframe
@@ -386,6 +396,9 @@ void Line2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_round_precision", "precision"), &Line2D::set_round_precision);
ClassDB::bind_method(D_METHOD("get_round_precision"), &Line2D::get_round_precision);
+ ClassDB::bind_method(D_METHOD("set_antialiased", "antialiased"), &Line2D::set_antialiased);
+ ClassDB::bind_method(D_METHOD("get_antialiased"), &Line2D::get_antialiased);
+
ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR2_ARRAY, "points"), "set_points", "get_points");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "width_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_curve", "get_curve");
@@ -401,6 +414,7 @@ void Line2D::_bind_methods() {
ADD_GROUP("Border", "");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sharp_limit"), "set_sharp_limit", "get_sharp_limit");
ADD_PROPERTY(PropertyInfo(Variant::INT, "round_precision"), "set_round_precision", "get_round_precision");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "antialiased"), "set_antialiased", "get_antialiased");
BIND_ENUM_CONSTANT(LINE_JOINT_SHARP);
BIND_ENUM_CONSTANT(LINE_JOINT_BEVEL);
diff --git a/scene/2d/line_2d.h b/scene/2d/line_2d.h
index 14afa463ba..10b2bf16e4 100644
--- a/scene/2d/line_2d.h
+++ b/scene/2d/line_2d.h
@@ -108,6 +108,9 @@ public:
void set_round_precision(int precision);
int get_round_precision() const;
+ void set_antialiased(bool p_antialiased);
+ bool get_antialiased() const;
+
protected:
void _notification(int p_what);
void _draw();
@@ -131,6 +134,7 @@ private:
LineTextureMode _texture_mode;
float _sharp_limit;
int _round_precision;
+ bool _antialiased;
};
#endif // LINE2D_H
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 5e14959e9d..9fe67a4d7e 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -308,7 +308,7 @@ void Polygon2D::_notification(int p_what) {
if (invert || polygons.size() == 0) {
Vector<int> indices = Geometry::triangulate_polygon(points);
if (indices.size()) {
- VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID());
+ VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, RID(), antialiased);
}
} else {
//draw individual polygons
@@ -342,7 +342,7 @@ void Polygon2D::_notification(int p_what) {
}
if (total_indices.size()) {
- VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), total_indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID());
+ VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), total_indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, RID(), antialiased);
}
#if 0