[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52322] trunk/blender/source/blender/bmesh : move decimator into tools/ dir
Campbell Barton
ideasman42 at gmail.com
Sun Nov 18 09:16:10 CET 2012
Revision: 52322
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52322
Author: campbellbarton
Date: 2012-11-18 08:16:09 +0000 (Sun, 18 Nov 2012)
Log Message:
-----------
move decimator into tools/ dir
Modified Paths:
--------------
trunk/blender/source/blender/bmesh/CMakeLists.txt
trunk/blender/source/blender/bmesh/bmesh.h
Added Paths:
-----------
trunk/blender/source/blender/bmesh/tools/bmesh_decimate.h
trunk/blender/source/blender/bmesh/tools/bmesh_decimate_collapse.c
trunk/blender/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
trunk/blender/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
Removed Paths:
-------------
trunk/blender/source/blender/bmesh/intern/bmesh_decimate.h
trunk/blender/source/blender/bmesh/intern/bmesh_decimate_collapse.c
trunk/blender/source/blender/bmesh/intern/bmesh_decimate_dissolve.c
trunk/blender/source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c
Modified: trunk/blender/source/blender/bmesh/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/bmesh/CMakeLists.txt 2012-11-18 07:41:38 UTC (rev 52321)
+++ trunk/blender/source/blender/bmesh/CMakeLists.txt 2012-11-18 08:16:09 UTC (rev 52322)
@@ -68,10 +68,6 @@
intern/bmesh_construct.h
intern/bmesh_core.c
intern/bmesh_core.h
- intern/bmesh_decimate_collapse.c
- intern/bmesh_decimate_dissolve.c
- intern/bmesh_decimate_unsubdivide.c
- intern/bmesh_decimate.h
intern/bmesh_inline.h
intern/bmesh_interp.c
intern/bmesh_interp.h
@@ -109,6 +105,10 @@
intern/bmesh_error.h
tools/BME_bevel.c
+ tools/bmesh_decimate_collapse.c
+ tools/bmesh_decimate_dissolve.c
+ tools/bmesh_decimate_unsubdivide.c
+ tools/bmesh_decimate.h
bmesh.h
bmesh_class.h
Modified: trunk/blender/source/blender/bmesh/bmesh.h
===================================================================
--- trunk/blender/source/blender/bmesh/bmesh.h 2012-11-18 07:41:38 UTC (rev 52321)
+++ trunk/blender/source/blender/bmesh/bmesh.h 2012-11-18 08:16:09 UTC (rev 52322)
@@ -252,7 +252,6 @@
#include "intern/bmesh_construct.h"
#include "intern/bmesh_core.h"
-#include "intern/bmesh_decimate.h"
#include "intern/bmesh_interp.h"
#include "intern/bmesh_iterators.h"
#include "intern/bmesh_marking.h"
@@ -267,6 +266,8 @@
#include "intern/bmesh_inline.h"
+#include "tools/bmesh_decimate.h"
+
#ifdef __cplusplus
}
#endif
Deleted: trunk/blender/source/blender/bmesh/intern/bmesh_decimate.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_decimate.h 2012-11-18 07:41:38 UTC (rev 52321)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_decimate.h 2012-11-18 08:16:09 UTC (rev 52322)
@@ -1,41 +0,0 @@
-/*
- * ***** 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): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __BMESH_DECIMATE_H__
-#define __BMESH_DECIMATE_H__
-
-/** \file blender/bmesh/intern/bmesh_decimate.h
- * \ingroup bmesh
- */
-
-void BM_mesh_decimate_collapse(BMesh *bm, const float factor, float *vweights, const int do_triangulate);
-
-void BM_mesh_decimate_unsubdivide_ex(BMesh *bm, const int iterations, const int tag_only);
-void BM_mesh_decimate_unsubdivide(BMesh *bm, const int iterations);
-
-void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const int do_dissolve_boundaries,
- BMVert **vinput_arr, const int vinput_len,
- BMEdge **einput_arr, const int einput_len);
-void BM_mesh_decimate_dissolve(BMesh *bm, const float angle_limit, const int do_dissolve_boundaries);
-
-
-#endif /* __BMESH_DECIMATE_H__ */
Deleted: trunk/blender/source/blender/bmesh/intern/bmesh_decimate_collapse.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_decimate_collapse.c 2012-11-18 07:41:38 UTC (rev 52321)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_decimate_collapse.c 2012-11-18 08:16:09 UTC (rev 52322)
@@ -1,1044 +0,0 @@
-/*
- * ***** 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): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/bmesh/intern/bmesh_decimate_collapse.c
- * \ingroup bmesh
- *
- * BMesh decimator that uses an edge collapse method.
- */
-
-#include <stddef.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_scene_types.h"
-
-#include "BLI_math.h"
-#include "BLI_quadric.h"
-#include "BLI_heap.h"
-
-#include "BKE_customdata.h"
-
-#include "bmesh.h"
-#include "bmesh_structure.h"
-#include "bmesh_decimate.h" /* own include */
-
-/* defines for testing */
-#define USE_CUSTOMDATA
-#define USE_TRIANGULATE
-#define USE_VERT_NORMAL_INTERP /* has the advantage that flipped faces don't mess up vertex normals */
-
-/* these checks are for rare cases that we can't avoid since they are valid meshes still */
-#define USE_SAFETY_CHECKS
-
-#define BOUNDARY_PRESERVE_WEIGHT 100.0f
-#define OPTIMIZE_EPS 0.01f /* FLT_EPSILON is too small, see [#33106] */
-#define COST_INVALID FLT_MAX
-
-typedef enum CD_UseFlag {
- CD_DO_VERT = (1 << 0),
- CD_DO_EDGE = (1 << 1),
- CD_DO_LOOP = (1 << 2)
-} CD_UseFlag;
-
-
-/* BMesh Helper Functions
- * ********************** */
-
-/**
- * \param vquadrics must be calloc'd
- */
-static void bm_decim_build_quadrics(BMesh *bm, Quadric *vquadrics)
-{
- BMIter iter;
- BMFace *f;
- BMEdge *e;
-
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- BMLoop *l_first;
- BMLoop *l_iter;
-
- const float *co = BM_FACE_FIRST_LOOP(f)->v->co;
- const float *no = f->no;
- const float offset = -dot_v3v3(no, co);
- Quadric q;
-
- BLI_quadric_from_v3_dist(&q, no, offset);
-
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(l_iter->v)], &q);
- } while ((l_iter = l_iter->next) != l_first);
- }
-
- /* boundary edges */
- BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- if (UNLIKELY(BM_edge_is_boundary(e))) {
- float edge_vector[3];
- float edge_cross[3];
- sub_v3_v3v3(edge_vector, e->v2->co, e->v1->co);
- f = e->l->f;
- cross_v3_v3v3(edge_cross, edge_vector, f->no);
-
- if (normalize_v3(edge_cross) > FLT_EPSILON) {
- Quadric q;
- BLI_quadric_from_v3_dist(&q, edge_cross, -dot_v3v3(edge_cross, e->v1->co));
- BLI_quadric_mul(&q, BOUNDARY_PRESERVE_WEIGHT);
-
- BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(e->v1)], &q);
- BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(e->v2)], &q);
- }
- }
- }
-}
-
-
-static void bm_decim_calc_target_co(BMEdge *e, float optimize_co[3],
- const Quadric *vquadrics)
-{
- /* compute an edge contration target for edge 'e'
- * this is computed by summing it's vertices quadrics and
- * optimizing the result. */
- Quadric q;
-
- BLI_quadric_add_qu_ququ(&q,
- &vquadrics[BM_elem_index_get(e->v1)],
- &vquadrics[BM_elem_index_get(e->v2)]);
-
-
- if (BLI_quadric_optimize(&q, optimize_co, OPTIMIZE_EPS)) {
- return; /* all is good */
- }
- else {
- mid_v3_v3v3(optimize_co, e->v1->co, e->v2->co);
- }
-}
-
-static int bm_edge_collapse_is_degenerate_flip(BMEdge *e, const float optimize_co[3])
-{
- BMIter liter;
- BMLoop *l;
- unsigned int i;
-
- for (i = 0; i < 2; i++) {
- /* loop over both verts */
- BMVert *v = *((&e->v1) + i);
-
- BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
- if (l->e != e && l->prev->e != e) {
- float *co_prev = l->prev->v->co;
- float *co_next = l->next->v->co;
- float cross_exist[3];
- float cross_optim[3];
-
-#if 1
- float vec_other[3]; /* line between the two outer verts, re-use for both cross products */
- float vec_exist[3]; /* before collapse */
- float vec_optim[3]; /* after collapse */
-
- sub_v3_v3v3(vec_other, co_prev, co_next);
- sub_v3_v3v3(vec_exist, co_prev, v->co);
- sub_v3_v3v3(vec_optim, co_prev, optimize_co);
-
- cross_v3_v3v3(cross_exist, vec_other, vec_exist);
- cross_v3_v3v3(cross_optim, vec_other, vec_optim);
-
- /* normalize isn't really needed, but ensures the value at a unit we can compare against */
- normalize_v3(cross_exist);
- normalize_v3(cross_optim);
-#else
- normal_tri_v3(cross_exist, v->co, co_prev, co_next);
- normal_tri_v3(cross_optim, optimize_co, co_prev, co_next);
-#endif
-
- /* use a small value rather then zero so we don't flip a face in multiple steps
- * (first making it zero area, then flipping again)*/
- if (dot_v3v3(cross_exist, cross_optim) <= FLT_EPSILON) {
- //printf("no flip\n");
- return TRUE;
- }
- }
- }
- }
-
- return FALSE;
-}
-
-static void bm_decim_build_edge_cost_single(BMEdge *e,
- const Quadric *vquadrics, const float *vweights,
- Heap *eheap, HeapNode **eheap_table)
-{
- const Quadric *q1, *q2;
- float optimize_co[3];
- float cost;
-
- if (eheap_table[BM_elem_index_get(e)]) {
- BLI_heap_remove(eheap, eheap_table[BM_elem_index_get(e)]);
- }
-
- /* check we can collapse, some edges we better not touch */
- if (BM_edge_is_boundary(e)) {
- if (e->l->f->len == 3) {
- /* pass */
- }
- else {
- /* only collapse tri's */
- eheap_table[BM_elem_index_get(e)] = NULL;
- return;
- }
- }
- else if (BM_edge_is_manifold(e)) {
- if ((e->l->f->len == 3) && (e->l->radial_next->f->len == 3)) {
- /* pass */
- }
- else {
- /* only collapse tri's */
- eheap_table[BM_elem_index_get(e)] = NULL;
- return;
- }
- }
- else {
- eheap_table[BM_elem_index_get(e)] = NULL;
- return;
- }
-
- if (vweights) {
- if ((vweights[BM_elem_index_get(e->v1)] < FLT_EPSILON) &&
- (vweights[BM_elem_index_get(e->v2)] < FLT_EPSILON))
- {
- /* skip collapsing this edge */
- eheap_table[BM_elem_index_get(e)] = NULL;
- return;
- }
- }
- /* end sanity check */
-
-
- bm_decim_calc_target_co(e, optimize_co, vquadrics);
-
- q1 = &vquadrics[BM_elem_index_get(e->v1)];
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list