diff options
| author | Juan Linietsky | 2017-08-19 13:14:04 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2017-08-19 13:14:38 -0300 |
| commit | 8fc6bb8f771c520c15320c3b4be561abc648d65d (patch) | |
| tree | dd02ad9af0e5bc87505c26ae6093426f49d58195 /scene/2d/polygon_2d.cpp | |
| parent | 01e447f3df570ab6a43d43e4d354b0f4bc4370fa (diff) | |
| download | godot-8fc6bb8f771c520c15320c3b4be561abc648d65d.tar.gz godot-8fc6bb8f771c520c15320c3b4be561abc648d65d.tar.zst godot-8fc6bb8f771c520c15320c3b4be561abc648d65d.zip | |
Added polygon antialiasing, but it does not work on nvidia. Will have to try something else..
Diffstat (limited to 'scene/2d/polygon_2d.cpp')
| -rw-r--r-- | scene/2d/polygon_2d.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 5c1c953a3..7e2d6d1b5 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -176,9 +176,10 @@ void Polygon2D::_notification(int p_what) { } } - Vector<int> indices = Geometry::triangulate_polygon(points); + // Vector<int> indices = Geometry::triangulate_polygon(points); + // VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID()); - VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID()); + VS::get_singleton()->canvas_item_add_polygon(get_canvas_item(), points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID(), RID(), antialiased); } break; } @@ -294,6 +295,16 @@ bool Polygon2D::get_invert() const { return invert; } +void Polygon2D::set_antialiased(bool p_antialiased) { + + antialiased = p_antialiased; + update(); +} +bool Polygon2D::get_antialiased() const { + + return antialiased; +} + void Polygon2D::set_invert_border(float p_invert_border) { invert_border = p_invert_border; @@ -348,6 +359,9 @@ void Polygon2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_invert", "invert"), &Polygon2D::set_invert); ClassDB::bind_method(D_METHOD("get_invert"), &Polygon2D::get_invert); + ClassDB::bind_method(D_METHOD("set_antialiased", "antialiased"), &Polygon2D::set_antialiased); + ClassDB::bind_method(D_METHOD("get_antialiased"), &Polygon2D::get_antialiased); + ClassDB::bind_method(D_METHOD("set_invert_border", "invert_border"), &Polygon2D::set_invert_border); ClassDB::bind_method(D_METHOD("get_invert_border"), &Polygon2D::get_invert_border); @@ -359,6 +373,7 @@ void Polygon2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); ADD_PROPERTY(PropertyInfo(Variant::POOL_COLOR_ARRAY, "vertex_colors"), "set_vertex_colors", "get_vertex_colors"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "antialiased"), "set_antialiased", "get_antialiased"); ADD_GROUP("Texture", ""); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); ADD_GROUP("Texture", "texture_"); @@ -375,6 +390,7 @@ Polygon2D::Polygon2D() { invert = 0; invert_border = 100; + antialiased = false; tex_rot = 0; tex_tile = true; tex_scale = Vector2(1, 1); |
