[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23108] branches/bmesh/blender: coded implemented for create faces from edgenet.

Joseph Eagar joeedh at gmail.com
Thu Sep 10 13:23:34 CEST 2009


Revision: 23108
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23108
Author:   joeedh
Date:     2009-09-10 13:23:34 +0200 (Thu, 10 Sep 2009)

Log Message:
-----------
coded implemented for create faces from edgenet.  note this is automatically executed from fkey now where appropriate, without popping up an annoying menu.  also forgot to commit some ui scripts related to the pinning commit.

Modified Paths:
--------------
    branches/bmesh/blender/config/win32-vc-config.py
    branches/bmesh/blender/projectfiles_vc9/blender/blenlib/BLI_blenlib.vcproj
    branches/bmesh/blender/release/ui/space_view3d.py
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers.c
    branches/bmesh/blender/source/blender/bmesh/operators/createops.c

Modified: branches/bmesh/blender/config/win32-vc-config.py
===================================================================
--- branches/bmesh/blender/config/win32-vc-config.py	2009-09-10 11:04:53 UTC (rev 23107)
+++ branches/bmesh/blender/config/win32-vc-config.py	2009-09-10 11:23:34 UTC (rev 23108)
@@ -148,6 +148,7 @@
 CXX = 'cl.exe'
 
 CCFLAGS = ['/nologo', '/Ob1', '/J', '/W3', '/Gd', '/wd4244', '/wd4305', '/wd4800', '/wd4065', '/wd4267']
+#CCFLAGS += ['/GL']
 CXXFLAGS = ['/EHsc']
 
 BF_DEBUG_CCFLAGS = ['/Zi', '/FR${TARGET}.sbr']
@@ -163,8 +164,8 @@
 
 LLIBS = ['ws2_32', 'vfw32', 'winmm', 'kernel32', 'user32', 'gdi32', 'comdlg32', 'advapi32', 'shfolder', 'shell32', 'ole32', 'oleaut32', 'uuid']
 
-PLATFORM_LINKFLAGS = ['/SUBSYSTEM:CONSOLE','/MACHINE:IX86','/INCREMENTAL:NO','/NODEFAULTLIB:"msvcprt.lib"','/NODEFAULTLIB:"msvcprtd.lib"','/NODEFAULTLIB:"glut32.lib"','/NODEFAULTLIB:"libc.lib"','/NODEFAULTLIB:"libcd.lib"','/NODEFAULTLIB:"libcpd.lib"','/NODEFAULTLIB:"libcp.lib"','/NODEFAULTLIB:"msvcrt.lib"', '/NODEFAULTLIB:"msvcrtd.lib"', '/NODEFAULTLIB:"msvcmrt.lib"', '/NODEFAULTLIB:"msvcurt.lib"', '/LARGEADDRESSAWARE']
-
+PLATFORM_LINKFLAGS = ['/SUBSYSTEM:CONSOLE','/MACHINE:IX86','/INCREMENTAL:YES','/NODEFAULTLIB:"msvcprt.lib"','/NODEFAULTLIB:"msvcprtd.lib"','/NODEFAULTLIB:"glut32.lib"','/NODEFAULTLIB:"libc.lib"','/NODEFAULTLIB:"libcd.lib"','/NODEFAULTLIB:"libcpd.lib"','/NODEFAULTLIB:"libcp.lib"','/NODEFAULTLIB:"msvcrt.lib"', '/NODEFAULTLIB:"msvcrtd.lib"', '/NODEFAULTLIB:"msvcmrt.lib"', '/NODEFAULTLIB:"msvcurt.lib"', '/LARGEADDRESSAWARE']
+#PLATFORM_LINKFLAGS += ['/LTCG']
 # # Todo
 # BF_PROFILE_CCFLAGS = ['-pg', '-g ']
 # BF_PROFILE_LINKFLAGS = ['-pg']

Modified: branches/bmesh/blender/projectfiles_vc9/blender/blenlib/BLI_blenlib.vcproj
===================================================================
--- branches/bmesh/blender/projectfiles_vc9/blender/blenlib/BLI_blenlib.vcproj	2009-09-10 11:04:53 UTC (rev 23107)
+++ branches/bmesh/blender/projectfiles_vc9/blender/blenlib/BLI_blenlib.vcproj	2009-09-10 11:23:34 UTC (rev 23108)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="9,00"
+	Version="9.00"
 	Name="BLI_blenlib"
 	ProjectGUID="{31628053-825D-4C06-8A21-D13883489718}"
 	RootNamespace="BLI_blenlib"
@@ -483,6 +483,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\source\blender\blenlib\intern\BLI_cellalloc.c"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\source\blender\blenlib\intern\BLI_dynstr.c"
 				>
 			</File>
@@ -644,6 +648,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\source\blender\blenlib\BLI_cellalloc.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\source\blender\blenlib\BLI_dlrbTree.h"
 				>
 			</File>

