[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45976] trunk/blender/source/blender: code cleanup: bmesh comments/todos, no functional changes.

Campbell Barton ideasman42 at gmail.com
Thu Apr 26 10:27:50 CEST 2012


Revision: 45976
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45976
Author:   campbellbarton
Date:     2012-04-26 08:27:50 +0000 (Thu, 26 Apr 2012)
Log Message:
-----------
code cleanup: bmesh comments/todos, no functional changes.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_array.h
    trunk/blender/source/blender/bmesh/bmesh.h
    trunk/blender/source/blender/bmesh/intern/bmesh_core.c

Modified: trunk/blender/source/blender/blenlib/BLI_array.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_array.h	2012-04-26 08:04:11 UTC (rev 45975)
+++ trunk/blender/source/blender/blenlib/BLI_array.h	2012-04-26 08:27:50 UTC (rev 45976)
@@ -64,7 +64,7 @@
 #define BLI_array_staticdeclare(arr, maxstatic)                               \
 	int   _##arr##_count = 0;                                                 \
 	void *_##arr##_tmp;                                                       \
-	char _##arr##_static[maxstatic * sizeof(arr)]
+	char  _##arr##_static[maxstatic * sizeof(arr)]
 
 
 /* this returns the entire size of the array, including any buffering. */

Modified: trunk/blender/source/blender/bmesh/bmesh.h
===================================================================
--- trunk/blender/source/blender/bmesh/bmesh.h	2012-04-26 08:04:11 UTC (rev 45975)
+++ trunk/blender/source/blender/bmesh/bmesh.h	2012-04-26 08:27:50 UTC (rev 45976)
@@ -192,6 +192,41 @@
  * - bmo_xxx() -    Low level / internal operator API functions.
  * - _bm_xxx() -    Functions which are called via macros only.
  *
+ * \section bm_todo BMesh TODO's
+ *
+ * There may be a better place for this section, but adding here for now.
+ *
+ *
+ * \subsection bm_todo_tools Tools
+ *
+ * Probably most of these will be bmesh operators.
+ *
+ * - make ngons flat.
+ * - make ngons into tris/quads (ngon poke?), many methods could be used here (triangulate/fan/quad-fan).
+ * - solidify (precise mode), keeps even wall thickness, re-creates outlines of offset faces with plane-plane
+ *   intersections.
+ * - split vert (we already have in our API, just no tool)
+ * - bridge (add option to bridge between different edge loop counts, option to remove selected face regions)
+ * - flip selected region (invert all faces about the plane defined by the selected region outline)
+ * - interactive dissolve (like the knife tool but draw over edges to dissolve)
+ *
+ *
+ * \subsection bm_todo_optimize Optimizations
+ *
+ * - skip normal calc when its not needed (when calling chain of operators & for modifiers, flag as dirty)
+ * - skip BMO flag allocation, its not needed in many cases, this is fairly redundant to calc by default.
+ * - ability to call BMO's with option not to create return data (will save some time)
+ * - binary diff UNDO, currently this uses huge amount of ram when all shapes are stored for each undo step for eg.
+ * - use two differnt iterator types for BMO map/buffer types.
+ * - avoid string lookups for BMO slot lookups _especially_ when used in loops, this is very crappy.
+ *
+ *
+ * \subsection bm_todo_tools_enhance Tool Enhancements
+ *
+ * - face inset interpolate loop data from face (currently copies - but this stretches UV's in an ugly way)
+ * - vert slide UV correction (like we have for edge slide)
+ * - fill-face edge net - produce consistant normals, currently it won't, fix should be to fill in edge-net node
+ *   connected with previous one - since they already check for normals of adjacent edge-faces before creating.
  */
 
 #ifdef __cplusplus

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_core.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_core.c	2012-04-26 08:04:11 UTC (rev 45975)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_core.c	2012-04-26 08:27:50 UTC (rev 45976)
@@ -50,6 +50,9 @@
 
 #endif
 
+/**
+ * \brief Main function for creating a new vertex.
+ */
 BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example)
 {
 	BMVert *v = BLI_mempool_calloc(bm->vpool);
@@ -85,6 +88,12 @@
 	return v;
 }
 
+/**
+ * \brief Main function for creating a new edge.
+ *
+ * \note Duplicate edges are supported by the API however users should _never_ see them.
+ * so unless you need a unique edge or know the edge won't exist, you should call wih \a nodouble=TRUE
+ */
 BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, int nodouble)
 {
 	BMEdge *e;
@@ -181,10 +190,11 @@
 	BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE);
 	BMLoop *l_iter;
 	BMLoop *l_first;
-	BMLoop *l2;
-	BMFace *f2;
+	BMLoop *l_copy;
+	BMFace *f_copy;
 	int i;
 
