Fixed antialiased option for Polygon2D / Line2D
Polygon2D: The property wasn't used anymore after switching from canvas_item_add_polygon() to canvas_item_add_triangle_array() for drawing. Line2D: Added the same property as for Polygon2D & fixed smooth line drawing to use indices correctly. Fixes #26823
This commit is contained in:
parent
636bc5c32f
commit
e6ebc43d72
|
@ -284,6 +284,15 @@ public:
|
||||||
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 6);
|
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class N, class M>
|
||||||
|
static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4, const Variant &p_def5, const Variant &p_def6, const Variant &p_def7) {
|
||||||
|
|
||||||
|
MethodBind *bind = create_method_bind(p_method);
|
||||||
|
const Variant *ptr[7] = { &p_def1, &p_def2, &p_def3, &p_def4, &p_def5, &p_def6, &p_def7 };
|
||||||
|
|
||||||
|
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 7);
|
||||||
|
}
|
||||||
|
|
||||||
template <class M>
|
template <class M>
|
||||||
static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>()) {
|
static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>()) {
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,9 @@
|
||||||
</method>
|
</method>
|
||||||
</methods>
|
</methods>
|
||||||
<members>
|
<members>
|
||||||
|
<member name="antialiased" type="bool" setter="set_antialiased" getter="get_antialiased" default="false">
|
||||||
|
If [code]true[/code], the line's border will be anti-aliased.
|
||||||
|
</member>
|
||||||
<member name="begin_cap_mode" type="int" setter="set_begin_cap_mode" getter="get_begin_cap_mode" enum="Line2D.LineCapMode" default="0">
|
<member name="begin_cap_mode" type="int" setter="set_begin_cap_mode" getter="get_begin_cap_mode" enum="Line2D.LineCapMode" default="0">
|
||||||
Controls the style of the line's first point. Use [code]LINE_CAP_*[/code] constants.
|
Controls the style of the line's first point. Use [code]LINE_CAP_*[/code] constants.
|
||||||
</member>
|
</member>
|
||||||
|
|
|
@ -411,6 +411,8 @@
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="9" name="normal_map" type="RID">
|
<argument index="9" name="normal_map" type="RID">
|
||||||
</argument>
|
</argument>
|
||||||
|
<argument index="10" name="antialiased" type="bool" default="false">
|
||||||
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
|
|
@ -406,6 +406,66 @@ void RasterizerCanvasGLES2::_draw_generic(GLuint p_primitive, int p_vertex_count
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RasterizerCanvasGLES2::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
||||||
|
#ifndef GLES_OVER_GL
|
||||||
|
// Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint32_t buffer_ofs = 0;
|
||||||
|
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * p_vertex_count, p_vertices);
|
||||||
|
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
|
||||||
|
glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
||||||
|
buffer_ofs += sizeof(Vector2) * p_vertex_count;
|
||||||
|
|
||||||
|
if (p_singlecolor) {
|
||||||
|
glDisableVertexAttribArray(VS::ARRAY_COLOR);
|
||||||
|
Color m = *p_colors;
|
||||||
|
glVertexAttrib4f(VS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
|
||||||
|
} else if (!p_colors) {
|
||||||
|
glDisableVertexAttribArray(VS::ARRAY_COLOR);
|
||||||
|
glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
|
||||||
|
} else {
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors);
|
||||||
|
glEnableVertexAttribArray(VS::ARRAY_COLOR);
|
||||||
|
glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||||
|
buffer_ofs += sizeof(Color) * p_vertex_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_uvs) {
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs);
|
||||||
|
glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
|
||||||
|
glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||||
|
buffer_ofs += sizeof(Vector2) * p_vertex_count;
|
||||||
|
} else {
|
||||||
|
glDisableVertexAttribArray(VS::ARRAY_TEX_UV);
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
|
||||||
|
#ifndef GLES_OVER_GL
|
||||||
|
// Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
|
||||||
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, NULL, GL_DYNAMIC_DRAW);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (storage->config.support_32_bits_indices) { //should check for
|
||||||
|
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(int) * p_index_count, p_indices);
|
||||||
|
glDrawElements(p_primitive, p_index_count, GL_UNSIGNED_INT, 0);
|
||||||
|
} else {
|
||||||
|
uint16_t *index16 = (uint16_t *)alloca(sizeof(uint16_t) * p_index_count);
|
||||||
|
for (int i = 0; i < p_index_count; i++) {
|
||||||
|
index16[i] = uint16_t(p_indices[i]);
|
||||||
|
}
|
||||||
|
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(uint16_t) * p_index_count, index16);
|
||||||
|
glDrawElements(p_primitive, p_index_count, GL_UNSIGNED_SHORT, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void RasterizerCanvasGLES2::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs) {
|
void RasterizerCanvasGLES2::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs) {
|
||||||
|
|
||||||
static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN };
|
static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN };
|
||||||
|
@ -973,7 +1033,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
|
||||||
#ifdef GLES_OVER_GL
|
#ifdef GLES_OVER_GL
|
||||||
if (polygon->antialiased) {
|
if (polygon->antialiased) {
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
_draw_generic(GL_LINE_LOOP, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
|
_draw_generic_indices(GL_LINE_STRIP, polygon->indices.ptr(), polygon->count, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
|
||||||
glDisable(GL_LINE_SMOOTH);
|
glDisable(GL_LINE_SMOOTH);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -118,6 +118,7 @@ public:
|
||||||
_FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs);
|
_FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs);
|
||||||
_FORCE_INLINE_ void _draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights = NULL, const int *p_bones = NULL);
|
_FORCE_INLINE_ void _draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights = NULL, const int *p_bones = NULL);
|
||||||
_FORCE_INLINE_ void _draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
|
_FORCE_INLINE_ void _draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
|
||||||
|
_FORCE_INLINE_ void _draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
|
||||||
|
|
||||||
_FORCE_INLINE_ void _canvas_item_render_commands(Item *p_item, Item *current_clip, bool &reclip, RasterizerStorageGLES2::Material *p_material);
|
_FORCE_INLINE_ void _canvas_item_render_commands(Item *p_item, Item *current_clip, bool &reclip, RasterizerStorageGLES2::Material *p_material);
|
||||||
void _copy_screen(const Rect2 &p_rect);
|
void _copy_screen(const Rect2 &p_rect);
|
||||||
|
|
|
@ -471,6 +471,75 @@ void RasterizerCanvasGLES3::_draw_generic(GLuint p_primitive, int p_vertex_count
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RasterizerCanvasGLES3::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
|
||||||
|
|
||||||
|
glBindVertexArray(data.polygon_buffer_pointer_array);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
||||||
|
|
||||||
|
#ifndef GLES_OVER_GL
|
||||||
|
// Orphan the buffers to avoid CPU/GPU sync points caused by glBufferSubData
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW);
|
||||||
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, NULL, GL_DYNAMIC_DRAW);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint32_t buffer_ofs = 0;
|
||||||
|
|
||||||
|
//vertex
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_vertices);
|
||||||
|
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
|
||||||
|
glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, false, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||||
|
buffer_ofs += sizeof(Vector2) * p_vertex_count;
|
||||||
|
//color
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
ERR_FAIL_COND(buffer_ofs > data.polygon_buffer_size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (p_singlecolor) {
|
||||||
|
glDisableVertexAttribArray(VS::ARRAY_COLOR);
|
||||||
|
Color m = *p_colors;
|
||||||
|
glVertexAttrib4f(VS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
|
||||||
|
} else if (!p_colors) {
|
||||||
|
glDisableVertexAttribArray(VS::ARRAY_COLOR);
|
||||||
|
glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors);
|
||||||
|
glEnableVertexAttribArray(VS::ARRAY_COLOR);
|
||||||
|
glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||||
|
buffer_ofs += sizeof(Color) * p_vertex_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
ERR_FAIL_COND(buffer_ofs > data.polygon_buffer_size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (p_uvs) {
|
||||||
|
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs);
|
||||||
|
glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
|
||||||
|
glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, false, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||||
|
buffer_ofs += sizeof(Vector2) * p_vertex_count;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
glDisableVertexAttribArray(VS::ARRAY_TEX_UV);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
ERR_FAIL_COND(buffer_ofs > data.polygon_buffer_size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//bind the indices buffer.
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
|
||||||
|
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(int) * p_index_count, p_indices);
|
||||||
|
|
||||||
|
//draw the triangles.
|
||||||
|
glDrawElements(p_primitive, p_index_count, GL_UNSIGNED_INT, 0);
|
||||||
|
|
||||||
|
storage->frame.canvas_draw_commands++;
|
||||||
|
|
||||||
|
glBindVertexArray(0);
|
||||||
|
}
|
||||||
|
|
||||||
void RasterizerCanvasGLES3::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs) {
|
void RasterizerCanvasGLES3::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs) {
|
||||||
|
|
||||||
static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN };
|
static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN };
|
||||||
|
@ -824,7 +893,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
|
||||||
#ifdef GLES_OVER_GL
|
#ifdef GLES_OVER_GL
|
||||||
if (polygon->antialiased) {
|
if (polygon->antialiased) {
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
_draw_generic(GL_LINE_LOOP, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
|
_draw_generic_indices(GL_LINE_STRIP, polygon->indices.ptr(), polygon->count, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
|
||||||
glDisable(GL_LINE_SMOOTH);
|
glDisable(GL_LINE_SMOOTH);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -132,6 +132,7 @@ public:
|
||||||
_FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs);
|
_FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs);
|
||||||
_FORCE_INLINE_ void _draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const int *p_bones, const float *p_weights);
|
_FORCE_INLINE_ void _draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const int *p_bones, const float *p_weights);
|
||||||
_FORCE_INLINE_ void _draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
|
_FORCE_INLINE_ void _draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
|
||||||
|
_FORCE_INLINE_ void _draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
|
||||||
|
|
||||||
_FORCE_INLINE_ void _canvas_item_render_commands(Item *p_item, Item *current_clip, bool &reclip);
|
_FORCE_INLINE_ void _canvas_item_render_commands(Item *p_item, Item *current_clip, bool &reclip);
|
||||||
_FORCE_INLINE_ void _copy_texscreen(const Rect2 &p_rect);
|
_FORCE_INLINE_ void _copy_texscreen(const Rect2 &p_rect);
|
||||||
|
|
|
@ -47,6 +47,7 @@ Line2D::Line2D() {
|
||||||
_texture_mode = LINE_TEXTURE_NONE;
|
_texture_mode = LINE_TEXTURE_NONE;
|
||||||
_sharp_limit = 2.f;
|
_sharp_limit = 2.f;
|
||||||
_round_precision = 8;
|
_round_precision = 8;
|
||||||
|
_antialiased = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect2 Line2D::_edit_get_rect() const {
|
Rect2 Line2D::_edit_get_rect() const {
|
||||||
|
@ -260,6 +261,15 @@ int Line2D::get_round_precision() const {
|
||||||
return _round_precision;
|
return _round_precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Line2D::set_antialiased(bool p_antialiased) {
|
||||||
|
_antialiased = p_antialiased;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Line2D::get_antialiased() const {
|
||||||
|
return _antialiased;
|
||||||
|
}
|
||||||
|
|
||||||
void Line2D::_draw() {
|
void Line2D::_draw() {
|
||||||
if (_points.size() <= 1 || _width == 0.f)
|
if (_points.size() <= 1 || _width == 0.f)
|
||||||
return;
|
return;
|
||||||
|
@ -305,8 +315,8 @@ void Line2D::_draw() {
|
||||||
lb.vertices,
|
lb.vertices,
|
||||||
lb.colors,
|
lb.colors,
|
||||||
lb.uvs, Vector<int>(), Vector<float>(),
|
lb.uvs, Vector<int>(), Vector<float>(),
|
||||||
|
texture_rid, -1, RID(),
|
||||||
texture_rid);
|
_antialiased);
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
// Draw wireframe
|
// 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("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("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::POOL_VECTOR2_ARRAY, "points"), "set_points", "get_points");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
|
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");
|
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_GROUP("Border", "");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sharp_limit"), "set_sharp_limit", "get_sharp_limit");
|
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::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_SHARP);
|
||||||
BIND_ENUM_CONSTANT(LINE_JOINT_BEVEL);
|
BIND_ENUM_CONSTANT(LINE_JOINT_BEVEL);
|
||||||
|
|
|
@ -108,6 +108,9 @@ public:
|
||||||
void set_round_precision(int precision);
|
void set_round_precision(int precision);
|
||||||
int get_round_precision() const;
|
int get_round_precision() const;
|
||||||
|
|
||||||
|
void set_antialiased(bool p_antialiased);
|
||||||
|
bool get_antialiased() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
void _draw();
|
void _draw();
|
||||||
|
@ -131,6 +134,7 @@ private:
|
||||||
LineTextureMode _texture_mode;
|
LineTextureMode _texture_mode;
|
||||||
float _sharp_limit;
|
float _sharp_limit;
|
||||||
int _round_precision;
|
int _round_precision;
|
||||||
|
bool _antialiased;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LINE2D_H
|
#endif // LINE2D_H
|
||||||
|
|
|
@ -308,7 +308,7 @@ void Polygon2D::_notification(int p_what) {
|
||||||
if (invert || polygons.size() == 0) {
|
if (invert || polygons.size() == 0) {
|
||||||
Vector<int> indices = Geometry::triangulate_polygon(points);
|
Vector<int> indices = Geometry::triangulate_polygon(points);
|
||||||
if (indices.size()) {
|
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 {
|
} else {
|
||||||
//draw individual polygons
|
//draw individual polygons
|
||||||
|
@ -342,7 +342,7 @@ void Polygon2D::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (total_indices.size()) {
|
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
|
#if 0
|
||||||
|
|
|
@ -781,7 +781,7 @@ void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2
|
||||||
canvas_item->commands.push_back(polygon);
|
canvas_item->commands.push_back(polygon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights, RID p_texture, int p_count, RID p_normal_map) {
|
void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights, RID p_texture, int p_count, RID p_normal_map, bool p_antialiased) {
|
||||||
|
|
||||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||||
ERR_FAIL_COND(!canvas_item);
|
ERR_FAIL_COND(!canvas_item);
|
||||||
|
@ -820,7 +820,7 @@ void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector
|
||||||
polygon->weights = p_weights;
|
polygon->weights = p_weights;
|
||||||
polygon->indices = indices;
|
polygon->indices = indices;
|
||||||
polygon->count = count;
|
polygon->count = count;
|
||||||
polygon->antialiased = false;
|
polygon->antialiased = p_antialiased;
|
||||||
canvas_item->rect_dirty = true;
|
canvas_item->rect_dirty = true;
|
||||||
|
|
||||||
canvas_item->commands.push_back(polygon);
|
canvas_item->commands.push_back(polygon);
|
||||||
|
|
|
@ -200,7 +200,7 @@ public:
|
||||||
void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode = VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode = VS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID());
|
void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode = VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode = VS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID());
|
||||||
void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID());
|
void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID());
|
||||||
void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false);
|
void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false);
|
||||||
void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID());
|
void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), bool p_antialiased = false);
|
||||||
void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID());
|
void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID());
|
||||||
void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID());
|
void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID());
|
||||||
void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal);
|
void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal);
|
||||||
|
|
|
@ -602,7 +602,7 @@ public:
|
||||||
BIND11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID)
|
BIND11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID)
|
||||||
BIND7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID)
|
BIND7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID)
|
||||||
BIND7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool)
|
BIND7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool)
|
||||||
BIND10(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, const Vector<int> &, const Vector<float> &, RID, int, RID)
|
BIND11(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, const Vector<int> &, const Vector<float> &, RID, int, RID, bool)
|
||||||
BIND6(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID, RID)
|
BIND6(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID, RID)
|
||||||
BIND4(canvas_item_add_multimesh, RID, RID, RID, RID)
|
BIND4(canvas_item_add_multimesh, RID, RID, RID, RID)
|
||||||
BIND4(canvas_item_add_particles, RID, RID, RID, RID)
|
BIND4(canvas_item_add_particles, RID, RID, RID, RID)
|
||||||
|
|
|
@ -520,7 +520,7 @@ public:
|
||||||
FUNC11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID)
|
FUNC11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID)
|
||||||
FUNC7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID)
|
FUNC7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID)
|
||||||
FUNC7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool)
|
FUNC7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool)
|
||||||
FUNC10(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, const Vector<int> &, const Vector<float> &, RID, int, RID)
|
FUNC11(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, const Vector<int> &, const Vector<float> &, RID, int, RID, bool)
|
||||||
FUNC6(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID, RID)
|
FUNC6(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID, RID)
|
||||||
FUNC4(canvas_item_add_multimesh, RID, RID, RID, RID)
|
FUNC4(canvas_item_add_multimesh, RID, RID, RID, RID)
|
||||||
FUNC4(canvas_item_add_particles, RID, RID, RID, RID)
|
FUNC4(canvas_item_add_particles, RID, RID, RID, RID)
|
||||||
|
|
|
@ -1973,7 +1973,7 @@ void VisualServer::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("canvas_item_add_nine_patch", "item", "rect", "source", "texture", "topleft", "bottomright", "x_axis_mode", "y_axis_mode", "draw_center", "modulate", "normal_map"), &VisualServer::canvas_item_add_nine_patch, DEFVAL(NINE_PATCH_STRETCH), DEFVAL(NINE_PATCH_STRETCH), DEFVAL(true), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()));
|
ClassDB::bind_method(D_METHOD("canvas_item_add_nine_patch", "item", "rect", "source", "texture", "topleft", "bottomright", "x_axis_mode", "y_axis_mode", "draw_center", "modulate", "normal_map"), &VisualServer::canvas_item_add_nine_patch, DEFVAL(NINE_PATCH_STRETCH), DEFVAL(NINE_PATCH_STRETCH), DEFVAL(true), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()));
|
||||||
ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture", "width", "normal_map"), &VisualServer::canvas_item_add_primitive, DEFVAL(1.0), DEFVAL(RID()));
|
ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture", "width", "normal_map"), &VisualServer::canvas_item_add_primitive, DEFVAL(1.0), DEFVAL(RID()));
|
||||||
ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &VisualServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()), DEFVAL(RID()), DEFVAL(false));
|
ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &VisualServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()), DEFVAL(RID()), DEFVAL(false));
|
||||||
ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count", "normal_map"), &VisualServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID()));
|
ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count", "normal_map", "antialiased"), &VisualServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID()), DEFVAL(false));
|
||||||
ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "transform", "modulate", "texture", "normal_map"), &VisualServer::canvas_item_add_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()), DEFVAL(RID()));
|
ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "transform", "modulate", "texture", "normal_map"), &VisualServer::canvas_item_add_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()), DEFVAL(RID()));
|
||||||
ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture", "normal_map"), &VisualServer::canvas_item_add_multimesh, DEFVAL(RID()));
|
ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture", "normal_map"), &VisualServer::canvas_item_add_multimesh, DEFVAL(RID()));
|
||||||
ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture", "normal_map"), &VisualServer::canvas_item_add_particles);
|
ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture", "normal_map"), &VisualServer::canvas_item_add_particles);
|
||||||
|
|
|
@ -903,7 +903,7 @@ public:
|
||||||
virtual void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, NinePatchAxisMode p_x_axis_mode = NINE_PATCH_STRETCH, NinePatchAxisMode p_y_axis_mode = NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID()) = 0;
|
virtual void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, NinePatchAxisMode p_x_axis_mode = NINE_PATCH_STRETCH, NinePatchAxisMode p_y_axis_mode = NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID()) = 0;
|
||||||
virtual void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID()) = 0;
|
virtual void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID()) = 0;
|
||||||
virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false) = 0;
|
virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false) = 0;
|
||||||
virtual void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID()) = 0;
|
virtual void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), bool p_antialiased = false) = 0;
|
||||||
virtual void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID()) = 0;
|
virtual void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID()) = 0;
|
||||||
virtual void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID()) = 0;
|
virtual void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID()) = 0;
|
||||||
virtual void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map) = 0;
|
virtual void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map) = 0;
|
||||||
|
|
Loading…
Reference in New Issue