Modified: branches/bmesh/blender/release/ui/space_view3d.py
===================================================================
--- branches/bmesh/blender/release/ui/space_view3d.py	2009-09-10 11:04:53 UTC (rev 23107)
+++ branches/bmesh/blender/release/ui/space_view3d.py	2009-09-10 11:23:34 UTC (rev 23108)
@@ -40,7 +40,19 @@
 # ********** Menu **********
 
 # ********** Utilities **********
+class VIEW3D_MT_pinunpin(bpy.types.Menu):
+	__space_type__ = "VIEW_3D"
+	__label__ = "Pin/Unpin"
+	_operator_name = ""
 
+	def draw(self, context):
+		layout = self.layout
+		
+		layout.itemO("%s.pin" % self._operator_name, text="Pin Selected")
+		layout.itemO("%s.unpin" % self._operator_name, text="Unpin Selected")
+		layout.item_booleanO("%s.pin" % self._operator_name, "unselected", True, text="Pin Unselected")
+		layout.item_booleanO("%s.unpin" % self._operator_name, "unselected", True, text="Unpin Unselected")
+
 class VIEW3D_MT_showhide(bpy.types.Menu):
 	__space_type__ = "VIEW_3D"
 	__label__ = "Show/Hide"
@@ -760,6 +772,10 @@
 		layout.itemS()
 		
 		layout.itemM("VIEW3D_MT_edit_MESH_showhide")
+		
+		layout.itemS()
+		
+		layout.itemM("VIEW3D_MT_edit_MESH_pinunpin")
 
 class VIEW3D_MT_edit_MESH_vertices(bpy.types.Menu):
 	__space_type__ = 'VIEW_3D'
@@ -842,6 +858,9 @@
 class VIEW3D_MT_edit_MESH_showhide(VIEW3D_MT_showhide):
 	_operator_name = "mesh"
 
+class VIEW3D_MT_edit_MESH_pinunpin(VIEW3D_MT_pinunpin):
+	_operator_name = "mesh"
+
 # Edit CURVE
 
 # draw_CURVE is used by VIEW3D_MT_edit_CURVE and VIEW3D_MT_edit_SURFACE
@@ -1198,6 +1217,7 @@
 		col.itemR(mesh, "draw_bevel_weights", text="Bevel Weights")
 		col.itemR(mesh, "draw_seams", text="Seams")
 		col.itemR(mesh, "draw_sharp", text="Sharp")
+		col.itemR(mesh, "draw_pins", text="Pins")
 		
 		col.itemS()
 		col.itemL(text="Normals:")
@@ -1297,6 +1317,7 @@
 bpy.types.register(VIEW3D_MT_edit_MESH_faces)
 bpy.types.register(VIEW3D_MT_edit_MESH_normals)
 bpy.types.register(VIEW3D_MT_edit_MESH_showhide)
+bpy.types.register(VIEW3D_MT_edit_MESH_pinunpin)
 
 bpy.types.register(VIEW3D_MT_edit_CURVE)
 bpy.types.register(VIEW3D_MT_edit_CURVE_ctrlpoints)

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c	2009-09-10 11:04:53 UTC (rev 23107)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c	2009-09-10 11:23:34 UTC (rev 23108)
@@ -274,6 +274,12 @@
 			if (!BMO_TestFlag
 		}*/
 
+		/*clear flags first*/
+		for(i = 0; i < len; i++){
+			BMO_ClearFlag(bm, edges[i]->v1, BM_EDGEVERT);
+			BMO_ClearFlag(bm, edges[i]->v2, BM_EDGEVERT);
+		}
+
 		for(i = 0, j=0; i < len; i++){
 			if(!BMO_TestFlag(bm, edges[i]->v1, BM_EDGEVERT)){
 				BMO_SetFlag(bm, edges[i]->v1, BM_EDGEVERT);
@@ -304,7 +310,7 @@
 
 	if((!f) && (!overlap)) {
 		f = bmesh_mf(bm, v1, v2, edges, len);
-	}
+	} else return NULL;
 
 	return f;
 }

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers.c	2009-09-10 11:04:53 UTC (rev 23107)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers.c	2009-09-10 11:23:34 UTC (rev 23108)
@@ -651,6 +651,8 @@
 	
 	rlen = owalk.startrad;
 	l = e->loop;
+	if (!l)
+		return owalk.cur;
 
 	if (val == 4 || val == 2 || rlen == 1) {		
 		i = 0;
@@ -670,11 +672,13 @@
 			}
 
 			l = l2;
-
 			i += 1;
 		}
 	}
 	