+	/* BMESH_TODO - grow verts array in one go! (right here) */
 	l_iter = l_first = BM_FACE_FIRST_LOOP(f);
 	do {
 		if (copyverts) {
@@ -196,6 +206,7 @@
 		}
 	} while ((l_iter = l_iter->next) != l_first);
 
+	/* BMESH_TODO - grow edges array in one go! (right here) */
 	l_iter = l_first = BM_FACE_FIRST_LOOP(f);
 	i = 0;
 	do {
@@ -222,18 +233,18 @@
 		i++;
 	} while ((l_iter = l_iter->next) != l_first);
 	
-	f2 = BM_face_create(bm, verts, edges, f->len, FALSE);
+	f_copy = BM_face_create(bm, verts, edges, f->len, FALSE);
 	
-	BM_elem_attrs_copy(bm, bm, f, f2);
+	BM_elem_attrs_copy(bm, bm, f, f_copy);
 	
 	l_iter = l_first = BM_FACE_FIRST_LOOP(f);
-	l2 = BM_FACE_FIRST_LOOP(f2);
+	l_copy = BM_FACE_FIRST_LOOP(f_copy);
 	do {
-		BM_elem_attrs_copy(bm, bm, l_iter, l2);
-		l2 = l2->next;
+		BM_elem_attrs_copy(bm, bm, l_iter, l_copy);
+		l_copy = l_copy->next;
 	} while ((l_iter = l_iter->next) != l_first);
 	
-	return f2;
+	return f_copy;
 }
 
 /**
@@ -270,6 +281,9 @@
 	return f;
 }
 
+/**
+ * \brief Main face creation function
+ */
 BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, int nodouble)
 {
 	BMFace *f = NULL;
@@ -319,6 +333,12 @@
 	return f;
 }
 
+/**
+ * Check the element is valid.
+ *
+ * BMESH_TODO, when this raises an error the output is incredible confusing.
+ * need to have some nice way to print/debug what the hecks going on.
+ */
 int bmesh_elem_check(void *element, const char htype)
 {
 	BMHeader *head = element;
@@ -446,14 +466,16 @@
 }
 
 /**
- * low level function, only free's,
- * does not change adjust surrounding geometry */
+ * low level function, only frees the vert,
+ * doesn't change or adjust surrounding geometry
+ */
 static void bm_kill_only_vert(BMesh *bm, BMVert *v)
 {
 	bm->totvert--;
 	bm->elem_index_dirty |= BM_VERT;
 
 	BM_select_history_remove(bm, v);
+
 	if (v->head.data)
 		CustomData_bmesh_free_block(&bm->vdata, &v->head.data);
 
@@ -461,6 +483,10 @@
 	BLI_mempool_free(bm->vpool, v);
 }
 
+/**
+ * low level function, only frees the edge,
+ * doesn't change or adjust surrounding geometry
+ */
 static void bm_kill_only_edge(BMesh *bm, BMEdge *e)
 {
 	bm->totedge--;
@@ -475,6 +501,10 @@
 	BLI_mempool_free(bm->epool, e);
 }
 
+/**
+ * low level function, only frees the face,
+ * doesn't change or adjust surrounding geometry
+ */
 static void bm_kill_only_face(BMesh *bm, BMFace *f)
 {
 	if (bm->act_face == f)
@@ -492,6 +522,10 @@
 	BLI_mempool_free(bm->fpool, f);
 }
 
+/**
+ * low level function, only frees the loop,
+ * doesn't change or adjust surrounding geometry
+ */
 static void bm_kill_only_loop(BMesh *bm, BMLoop *l)
 {
 	bm->totloop--;
@@ -502,7 +536,7 @@
 }
 
 /**
- * kills all edges associated with f, along with any other faces containing
+ * kills all edges associated with \a f, along with any other faces containing
  * those edges
  */
 void BM_face_edges_kill(BMesh *bm, BMFace *f)
@@ -526,7 +560,7 @@
 }
 
 /**
- * kills all verts associated with f, along with any other faces containing
+ * kills all verts associated with \a f, along with any other faces containing
  * those vertices
  */
 void BM_face_verts_kill(BMesh *bm, BMFace *f)
@@ -587,7 +621,9 @@
 
 	bm_kill_only_face(bm, f);
 }
-
+/**
+ * kills \a e and all faces that use it.
+ */
 void BM_edge_kill(BMesh *bm, BMEdge *e)
 {
 
@@ -615,6 +651,9 @@
 	bm_kill_only_edge(bm, e);
 }
 
+/**
+ * kills \a v and all edges that use it.
+ */
 void BM_vert_kill(BMesh *bm, BMVert *v)
 {
 	if (v->e) {
@@ -746,6 +785,9 @@
 	return 1;
 }
 
+/**
+ * \brief Flip the faces direction
+ */
 int bmesh_loop_reverse(BMesh *bm, BMFace *f)
 {
 #ifdef USE_BMESH_HOLES




More information about the Bf-blender-cvs mailing list