From 325a02e4af082fcef6173fb1a100eab2ecd936b1 Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Mon, 18 Apr 2016 20:33:54 +0300 Subject: [PATCH] Add a add_triangle_fan method to SurfaceTool Closes #4298 --- scene/resources/surface_tool.cpp | 31 +++++++++++++++++++++++++++++++ scene/resources/surface_tool.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index e3a02420c7a..de4bb4122d4 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "surface_tool.h" +#include "method_bind_ext.inc" #define _VERTEX_SNAP 0.0001 #define EQ_VERTEX_DIST 0.00001 @@ -196,6 +197,35 @@ void SurfaceTool::add_smooth_group(bool p_smooth) { } } +void SurfaceTool::add_triangle_fan(const Vector& p_vertexes, const Vector& p_uvs, const Vector& p_colors,const Vector& p_uv2s, const Vector& p_normals, const Vector& p_tangents) { + ERR_FAIL_COND(!begun); + ERR_FAIL_COND(primitive!=Mesh::PRIMITIVE_TRIANGLES); + ERR_FAIL_COND(p_vertexes.size()<3); + +#define ADD_POINT(n)\ + {\ + if(p_colors.size() > n)\ + add_color(p_colors[n]);\ + if(p_uvs.size() > n)\ + add_uv(p_uvs[n]);\ + if(p_uv2s.size() > n)\ + add_uv2(p_uv2s[n]);\ + if(p_normals.size() > n)\ + add_normal(p_normals[n]);\ + if(p_tangents.size() > n)\ + add_tangent(p_tangents[n]);\ + add_vertex(p_vertexes[n]);\ + } + + for(int i=0;i()), DEFVAL(Vector()), DEFVAL(Vector()),DEFVAL(Vector()), DEFVAL(Vector())); ObjectTypeDB::bind_method(_MD("set_material","material:Material"),&SurfaceTool::set_material); ObjectTypeDB::bind_method(_MD("index"),&SurfaceTool::index); ObjectTypeDB::bind_method(_MD("deindex"),&SurfaceTool::deindex); diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h index 1d329f23c01..fa9724b1420 100644 --- a/scene/resources/surface_tool.h +++ b/scene/resources/surface_tool.h @@ -108,6 +108,8 @@ public: void add_weights( const Vector& p_weights); void add_smooth_group(bool p_smooth); + void add_triangle_fan( const Vector& p_vertexes, const Vector& p_uvs=Vector(), const Vector& p_colors=Vector(), const Vector& p_uv2s=Vector(), const Vector& p_normals=Vector(), const Vector& p_tangents=Vector() ); + void add_index( int p_index); void index();