+	if (!l)
+		return owalk.cur;
+
 	if (l != e->loop && !BLI_ghash_haskey(walker->visithash, l->e)) {
 		if (!(rlen != 1 && i != stopi)) {
 			BMW_pushstate(walker);

Modified: branches/bmesh/blender/source/blender/bmesh/operators/createops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/createops.c	2009-09-10 11:04:53 UTC (rev 23107)
+++ branches/bmesh/blender/source/blender/bmesh/operators/createops.c	2009-09-10 11:23:34 UTC (rev 23108)
@@ -2,8 +2,10 @@
 
 #include "BKE_utildefines.h"
 
+#include "BLI_memarena.h"
+#include "BLI_mempool.h"
+#include "BLI_heap.h"
 #include "BLI_ghash.h"
-#include "BLI_memarena.h"
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
 
@@ -13,10 +15,264 @@
 #define ELE_NEW		1
 #define ELE_OUT		2
 
+typedef struct EPathNode {
+	struct EPathNode *next, *prev;
+	BMVert *v;
+	BMEdge *e;
+} EPathNode;
+
+typedef struct EPath {
+	ListBase nodes;
+	float weight;
+} EPath;
+
+typedef struct PathBase {
+	BLI_mempool *nodepool, *pathpool;
+} PathBase;
+
+typedef struct EdgeData {
+	int tag;
+	int ftag;
+} EdgeData;
+
+#define EDGE_MARK	1
+#define EDGE_VIS	2
+
+#define VERT_VIS	1
+
+#define FACE_NEW	1
+
+PathBase *edge_pathbase_new(void)
+{
+	PathBase *pb = MEM_callocN(sizeof(PathBase), "PathBase");
+
+	pb->nodepool = BLI_mempool_create(sizeof(EPathNode), 1, 512);
+	pb->pathpool = BLI_mempool_create(sizeof(EPath), 1, 512);
+
+	return pb;
+}
+
+void edge_pathbase_free(PathBase *pathbase)
+{
+	BLI_mempool_destroy(pathbase->nodepool);
+	BLI_mempool_destroy(pathbase->pathpool);
+	MEM_freeN(pathbase);
+}
+
+EPath *edge_copy_add_path(PathBase *pb, EPath *path, BMVert *appendv, BMEdge *e)
+{
+	EPath *path2;
+	EPathNode *node, *node2;
+
+	path2 = BLI_mempool_calloc(pb->pathpool);
+	
+	for (node=path->nodes.first; node; node=node->next) {
+		node2 = BLI_mempool_calloc(pb->nodepool);
+		*node2 = *node;
+		BLI_addtail(&path2->nodes, node2);
+	}
+
+	node2 = BLI_mempool_calloc(pb->nodepool);
+	node2->v = appendv;
+	node2->e = e;
+
+	BLI_addtail(&path2->nodes, node2);
+
+	return path2;
+}
+
+EPath *edge_path_new(PathBase *pb, BMVert *start)
+{
+	EPath *path;
+	EPathNode *node;
+
+	path = BLI_mempool_calloc(pb->pathpool);
+	node = BLI_mempool_calloc(pb->nodepool);
+
+	node->v = start;
+	node->e = NULL;
+
+	BLI_addtail(&path->nodes, node);
+	path->weight = 0.0f;
+
+	return path;
+}
+
+float edge_weight_path(EPath *path, EdgeData *edata)
+{
+	EPathNode *node;
+	float w;
+
+	for (node=path->nodes.first; node; node=node->next) {
+		if (node->e) {
+			w += edata[BMINDEX_GET(node->e)].ftag;
+		}
+
+		w += 1.0f;
+	}
+
+	return w;
+}
+
+
+void edge_free_path(PathBase *pathbase, EPath *path)
+{
+	EPathNode *node, *next;
+
+	for (node=path->nodes.first; node; node=next) {
+		next = node->next;
+		BLI_mempool_free(pathbase->nodepool, node);
+	}
+
+	BLI_mempool_free(pathbase->pathpool, path);
+}
+
+EPath *edge_find_shortest_path(BMesh *bm, BMEdge *edge, EdgeData *edata, PathBase *pathbase)
+{
+	BMIter iter;
+	BMEdge *e;
+	GHash *gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+	BMVert *v1, *v2;
+	BMVert **verts = NULL;
+	V_DECLARE(verts);
+	Heap *heap = BLI_heap_new();
+	EPath *path = NULL, *path2;
+	EPathNode *node;
+	int i;
+
+	path = edge_path_new(pathbase, edge->v1);
+	BLI_heap_insert(heap, path->weight, path);
+	path = NULL;
+
+	while (BLI_heap_size(heap)) {
+		if (path)
+			edge_free_path(pathbase, path);
+		path = BLI_heap_popmin(heap);
+		v1 = ((EPathNode*)path->nodes.last)->v;
+		
+		if (v1 == edge->v2) {
+			/*make sure this path loop doesn't already exist*/
+			i = 0;
+			V_RESET(verts);
+			for (i=0, node = path->nodes.first; node; node=node->next, i++) {
+				V_GROW(verts);
+				verts[i] = node->v;
+			}
+
+			if (!BM_Face_Exists(bm, verts, i, NULL))
+				break;
+			else
+				continue;
+		}
+
+		BM_ITER(e, &iter, bm, BM_EDGES_OF_VERT, v1) {
+			if (e == edge || !BMO_TestFlag(bm, e, EDGE_MARK))
+				continue;
+			
+			v2 = BM_OtherEdgeVert(e, v1);
+			
+			if (BLI_ghash_haskey(gh, v2))
+				continue;
+
+			BLI_ghash_insert(gh, v2, NULL);
+
+			path2 = edge_copy_add_path(pathbase, path, v2, e);
+			path2->weight = edge_weight_path(path2, edata);
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list