[Bf-committers] Collapse Loop Patch - Version 1

Johnny Matthews johnny.matthews at gmail.com
Fri Feb 11 19:10:30 CET 2005


hmm, that sounds pretty interesting. I might play with that seeing as 
how insomnia seems to be plaguing me lately. :)

malefico andauer wrote:

>Very nice, will try asap.
>
>BTW, what do you think of a tool to turn one vertex
>into a face ? (I think it's called chamfer in MAX?)
>You select a vertex, and then three more vertices are
>added to form a face with the original neighbour
>vertices.
>
>I haven't heard of any develpment in this topic yet...
>
>Regards
>
>malefico.
>
> --- Johnny Matthews <johnny.matthews at gmail.com>
>escribió: 
>  
>
>>Here is a first version of collapse loop for you to
>>check out
>>
>>It is activated with keystroke CTRL-SHIFT-R after
>>selecting 2 adjacent 
>>vert rings that are full rings with 5 or more verts
>>each.
>>
>>--TODO--
>>**edge and face mode. Only works in vertex mode
>>right now.
>>**work for loops with 3 or 4 verts per ring. Only
>>works now with loops 
>>with 5 or more verts per ring.
>>**Anything other bugs that people find.
>>
>>I have this info here
>>http://guitargeek.superihost.com/collapse
>>
>>
>>    
>>
>>>Index: source/blender/include/BIF_editmesh.h
>>>      
>>>
>===================================================================
>  
>
>>RCS file:
>>
>>    
>>
>/cvsroot/bf-blender/blender/source/blender/include/BIF_editmesh.h,v
>  
>
>>retrieving revision 1.36
>>diff -u -r1.36 BIF_editmesh.h
>>--- source/blender/include/BIF_editmesh.h	24 Nov
>>2004 16:29:10 -0000	1.36
>>+++ source/blender/include/BIF_editmesh.h	11 Feb
>>2005 14:28:48 -0000
>>@@ -148,6 +148,7 @@
>> #define LOOP_CUT	2
>> 
>> extern void loopoperations(char mode);
>>+extern void collapseedgeloop();
>> extern void vertex_loop_select(void); 
>> 
>> /* ******************* editmesh_tools.c */
>>
>>Index: source/blender/src/editmesh_loop.c
>>
>>    
>>
>===================================================================
>  
>
>>RCS file:
>>
>>    
>>
>/cvsroot/bf-blender/blender/source/blender/src/editmesh_loop.c,v
>  
>
>>retrieving revision 1.11
>>diff -u -r1.11 editmesh_loop.c
>>--- source/blender/src/editmesh_loop.c	28 Dec 2004
>>05:38:56 -0000	1.11
>>+++ source/blender/src/editmesh_loop.c	11 Feb 2005
>>15:49:00 -0000
>>@@ -92,6 +92,208 @@
>> #include "winlay.h"
>> 
>> 
>>+
>>+void collapseedgeloop()
>>+{
>>+	EditMesh *em = G.editMesh;
>>+	EditEdge *eed = NULL;
>>+	EditFace *ef = NULL;
>>+	EditVert *ev = NULL, **index, **vertChart,
>>**collapse, **tree;
>>+	int selectedVertCount = 0;
>>+	int i,n=0,m,vertno[3],matchno=0,next, shared, exit
>>= 0;
>>+
>>+	/*Change Face and Edge selection to vertex
>>selection*/
>>+	for(eed=em->edges.first; eed; eed=eed->next){
>>+		if(eed->f & 1){
>>+			eed->v1->f |= 1;
>>+			eed->v2->f |= 1;
>>+			eed->f &= ~(1);
>>+		}
>>+	}
>>+	for(ef=em->faces.first; ef; ef=ef->next){
>>+		if(ef->f & 1){
>>+			ef->v1->f |= 1;
>>+			ef->v2->f |= 1;
>>+			ef->v3->f |= 1;
>>+			if(ef->v4)
>>+				ef->v4->f |= 1;
>>+			ef->f &= ~(1);
>>+		}
>>+	}
>>+
>>+	/*Count Number of Selected Verts*/
>>+	for(ev=em->verts.first; ev; ev=ev->next){
>>+		if(ev->f & 1)
>>+			selectedVertCount++;
>>+	}
>>+		
>>+	/*If it is odd or 0 it is not 2 similar loops and
>>8 is a cube*/
>>+	if(selectedVertCount == 0 || selectedVertCount % 2
>>!= 0 || selectedVertCount == 8){
>>+		okee("Sorry, I can't collapse that");
>>+		return;
>>+	}		
>>+	vertChart =
>>MEM_mallocN(4*selectedVertCount*sizeof(EditVert*),
>>"vertChart Created");
>>+	index     =
>>MEM_mallocN(selectedVertCount*sizeof(EditVert*),
>>"index Created");
>>+	tree      = MEM_mallocN(12*sizeof(EditVert*),
>>"collapselist Created");
>>+	collapse  =
>>MEM_mallocN(selectedVertCount*sizeof(EditVert*),
>>"collapselist Created");
>>+	
>>+	
>>+	/*Fill in the Index Array for our selected verts*/
>>+	n=0;
>>+	for(ev=em->verts.first; ev; ev=ev->next){
>>+		if(ev->f & 1){
>>+			index[n] = ev;
>>+			n++;
>>+		}
>>+	}
>>+	
>>+	/* Null out the vert arrays */
>>+	for(n=0;n<selectedVertCount*4;n++)
>>+		vertChart[n] = NULL;
>>+	for(n=0;n<selectedVertCount;n++)
>>+		collapse[n] = NULL;
>>+	for(n=0;n<12;n++)
>>+		tree[n] = NULL;
>>+		
>>+	/*Fill the Vert Chart*/
>>+	/* the vert chart is a vert folled by the 3 verts
>>it connects to */
>>+	for(n=0;n<selectedVertCount;n++){
>>+		shared = 0;
>>+		m=0;
>>+		if(vertChart[n*4-1]==NULL){
>>+			exit = 1;
>>+			break;
>>+		}
>>+		vertChart[n*4] = index[n];
>>+		for(eed=em->edges.first; eed; eed=eed->next){
>>+			m++;
>>+			if((eed->v1 == index[n] && eed->v2->f & 1) ||
>>(eed->v2 == index[n] && eed->v1->f & 1)){
>>+				shared++;
>>+				if(shared>3){
>>+					exit = 1;
>>+					break;
>>+				}
>>+				if(eed->v1 == index[n])
>>+					vertChart[n*4+shared] = eed->v2;
>>+				else
>>+					vertChart[n*4+shared] = eed->v1;
>>+			}
>>+		}
>>+		if(exit)
>>+			break;
>>+	}
>>+	
>>+	if(!exit){
>>+		/*Pair up the Verts*/
>>+		for(n=0;n<selectedVertCount;n++){
>>+			/*if we have paired the vert, skip it*/
>>+			next = 0;
>>+			for(i=0;i<selectedVertCount;i++){
>>+				if(index[n] == collapse[i])
>>+					next = 1;
>>+					continue;
>>+			}
>>+			if(next)
>>+				continue;
>>+			
>>+			
>>+			/*make our vert tree*/
>>+				
>>+			tree[0] = vertChart[n*4+1];
>>+			tree[4] = vertChart[n*4+2];
>>+			tree[8] = vertChart[n*4+3];
>>+
>>+			for(m=0;m<selectedVertCount;m++){
>>+				if(index[m] == tree[0]){
>>+					vertno[0] = m;
>>+				}
>>+				if(index[m] == tree[4]){
>>+					vertno[1] = m;
>>+				}
>>+				if(index[m] == tree[8]){
>>+					vertno[2] = m;
>>+				}
>>+			}
>>+			
>>+			tree[1]  = vertChart[vertno[0]*4+1];
>>+			tree[2]  = vertChart[vertno[0]*4+2];
>>+			tree[3]  = vertChart[vertno[0]*4+3];
>>+			
>>+			tree[5]  = vertChart[vertno[1]*4+1];
>>+			tree[6]  = vertChart[vertno[1]*4+2];
>>+			tree[7]  = vertChart[vertno[1]*4+3];
>>+			
>>+			tree[9]  = vertChart[vertno[2]*4+1];
>>+			tree[10] = vertChart[vertno[2]*4+2];
>>+			tree[11] = vertChart[vertno[2]*4+3];
>>+			
>>+			/*remove duplicates from the vert tree*/
>>+			
>>+			for(m=0;m<11;m++){
>>+				if(tree[m] == NULL)
>>+					continue;
>>+				ev = tree[m];
>>+				for(i=m+1;i<12;i++){
>>+					if(ev == tree[i]){
>>+						tree[m] = NULL;
>>+						tree[i] = NULL;
>>+					}
>>+				}
>>+			}
>>+			
>>+			/*determine which branch has the paired vertex*/
>>+			
>>+			i=0;
>>+			for(m=0;m<12;m++){
>>+				if(m==0 || m==4 || m == 8)
>>
>>    
>>
>=== message truncated ===>
>_______________________________________________
>  
>
>>Bf-committers mailing list
>>Bf-committers at projects.blender.org
>>
>>    
>>
>http://projects.blender.org/mailman/listinfo/bf-committers
>  
>
>> 
>>    
>>
>
>
>	
>
>	
>		
>___________________________________________________________ 
>250MB gratis, Antivirus y Antispam 
>Correo Yahoo!, el mejor correo web del mundo 
>http://correo.yahoo.com.ar
>_______________________________________________
>Bf-committers mailing list
>Bf-committers at projects.blender.org
>http://projects.blender.org/mailman/listinfo/bf-committers
>
>  
>


More information about the Bf-committers mailing list