[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39279] branches/soc-2011-onion/source/ blender/editors: smooth brush

Antony Riakiotakis kalast at gmail.com
Thu Aug 11 00:43:03 CEST 2011


Revision: 39279
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39279
Author:   psy-fi
Date:     2011-08-10 22:43:02 +0000 (Wed, 10 Aug 2011)
Log Message:
-----------
smooth brush
============
-After communion with god...sorry, communication with mentor it's decided to keep pinch brushes after all. This commit adds ability to inflate by pressing Ctrl too.
-Some renaming made to UvElementMaps and preparation to heavily utilize for adjacency information generation.

Modified Paths:
--------------
    branches/soc-2011-onion/source/blender/editors/include/ED_mesh.h
    branches/soc-2011-onion/source/blender/editors/mesh/editmesh_lib.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_uv.c
    branches/soc-2011-onion/source/blender/editors/space_image/image_ops.c
    branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c

Modified: branches/soc-2011-onion/source/blender/editors/include/ED_mesh.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/include/ED_mesh.h	2011-08-10 22:23:08 UTC (rev 39278)
+++ branches/soc-2011-onion/source/blender/editors/include/ED_mesh.h	2011-08-10 22:43:02 UTC (rev 39279)
@@ -156,9 +156,9 @@
 struct UvMapVert *EM_get_uv_map_vert(struct UvVertMap *vmap, unsigned int v);
 void		EM_free_uv_vert_map(struct UvVertMap *vmap);
 
-struct UvElementMap *EM_make_uv_vert_map2(struct EditMesh *em, int selected);
-struct UvElement *EM_get_uv_map_vert_for_edge(struct UvElementMap *vmap, struct EditMesh *em, struct EditEdge *edge, int initVertexArray);
-void		EM_free_uv_vert_map2(struct UvElementMap *vmap);
+struct UvElementMap *EM_make_uv_element_map(struct EditMesh *em, int selected, int doIslands);
+//struct UvElement *EM_get_uv_map_vert_for_edge(struct UvElementMap *vmap, struct EditMesh *em, struct EditEdge *edge, int initVertexArray);
+void		EM_free_uv_element_map(struct UvElementMap *vmap);
 
 void		EM_add_data_layer(struct EditMesh *em, struct CustomData *data, int type, const char *name);
 void		EM_free_data_layer(struct EditMesh *em, struct CustomData *data, int type);

Modified: branches/soc-2011-onion/source/blender/editors/mesh/editmesh_lib.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/mesh/editmesh_lib.c	2011-08-10 22:23:08 UTC (rev 39278)
+++ branches/soc-2011-onion/source/blender/editors/mesh/editmesh_lib.c	2011-08-10 22:43:02 UTC (rev 39279)
@@ -2358,7 +2358,7 @@
 }
 
 /* A specialized vert map used by stitch operator */
-UvElementMap *EM_make_uv_vert_map2(EditMesh *em, int selected)
+UvElementMap *EM_make_uv_element_map(EditMesh *em, int selected, int doIslands)
 {
 	EditVert *ev;
 	EditFace *efa;
@@ -2391,16 +2391,16 @@
 	if(totuv==0) {
 		return NULL;
 	}
-	vmap= (UvElementMap *)MEM_callocN(sizeof(*vmap), "UvVertMap2");
+	vmap= (UvElementMap *)MEM_callocN(sizeof(*vmap), "UvVertElementMap");
 	if (!vmap) {
 		return NULL;
 	}
 
-	vmap->vert= (UvElement**)MEM_callocN(sizeof(*vmap->vert)*em->totvert, "UvElement*");
+	vmap->vert= (UvElement**)MEM_callocN(sizeof(*vmap->vert)*em->totvert, "UvElementVerts");
 	buf= vmap->buf= (UvElement*)MEM_callocN(sizeof(*vmap->buf)*totuv, "UvElement");
 
 	if (!vmap->vert || !vmap->buf) {
-		EM_free_uv_vert_map2(vmap);
+		EM_free_uv_element_map(vmap);
 		return NULL;
 	}
 
@@ -2465,100 +2465,102 @@
 			vmap->vert[a]= newvlist;
 	}
 
