[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29674] branches/soc-2010-jwilkins/source/ blender: == Alt-Smooth ==

Jason Wilkins Jason.A.Wilkins at gmail.com
Thu Jun 24 20:14:51 CEST 2010


Revision: 29674
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29674
Author:   jwilkins
Date:     2010-06-24 20:14:51 +0200 (Thu, 24 Jun 2010)

Log Message:
-----------
== Alt-Smooth ==
Press alt-key to switch to the brush preset named "Smooth" (it may or may not smooth depending on if you messed up your preset /sigh)

Modified Paths:
--------------
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_ops.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_sculpt_paint.c

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_ops.c	2010-06-24 18:12:59 UTC (rev 29673)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_ops.c	2010-06-24 18:14:51 UTC (rev 29674)
@@ -206,6 +206,7 @@
 
 	WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0);
 	WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
+	WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_ALT, 0);
 
 	for(i=0; i<=5; i++)
 		RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i);
@@ -221,7 +222,8 @@
 
 	ed_keymap_paint_brush_switch(keymap, "tool_settings.sculpt.active_brush_index");
 	ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size");
-	
+
+	/* */
 	kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", AKEY, KM_PRESS, 0, 0);
 	RNA_string_set(kmi->ptr, "path", "tool_settings.sculpt.brush.use_anchor");
 
@@ -254,11 +256,10 @@
 	kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", LKEY, KM_PRESS, 0, 0);
 	RNA_string_set(kmi->ptr, "path", "tool_settings.sculpt.active_brush_name");
 	RNA_string_set(kmi->ptr, "value", "Layer");
-	
+
 	kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", TKEY, KM_PRESS, KM_SHIFT, 0); // was just T in 2.4x
 	RNA_string_set(kmi->ptr, "path", "tool_settings.sculpt.active_brush_name");
 	RNA_string_set(kmi->ptr, "value", "Flatten");
-	
 
 	/* Vertex Paint mode */
 	keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0);

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c	2010-06-24 18:12:59 UTC (rev 29673)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c	2010-06-24 18:14:51 UTC (rev 29674)
@@ -695,6 +695,7 @@
 	float pressure = 1;
 	float center[3] = {0, 0, 0};
 	int flip= event->shift?1:0;
+
 	PaintStroke *stroke = op->customdata;
 
 	/* XXX: can remove the if statement once all modes have this */

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-06-24 18:12:59 UTC (rev 29673)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-06-24 18:14:51 UTC (rev 29674)
@@ -220,6 +220,9 @@
 	int original;
 
 	float vertex_rotation;
+
+	char saved_active_brush_name[24];
+	int alt_smooth;
 } StrokeCache;
 
 /* ===== OPENGL =====
@@ -2382,6 +2385,8 @@
 		return "Flatten Brush"; break;
 	case SCULPT_TOOL_CLAY:
 		return "Clay Brush"; break;
+	case SCULPT_TOOL_WAX:
+		return "Wax Brush"; break;
 	case SCULPT_TOOL_FILL:
 		return "Fill Brush"; break;
 	case SCULPT_TOOL_SCRAPE:
@@ -2464,7 +2469,7 @@
 }
 
 /* Initialize the stroke cache invariants from operator properties */
-static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, wmOperator *op)
+static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSession *ss, wmOperator *op)
 {
 	StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
 	Brush *brush = paint_brush(&sd->paint);
@@ -2478,6 +2483,25 @@
 	RNA_float_get_array(op->ptr, "clip_tolerance", cache->clip_tolerance);
 	RNA_float_get_array(op->ptr, "initial_mouse", cache->initial_mouse);
 
+	RNA_boolean_get_array(op->ptr, "alt_smooth", &cache->alt_smooth);
+
+	if (cache->alt_smooth) {
+		Paint *p= &sd->paint;
+		Brush *br;
+		int i;
+		
+		BLI_strncpy(cache->saved_active_brush_name, brush->id.name+2, sizeof(cache->saved_active_brush_name));
+
+		for(i = 0; i < p->brush_count; ++i) {
+			br = p->brushes[i];
+		
+			if (strcmp(br->id.name+2, "Smooth")==0) {
+				paint_brush_set(p, br);
+				break;
+			}
+		}
+	}
+
 	copy_v2_v2(cache->mouse, cache->initial_mouse);
 	copy_v2_v2(cache->tex_mouse, cache->initial_mouse);
 
@@ -2869,6 +2893,7 @@
 	float scale[3], clip_tolerance[3] = {0,0,0};
 	float mouse[2];
 	int flag = 0;
+	int alt_smooth;
 
 	/* Set scaling adjustment */
 	scale[0] = 1.0f / ob->size[0];
@@ -2896,6 +2921,10 @@
 	mouse[0] = event->x;
 	mouse[1] = event->y;
 	RNA_float_set_array(op->ptr, "initial_mouse", mouse);
+
+	/* Alt-Smooth */
+	alt_smooth = event->alt;
+	RNA_boolean_set_array(op->ptr, "alt_smooth", &alt_smooth);
 }
 
 static int sculpt_brush_stroke_init(bContext *C, ReportList *reports)
@@ -3031,7 +3060,7 @@
 
 		sculpt_brush_stroke_init_properties(C, op, event);
 
-		sculpt_update_cache_invariants(sd, ss, op);
+		sculpt_update_cache_invariants(C, sd, ss, op);
 
 		sculpt_undo_push_begin(sculpt_tool_name(sd));
 
@@ -3085,8 +3114,25 @@
 	if(ss->cache) {
 		sculpt_stroke_modifiers_check(C, ss);
 		
-		if(brush->flag & BRUSH_SUBDIV) unlimited_clay(ss, ob);
+		if(brush->flag & BRUSH_SUBDIV)
+			unlimited_clay(ss, ob);
 
+		/* Alt-Smooth */
+		if (ss->cache->alt_smooth) {
+			Paint *p= &sd->paint;
+			Brush *br;
+			int i;
+
+			for(i = 0; i < p->brush_count; ++i) {
+				br = p->brushes[i];
+
+				if (strcmp(br->id.name+2, ss->cache->saved_active_brush_name)==0) {
+					paint_brush_set(p, br);
+					break;
+				}
+			}
+		}
+
 		sculpt_cache_free(ss->cache);
 		ss->cache = NULL;
 
@@ -3148,7 +3194,7 @@
 	op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start,
 					  sculpt_stroke_update_step, sculpt_stroke_done);
 
-	sculpt_update_cache_invariants(sd, ss, op);
+	sculpt_update_cache_invariants(C, sd, ss, op);
 
 	paint_stroke_exec(C, op);
 
@@ -3190,6 +3236,10 @@
 	/* The initial 2D location of the mouse */
 	RNA_def_float_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX);
 
+	RNA_def_boolean(ot->srna, "alt_smooth", 0, 
+			NULL, 
+			NULL);
+
 	RNA_def_boolean(ot->srna, "ignore_background_click", 0,
 			"Ignore Background Click",
 			"Clicks on the background don't start the stroke");

Modified: branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_sculpt_paint.c	2010-06-24 18:12:59 UTC (rev 29673)
+++ branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_sculpt_paint.c	2010-06-24 18:14:51 UTC (rev 29674)
@@ -193,7 +193,7 @@
 	Paint *p= ptr->data;
 	Brush *br = paint_brush(p);
 	
-	BLI_strncpy(value, br->id.name+2, sizeof(br->id.name-2));
+	BLI_strncpy(value, br->id.name+2, sizeof(br->id.name)-2);
 }
 
 





More information about the Bf-blender-cvs mailing list