[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36416] branches/bmesh/blender/source/ blender: =bmesh=

Joseph Eagar joeedh at gmail.com
Sun May 1 20:53:19 CEST 2011


Revision: 36416
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36416
Author:   joeedh
Date:     2011-05-01 18:53:18 +0000 (Sun, 01 May 2011)
Log Message:
-----------
=bmesh=

Fixed some bugs with mesh primitive add 
operators.  Suzanne now faces forward,
instead of down.  Cylinder and circle
both now work.  Cone lets you adjust the
diameter at both ends now.

I also reorganized the walker code, to
be more maintainable and understandable.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/bmesh/CMakeLists.txt
    branches/bmesh/blender/source/blender/bmesh/bmesh.h
    branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h
    branches/bmesh/blender/source/blender/bmesh/bmesh_walkers.h
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators_private.h
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers.c
    branches/bmesh/blender/source/blender/bmesh/operators/primitiveops.c
    branches/bmesh/blender/source/blender/editors/curve/editcurve.c
    branches/bmesh/blender/source/blender/editors/include/ED_object.h
    branches/bmesh/blender/source/blender/editors/mesh/editbmesh_add.c
    branches/bmesh/blender/source/blender/editors/object/object_add.c

Added Paths:
-----------
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers_private.h

Modified: branches/bmesh/blender/source/blender/bmesh/CMakeLists.txt
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/CMakeLists.txt	2011-05-01 16:07:18 UTC (rev 36415)
+++ branches/bmesh/blender/source/blender/bmesh/CMakeLists.txt	2011-05-01 18:53:18 UTC (rev 36416)
@@ -84,7 +84,6 @@
 	intern/bmesh_mods.c
 	intern/bmesh_structure.h
 	intern/bmesh_construct.c
-	intern/bmesh_walkers.c
 	intern/bmesh_to_editmesh.c
 	intern/bmesh_operators_private.h
 	intern/editmesh_to_bmesh.c
@@ -96,6 +95,9 @@
 	intern/bmesh_eulers.c
 	intern/bmesh_operators.c
 	intern/bmesh_private.h
+	intern/bmesh_walkers.c
+	intern/bmesh_walkers_impl.c
+	intern/bmesh_walkers_private.h
 	bmesh_error.h
 	bmesh_queries.h
 	bmesh.h

Modified: branches/bmesh/blender/source/blender/bmesh/bmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh.h	2011-05-01 16:07:18 UTC (rev 36415)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh.h	2011-05-01 18:53:18 UTC (rev 36416)
@@ -24,11 +24,6 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * The Original Code is Copyright (C) 2004 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
  * Contributor(s): Geoffrey Bantle, Levi Schooley.
  *
  * ***** END GPL LICENSE BLOCK *****

Modified: branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h	2011-05-01 16:07:18 UTC (rev 36415)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h	2011-05-01 18:53:18 UTC (rev 36416)
@@ -1,6 +1,8 @@
 #ifndef BM_OPERATORS_H
 #define BM_OPERATORS_H
 
+/*see comments in intern/bmesh_opdefines.c for documentation of specific operators*/
+
 /*--------defines/enumerations for specific operators-------*/
 
 /*del operator "context" slot values*/

Modified: branches/bmesh/blender/source/blender/bmesh/bmesh_walkers.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh_walkers.h	2011-05-01 16:07:18 UTC (rev 36415)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh_walkers.h	2011-05-01 18:53:18 UTC (rev 36416)
@@ -9,15 +9,17 @@
 
 /*Walkers*/
 typedef struct BMWalker {
+	void (*begin) (struct BMWalker *walker, void *start);
+	void *(*step) (struct BMWalker *walker);
+	void *(*yield)(struct BMWalker *walker);
+	int structsize;
+	int flag;
+
+	BMesh *bm;
 	BLI_mempool *stack;
-	BMesh *bm;
 	void *currentstate;
-	void (*begin) (struct BMWalker *walker, void *start);
-	void *(*yield)(struct BMWalker *walker);
-	void *(*step) (struct BMWalker *walker);
 	int restrictflag;
 	GHash *visithash;
-	int flag;
 } BMWalker;
 
 /*initialize a walker.  searchmask restricts some (not all) walkers to
@@ -27,6 +29,12 @@
 void *BMW_Step(struct BMWalker *walker);
 void BMW_End(struct BMWalker *walker);
 
+/*these are used by custom walkers*/
+void BMW_pushstate(BMWalker *walker);
+void BMW_popstate(BMWalker *walker);
+void *BMW_walk(BMWalker *walker);
+void BMW_reset(BMWalker *walker);
+
 /*
 example of usage, walking over an island of tool flagged faces:
 
@@ -67,7 +75,9 @@
 	BMW_ISLANDBOUND,
 	/*walk over all faces in an island of tool flagged faces.*/
 	BMW_ISLAND,
+	/*do not intitialze function pointers and struct size in BMW_Init*/
+	BMW_CUSTOM,
 	BMW_MAXWALKERS,
 };
 
