diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-29 14:31:05 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-29 14:31:05 +0400 |
commit | 37489d71c7f0007ffc3aa252a4cc63d1aa903399 (patch) | |
tree | 8d535c6ff229d8a30855a88a8cb3e2051e0485e8 /source/blender/bmesh/tools/bmesh_triangulate.c | |
parent | 97a5cd92bc807a03c4983ec70b1b961491062b13 (diff) |
Triangulate modifier no longer uses bmesh operator api call, instead add a BM_mesh_triangulate() function. Gives ~2x speedup in my tests on an optimized build.
Diffstat (limited to 'source/blender/bmesh/tools/bmesh_triangulate.c')
-rw-r--r-- | source/blender/bmesh/tools/bmesh_triangulate.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/source/blender/bmesh/tools/bmesh_triangulate.c b/source/blender/bmesh/tools/bmesh_triangulate.c new file mode 100644 index 00000000000..7e6e41a12e6 --- /dev/null +++ b/source/blender/bmesh/tools/bmesh_triangulate.c @@ -0,0 +1,66 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Joseph Eagar + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/bmesh/tools/bmesh_triangulate.c + * \ingroup bmesh + * + * Triangulate. + * + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" +#include "BLI_array.h" + +#include "bmesh.h" + +#include "bmesh_triangulate.h" /* own include */ + +void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only) +{ + BMIter iter; + BMFace *face; + float (*projectverts)[3] = NULL; + BLI_array_declare(projectverts); + + if (tag_only == false) { + BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) { + BLI_array_empty(projectverts); + BLI_array_reserve(projectverts, face->len * 3); + + BM_face_triangulate(bm, face, projectverts, NULL, use_beauty, false); + } + } + else { + BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) { + if (BM_elem_flag_test(face, BM_ELEM_TAG)) { + BLI_array_empty(projectverts); + BLI_array_grow_items(projectverts, face->len * 3); + + BM_face_triangulate(bm, face, projectverts, NULL, use_beauty, true); + } + } + } + + BLI_array_free(projectverts); +} |