-	/* At this point, every UvElement in vert points to a UvElement sharing the same vertex. Now we should sort uv's in islands. */
+	if(doIslands){
+		/* At this point, every UvElement in vert points to a UvElement sharing the same vertex. Now we should sort uv's in islands. */
 
-	/* map holds the map from current vmap->buf to the new, sorted map*/
-	map = MEM_mallocN(sizeof(*map)*totuv, "uvelement_remap");
-	stack = MEM_mallocN(sizeof(*stack)*em->totface, "uv_island_face_stack");
-	islandbuf = MEM_callocN(sizeof(*islandbuf)*totuv, "uvelement_island_buffer");
-	if(!map || !stack || !islandbuf){
-		if(stack)
-			MEM_freeN(stack);
-		if(map)
-			MEM_freeN(map);
-		if(islandbuf)
-			MEM_freeN(islandbuf);
-		EM_free_uv_vert_map2(vmap);
-		return NULL;
-	}
-	for(i = 0; i < totuv; i++){
-		if(vmap->buf[i].island == INVALID_ISLAND){
-			vmap->buf[i].island = nislands;
-			stack[0] = vmap->buf[i].face;
-			stack[0]->tmp.l = nislands;
-			stacksize=1;
+		/* map holds the map from current vmap->buf to the new, sorted map*/
+		map = MEM_mallocN(sizeof(*map)*totuv, "uvelement_remap");
+		stack = MEM_mallocN(sizeof(*stack)*em->totface, "uv_island_face_stack");
+		islandbuf = MEM_callocN(sizeof(*islandbuf)*totuv, "uvelement_island_buffer");
+		if(!map || !stack || !islandbuf){
+			if(stack)
+				MEM_freeN(stack);
+			if(map)
+				MEM_freeN(map);
+			if(islandbuf)
+				MEM_freeN(islandbuf);
+			EM_free_uv_element_map(vmap);
+			return NULL;
+		}
+		for(i = 0; i < totuv; i++){
+			if(vmap->buf[i].island == INVALID_ISLAND){
+				vmap->buf[i].island = nislands;
+				stack[0] = vmap->buf[i].face;
+				stack[0]->tmp.l = nislands;
+				stacksize=1;
 
-			while(stacksize > 0){
-				efa = stack[--stacksize];
-				nverts = efa->v4? 4 : 3;
-				for(j = 0; j < nverts; j++){
-					UvElement *element, *initelement = vmap->vert[(*(&efa->v1 + j))->tmp.l];
-					for(element = initelement; element; element = element->next){
-						if(element->separate){
-							initelement = element;
-						}
-						if(element->face == efa){
-							/* found the uv corresponding to our face and vertex. Now fill it to the buffer */
-							element->island = nislands;
-							map[element - vmap->buf] = islandbufsize;
-							islandbuf[islandbufsize].tfindex = element->tfindex;
-							islandbuf[islandbufsize].face = element->face;
-							islandbuf[islandbufsize].separate = element->separate;
-							islandbuf[islandbufsize].island =  nislands;
-							islandbufsize++;
+				while(stacksize > 0){
+					efa = stack[--stacksize];
+					nverts = efa->v4? 4 : 3;
+					for(j = 0; j < nverts; j++){
+						UvElement *element, *initelement = vmap->vert[(*(&efa->v1 + j))->tmp.l];
+						for(element = initelement; element; element = element->next){
+							if(element->separate){
+								initelement = element;
+							}
+							if(element->face == efa){
+								/* found the uv corresponding to our face and vertex. Now fill it to the buffer */
+								element->island = nislands;
+								map[element - vmap->buf] = islandbufsize;
+								islandbuf[islandbufsize].tfindex = element->tfindex;
+								islandbuf[islandbufsize].face = element->face;
+								islandbuf[islandbufsize].separate = element->separate;
+								islandbuf[islandbufsize].island =  nislands;
+								islandbufsize++;
 
-							for(element = initelement; element; element = element->next){
-								if(element->separate && element != initelement){
-									break;
+								for(element = initelement; element; element = element->next){
+									if(element->separate && element != initelement){
+										break;
+									}
+									if(element->face->tmp.l == INVALID_ISLAND){
+										stack[stacksize++] = element->face;
+										element->face->tmp.l = nislands;
+									}
 								}
-								if(element->face->tmp.l == INVALID_ISLAND){
-									stack[stacksize++] = element->face;
-									element->face->tmp.l = nislands;
-								}
+								break;
 							}
-							break;
 						}
 					}
 				}
+
+				nislands++;
 			}
+		}
+		/* Remap */
+		for(i = 0; i < em->totvert; i++){
+			vmap->vert[i] = &islandbuf[map[vmap->vert[i] - vmap->buf]];
+		}
+		vmap->islandIndices = MEM_callocN(sizeof(*vmap->islandIndices)*nislands,"UvVertMap2_island_indices");
+		if(!vmap->islandIndices)
+		{
+			MEM_freeN(islandbuf);
+			MEM_freeN(stack);
+			MEM_freeN(map);
+			EM_free_uv_element_map(vmap);
+		}
 
-			nislands++;
+		j = 0;
+		for(i = 0; i < totuv; i++){
+			UvElement *element = vmap->buf[i].next;
+			if(element == NULL){
+				islandbuf[map[i]].next = NULL;
+			} else {
+				islandbuf[map[i]].next = &islandbuf[map[element - vmap->buf]];
+			}
+			if(islandbuf[i].island != j){
+				j++;
+				vmap->islandIndices[j] = i;
+			}
 		}
-	}
-	/* Remap */
-	for(i = 0; i < em->totvert; i++){
-		vmap->vert[i] = &islandbuf[map[vmap->vert[i] - vmap->buf]];
-	}
-	vmap->islandIndices = MEM_callocN(sizeof(*vmap->islandIndices)*nislands,"UvVertMap2_island_indices");
-	if(!vmap->islandIndices)
-	{
-		MEM_freeN(islandbuf);
+
+		MEM_freeN(vmap->buf);
+
+		vmap->buf = islandbuf;
+		vmap->numOfIslands = nislands;
 		MEM_freeN(stack);
 		MEM_freeN(map);
-		EM_free_uv_vert_map2(vmap);
 	}
 
-
-	j = 0;
-	for(i = 0; i < totuv; i++){
-		UvElement *element = vmap->buf[i].next;
-		if(element == NULL){
-			islandbuf[map[i]].next = NULL;
-		} else {
-			islandbuf[map[i]].next = &islandbuf[map[element - vmap->buf]];
-		}
-		if(islandbuf[i].island != j){
-			j++;
-			vmap->islandIndices[j] = i;
-		}
-	}
-
-	MEM_freeN(vmap->buf);
-
-	vmap->buf = islandbuf;
-	vmap->numOfIslands = nislands;
-	MEM_freeN(stack);
-	MEM_freeN(map);
 	return vmap;
 }
 /* The function below is buggy, should check face first. correct before use */
@@ -2609,7 +2611,7 @@
 	}
 }
 
-void EM_free_uv_vert_map2(UvElementMap *vmap)
+void EM_free_uv_element_map(UvElementMap *vmap)
 {
 	if (vmap) {
 		if (vmap->vert) MEM_freeN(vmap->vert);

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c	2011-08-10 22:23:08 UTC (rev 39278)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c	2011-08-10 22:43:02 UTC (rev 39279)
@@ -687,6 +687,7 @@
 	keymap->poll= uv_smooth_poll;
 
 	WM_keymap_add_item(keymap, "PAINT_OT_uv_smooth_stroke", LEFTMOUSE, KM_PRESS, 0, 0);
+	RNA_boolean_set(WM_keymap_add_item(keymap, "PAINT_OT_uv_smooth_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
 
 	ed_keymap_paint_brush_size(keymap, "tool_settings.uv_smooth.brush.size");
 	ed_keymap_paint_brush_radial_control(keymap, "uv_smooth", RC_ZOOM, 0);

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_uv.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_uv.c	2011-08-10 22:23:08 UTC (rev 39278)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_uv.c	2011-08-10 22:43:02 UTC (rev 39279)
@@ -56,6 +56,7 @@
 
 #include "ED_screen.h"
 #include "ED_image.h"
+#include "ED_mesh.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -331,6 +332,8 @@
 	/* Timer to be used for airbrush-type brush */
 	wmTimer *timer;
 
+	/* To determine quickly adjacent uvs */
+	UvElementMap *elementMap;
 	/* uvsmooth Paint for fast reference */
 	Paint *uvpaint;
 }SmoothBrushData;
@@ -344,9 +347,12 @@
 	EditFace *efa;
 	SmoothBrushData *smoothbrushdata = (SmoothBrushData *)op->customdata;
 	SpaceImage *sima;
+	char invert;
 	int width, height;
 	float aspectRatio;
 	Brush *brush = paint_brush(smoothbrushdata->uvpaint);
+	invert = RNA_boolean_get(op->ptr, "invert");
+
 	UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
 
 	radius = brush_size(brush);
@@ -369,8 +375,13 @@
 				float strength;
 				strength = brush_curve_strength(brush, dist, radius);
 				normalize_v2(diff);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list