-#endif
\ No newline at end of file
+#endif

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c	2011-05-01 16:07:18 UTC (rev 36415)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c	2011-05-01 18:53:18 UTC (rev 36416)
@@ -897,6 +897,7 @@
 	"create_cone",
 	{{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts
 	 {BMOP_OPSLOT_INT, "cap_ends"}, //wheter or not to fill in the ends with faces
+	 {BMOP_OPSLOT_INT, "cap_tris"}, //fill ends with triangles instead of ngons
 	 {BMOP_OPSLOT_INT, "segments"},
 	 {BMOP_OPSLOT_FLT, "diameter1"}, //diameter of one end
 	 {BMOP_OPSLOT_FLT, "diameter2"}, //diameter of the opposite
@@ -908,6 +909,22 @@
 };
 
 /*
+Creates a circle
+*/
+BMOpDefine def_create_circle = {
+  "create_circle",
+  {{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts
+   {BMOP_OPSLOT_INT, "cap_ends"}, //wheter or not to fill in the ends with faces
+   {BMOP_OPSLOT_INT, "cap_tris"}, //fill ends with triangles instead of ngons
+   {BMOP_OPSLOT_INT, "segments"},
+   {BMOP_OPSLOT_FLT, "diameter"}, //diameter of one end
+   {BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with--
+   {0, /*null-terminating sentinel*/}},
+  bmesh_create_circle_exec,
+  0,
+};
+
+/*
   Create Cone
 
   Creates a cone with variable depth at both ends
@@ -1025,8 +1042,9 @@
 	&def_create_grid,
 	&def_create_icosphere,
 	&def_create_monkey,
+	&def_create_cube,
+	&def_create_circle,
 	&def_create_cone,
-	&def_create_cube,
 	&def_join_triangles,
 	&def_bevel,
 	&def_beautify_fill,

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators_private.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators_private.h	2011-05-01 16:07:18 UTC (rev 36415)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators_private.h	2011-05-01 18:53:18 UTC (rev 36416)
@@ -71,5 +71,6 @@
 void bmesh_bevel_exec(BMesh *bm, BMOperator *op);
 void bmesh_beautify_fill_exec(BMesh *bm, BMOperator *op);
 void bmesh_triangle_fill_exec(BMesh *bm, BMOperator *op);
+void bmesh_create_circle_exec(BMesh *bm, BMOperator *op);
 
 #endif

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers.c	2011-05-01 16:07:18 UTC (rev 36415)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers.c	2011-05-01 18:53:18 UTC (rev 36416)
@@ -1,3 +1,34 @@
+/**
+ *  bmesh_walkers.c    april 2011
+ *
+ *	BMesh Walker API.
+ *
+ * $Id: $
+ *
+ * ***** 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License.  See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Contributor(s): Joseph Eagar, Geoffrey Bantle, Levi Schooley.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
 #include <stdio.h>
 #include <string.h>
 
@@ -10,11 +41,11 @@
 #include "BLI_mempool.h"
 #include "BLI_array.h"
 
-#include "bmesh_private.h"
-#include "bmesh_walkers.h"
-
 #include "bmesh.h"
 
+#include "bmesh_private.h"
+#include "bmesh_walkers_private.h"
+
 /*
  - joeedh -
  design notes:
@@ -37,103 +68,7 @@
    for if walkers fail.
 */
 
-typedef struct shellWalker{
-	struct shellWalker *prev;
-	BMVert *base;			
-	BMEdge *curedge, *current;
-} shellWalker;
 
-typedef struct islandboundWalker {
-	struct islandboundWalker *prev;
-	BMLoop *base;
-	BMVert *lastv;
-	BMLoop *curloop;
-} islandboundWalker;
-
-typedef struct islandWalker {
-	struct islandWalker * prev;
-	BMFace *cur;
-} islandWalker;
-
-typedef struct loopWalker {
-	struct loopWalker * prev;
-	BMEdge *cur, *start;
-	BMVert *lastv, *startv;
-	int startrad, stage2;
-} loopWalker;
-
-typedef struct faceloopWalker {
-	struct faceloopWalker * prev;
-	BMLoop *l;
-	int nocalc;
-} faceloopWalker;
-
-typedef struct edgeringWalker {
-	struct edgeringWalker * prev;
-	BMLoop *l;
-} edgeringWalker;
-
-typedef struct uvedgeWalker {
-	struct uvedgeWalker *prev;
-	BMLoop *l;
-} uvedgeWalker;
-
-/*  NOTE: this comment is out of date, update it - joeedh
- *	BMWalker - change this to use the filters functions.
- *	
- *	A generic structure for maintaing the state and callbacks nessecary for walking over
- *  the surface of a mesh. An example of usage:
- *
- *	     BMEdge *edge;
- *	     BMWalker *walker = BMW_create(BM_SHELLWALKER, BM_SELECT);
- *       walker->begin(walker, vert);
- *       for(edge = BMW_walk(walker); edge; edge = bmeshWwalker_walk(walker)){
- *            bmesh_select_edge(edge);
- *       }
- *       BMW_free(walker);
- *
- *	The above example creates a walker that walks over the surface a mesh by starting at
- *  a vertex and traveling across its edges to other vertices, and repeating the process
- *  over and over again until it has visited each vertex in the shell. An additional restriction
- *  is passed into the BMW_create function stating that we are only interested
- *  in walking over edges that have been flagged with the bitmask 'BM_SELECT'.
- *
- *
-*/
-
-/*Forward declerations*/
-static void *BMW_walk(struct BMWalker *walker);
-static void BMW_popstate(struct BMWalker *walker);
-static void BMW_pushstate(struct BMWalker *walker);
-
-static void shellWalker_begin(struct BMWalker *walker, void *data);
-static void *shellWalker_yield(struct BMWalker *walker);
-static void *shellWalker_step(struct BMWalker *walker);
-
-static void islandboundWalker_begin(BMWalker *walker, void *data);
-static void *islandboundWalker_yield(BMWalker *walker);
-static void *islandboundWalker_step(BMWalker *walker);
-
-static void islandWalker_begin(BMWalker *walker, void *data);
-static void *islandWalker_yield(BMWalker *walker);
-static void *islandWalker_step(BMWalker *walker);
-
-static void loopWalker_begin(BMWalker *walker, void *data);
-static void *loopWalker_yield(BMWalker *walker);
-static void *loopWalker_step(BMWalker *walker);
-

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list