[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44518] trunk/blender/source/blender/bmesh : code cleanup,
Campbell Barton
ideasman42 at gmail.com
Tue Feb 28 17:29:59 CET 2012
Revision: 44518
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44518
Author: campbellbarton
Date: 2012-02-28 16:29:48 +0000 (Tue, 28 Feb 2012)
Log Message:
-----------
code cleanup,
- bmesh_newcore.c -> bmesh_core.c.
- add bmesh_interp header.
Modified Paths:
--------------
trunk/blender/source/blender/bmesh/CMakeLists.txt
trunk/blender/source/blender/bmesh/bmesh.h
trunk/blender/source/blender/bmesh/bmesh_marking.h
trunk/blender/source/blender/bmesh/intern/bmesh_private.h
trunk/blender/source/blender/bmesh/intern/bmesh_structure.c
Added Paths:
-----------
trunk/blender/source/blender/bmesh/intern/bmesh_core.c
Removed Paths:
-------------
trunk/blender/source/blender/bmesh/intern/bmesh_newcore.c
Modified: trunk/blender/source/blender/bmesh/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/bmesh/CMakeLists.txt 2012-02-28 15:28:41 UTC (rev 44517)
+++ trunk/blender/source/blender/bmesh/CMakeLists.txt 2012-02-28 16:29:48 UTC (rev 44518)
@@ -88,7 +88,7 @@
intern/bmesh_marking.c
intern/bmesh_mesh.c
intern/bmesh_mods.c
- intern/bmesh_newcore.c
+ intern/bmesh_core.c
intern/bmesh_opdefines.c
intern/bmesh_operator_api_inline.c
intern/bmesh_operators.c
@@ -107,6 +107,7 @@
bmesh.h
bmesh_class.h
bmesh_error.h
+ bmesh_interp.h
bmesh_iterators.h
bmesh_marking.h
bmesh_operator_api.h
Modified: trunk/blender/source/blender/bmesh/bmesh.h
===================================================================
--- trunk/blender/source/blender/bmesh/bmesh.h 2012-02-28 15:28:41 UTC (rev 44517)
+++ trunk/blender/source/blender/bmesh/bmesh.h 2012-02-28 16:29:48 UTC (rev 44518)
@@ -397,33 +397,6 @@
* space, so there might be accuracy issues.*/
int BM_face_point_inside_test(BMesh *bm, BMFace *f, const float co[3]);
-/* Interpolation */
-
-/* projects target onto source for customdata interpolation. note: only
- * does loop customdata. multires is handled. */
-void BM_face_interp_from_face(BMesh *bm, BMFace *target, BMFace *source);
-
-/* projects a single loop, target, onto source for customdata interpolation. multires is handled.
- * if do_vertex is true, target's vert data will also get interpolated.*/
-void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source,
- int do_vertex, int do_multires);
-
-/* smoothes boundaries between multires grids, including some borders in adjacent faces */
-void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f);
-
-/* project the multires grid in target onto source's set of multires grids */
-void BM_loop_interp_multires(BMesh *bm, BMLoop *target, BMFace *source);
-void BM_vert_interp_from_face(BMesh *bm, BMVert *v, BMFace *source);
-
-void BM_data_interp_from_verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, const float fac);
-void BM_data_interp_face_vert_edge(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, BMEdge *e1, const float fac);
-void BM_data_layer_add(BMesh *em, CustomData *data, int type);
-void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name);
-void BM_data_layer_free(BMesh *em, CustomData *data, int type);
-void BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n);
-float BM_elem_float_data_get(CustomData *cd, void *element, int type);
-void BM_elem_float_data_set(CustomData *cd, void *element, int type, const float val);
-
/* get the area of the face */
float BM_face_area_calc(BMesh *bm, BMFace *f);
/* computes the centroid of a face, using the center of the bounding box */
@@ -431,12 +404,6 @@
/* computes the centroid of a face, using the mean average */
void BM_face_center_mean_calc(BMesh *bm, BMFace *f, float center[3]);
-void BM_mesh_select_mode_flush(BMesh *bm);
-
-/* mode independent flushing up/down */
-void BM_mesh_deselect_flush(BMesh *bm);
-void BM_mesh_select_flush(BMesh *bm);
-
/* flag conversion funcs */
char BM_face_flag_from_mflag(const char mflag);
char BM_edge_flag_from_mflag(const short mflag);
@@ -446,12 +413,6 @@
short BM_edge_flag_to_mflag(BMEdge *e);
char BM_vert_flag_to_mflag(BMVert *v);
-
-/* convert MLoop*** in a bmface to mtface and mcol in
- * an MFace*/
-void BM_loops_to_corners(BMesh *bm, struct Mesh *me, int findex,
- BMFace *f, int numTex, int numCol);
-
void BM_loop_kill(BMesh *bm, BMLoop *l);
void BM_face_kill(BMesh *bm, BMFace *f);
void BM_edge_kill(BMesh *bm, BMEdge *e);
@@ -504,6 +465,7 @@
#include "bmesh_operators.h"
#include "bmesh_error.h"
#include "bmesh_queries.h"
+#include "bmesh_interp.h"
#include "bmesh_iterators.h"
#include "bmesh_walkers.h"
#include "intern/bmesh_inline.c"
Modified: trunk/blender/source/blender/bmesh/bmesh_marking.h
===================================================================
--- trunk/blender/source/blender/bmesh/bmesh_marking.h 2012-02-28 15:28:41 UTC (rev 44517)
+++ trunk/blender/source/blender/bmesh/bmesh_marking.h 2012-02-28 16:29:48 UTC (rev 44518)
@@ -57,7 +57,12 @@
void BM_face_select_set(BMesh *bm, BMFace *f, int select);
void BM_select_mode_set(BMesh *bm, int selectmode);
+void BM_mesh_select_mode_flush(BMesh *bm);
+/* mode independent flushing up/down */
+void BM_mesh_deselect_flush(BMesh *bm);
+void BM_mesh_select_flush(BMesh *bm);
+
/* counts number of elements with flag set */
int BM_mesh_count_flag(BMesh *bm, const char htype, const char hflag, int respecthide);
Copied: trunk/blender/source/blender/bmesh/intern/bmesh_core.c (from rev 44515, trunk/blender/source/blender/bmesh/intern/bmesh_newcore.c)
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_core.c (rev 0)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_core.c 2012-02-28 16:29:48 UTC (rev 44518)
@@ -0,0 +1,2039 @@
+/*
+ * ***** 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, Geoffrey Bantle, Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/bmesh/intern/bmesh_newcore.c
+ * \ingroup bmesh
+ *
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math_vector.h"
+
+#include "BKE_DerivedMesh.h"
+
+#include "BLI_listbase.h"
+#include "BLI_array.h"
+
+#include "bmesh.h"
+#include "bmesh_private.h"
+
+/* use so valgrinds memcheck alerts us when undefined index is used.
+ * TESTING ONLY! */
+// #define USE_DEBUG_INDEX_MEMCHECK
+
+static int bmesh_edge_splice(BMesh *bm, BMEdge *e, BMEdge *etarget);
+
+#ifdef USE_DEBUG_INDEX_MEMCHECK
+#define DEBUG_MEMCHECK_INDEX_INVALIDATE(ele) \
+ { \
+ int undef_idx; \
+ BM_elem_index_set(ele, undef_idx); /* set_ok_invalid */ \
+ } \
+
+#endif
+
+BMVert *BM_vert_create(BMesh *bm, const float co[3], const struct BMVert *example)
+{
+ BMVert *v = BLI_mempool_calloc(bm->vpool);
+
+#ifdef USE_DEBUG_INDEX_MEMCHECK
+ DEBUG_MEMCHECK_INDEX_INVALIDATE(v)
+#else
+ BM_elem_index_set(v, -1); /* set_ok_invalid */
+#endif
+
+ bm->elem_index_dirty |= BM_VERT; /* may add to middle of the pool */
+
+ bm->totvert++;
+
+ v->head.htype = BM_VERT;
+
+ /* 'v->no' is handled by BM_elem_attrs_copy */
+ if (co) {
+ copy_v3_v3(v->co, co);
+ }
+
+ /* allocate flag */
+ v->oflags = BLI_mempool_calloc(bm->toolflagpool);
+
+ CustomData_bmesh_set_default(&bm->vdata, &v->head.data);
+
+ if (example) {
+ BM_elem_attrs_copy(bm, bm, example, v);
+ }
+
+ BM_CHECK_ELEMENT(bm, v);
+
+ return v;
+}
+
+/**
+ * BMESH EDGE EXIST
+ *
+ * Finds out if two vertices already have an edge
+ * connecting them. Note that multiple edges may
+ * exist between any two vertices, and therefore
+ * This function only returns the first one found.
+ *
+ * Returns -
+ * BMEdge pointer
+ */
+BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2)
+{
+ BMIter iter;
+ BMEdge *e;
+
+ BM_ITER(e, &iter, NULL, BM_EDGES_OF_VERT, v1) {
+ if (e->v1 == v2 || e->v2 == v2)
+ return e;
+ }
+
+ return NULL;
+}
+
+BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, int nodouble)
+{
+ BMEdge *e;
+
+ if (nodouble && (e = BM_edge_exists(v1, v2)))
+ return e;
+
+ e = BLI_mempool_calloc(bm->epool);
+
+#ifdef USE_DEBUG_INDEX_MEMCHECK
+ DEBUG_MEMCHECK_INDEX_INVALIDATE(e)
+#else
+ BM_elem_index_set(e, -1); /* set_ok_invalid */
+#endif
+
+ bm->elem_index_dirty |= BM_EDGE; /* may add to middle of the pool */
+
+ bm->totedge++;
+
+ e->head.htype = BM_EDGE;
+
+ /* allocate flag */
+ e->oflags = BLI_mempool_calloc(bm->toolflagpool);
+
+ e->v1 = v1;
+ e->v2 = v2;
+
+ BM_elem_flag_enable(e, BM_ELEM_SMOOTH);
+
+ CustomData_bmesh_set_default(&bm->edata, &e->head.data);
+
+ bmesh_disk_edge_append(e, e->v1);
+ bmesh_disk_edge_append(e, e->v2);
+
+ if (example)
+ BM_elem_attrs_copy(bm, bm, example, e);
+
+ BM_CHECK_ELEMENT(bm, e);
+
+ return e;
+}
+
+static BMLoop *bmesh_loop_create(BMesh *bm, BMVert *v, BMEdge *e, BMFace *f, const BMLoop *example)
+{
+ BMLoop *l = NULL;
+
+ l = BLI_mempool_calloc(bm->lpool);
+ l->next = l->prev = NULL;
+ l->v = v;
+ l->e = e;
+ l->f = f;
+ l->radial_next = l->radial_prev = NULL;
+ l->head.data = NULL;
+ l->head.htype = BM_LOOP;
+
+ bm->totloop++;
+
+ if (example)
+ CustomData_bmesh_copy_data(&bm->ldata, &bm->ldata, example->head.data, &l->head.data);
+ else
+ CustomData_bmesh_set_default(&bm->ldata, &l->head.data);
+
+ return l;
+}
+
+static BMLoop *bm_face_boundary_add(BMesh *bm, BMFace *f, BMVert *startv, BMEdge *starte)
+{
+#ifdef USE_BMESH_HOLES
+ BMLoopList *lst = BLI_mempool_calloc(bm->looplistpool);
+#endif
+ BMLoop *l = bmesh_loop_create(bm, startv, starte, f, NULL);
+
+ bmesh_radial_append(starte, l);
+
+#ifdef USE_BMESH_HOLES
+ lst->first = lst->last = l;
+ BLI_addtail(&f->loops, lst);
+#else
+ f->l_first = l;
+#endif
+
+ l->f = f;
+
+ return l;
+}
+
+BMFace *BM_face_copy(BMesh *bm, BMFace *f, const short copyverts, const short copyedges)
+{
+ BMEdge **edges = NULL;
+ BMVert **verts = NULL;
+ BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE);
+ BMLoop *l_iter;
+ BMLoop *l_first;
+ BMLoop *l2;
+ BMFace *f2;
+ int i;
+
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ if (copyverts) {
+ BMVert *v = BM_vert_create(bm, l_iter->v->co, l_iter->v);
+ BLI_array_append(verts, v);
+ }
+ else {
+ BLI_array_append(verts, l_iter->v);
+ }
+ } while ((l_iter = l_iter->next) != l_first);
+
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ i = 0;
+ do {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list