[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47691] trunk/blender/source/blender/ editors/sculpt_paint/sculpt.c: Bugfix for autosmooth in sculpt mode.

Nicholas Bishop nicholasbishop at gmail.com
Sun Jun 10 18:23:04 CEST 2012


Revision: 47691
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47691
Author:   nicholasbishop
Date:     2012-06-10 16:22:58 +0000 (Sun, 10 Jun 2012)
Log Message:
-----------
Bugfix for autosmooth in sculpt mode.

This option was broken for non-multires meshes (not sure for how
long), as the pmap was not getting calculated.

Added a more general check for whether the pmap is needed, also added
an assert to warn about this in future.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2012-06-10 16:16:02 UTC (rev 47690)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2012-06-10 16:22:58 UTC (rev 47691)
@@ -1413,6 +1413,7 @@
 	SculptSession *ss = ob->sculpt;
 	const int max_iterations = 4;
 	const float fract = 1.0f / max_iterations;
+	PBVHType type = BLI_pbvh_type(ss->pbvh);
 	int iteration, n, count;
 	float last;
 
@@ -1421,17 +1422,26 @@
 	count = (int)(bstrength * max_iterations);
 	last  = max_iterations * (bstrength - count * fract);
 
+	if (type == PBVH_FACES && !ss->pmap) {
+		BLI_assert(!"sculpt smooth: pmap missing");
+		return;
+	}
+
 	for (iteration = 0; iteration <= count; ++iteration) {
+		float strength = (iteration != count) ? 1.0f : last;
+
 		#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
 		for (n = 0; n < totnode; n++) {
-			if (ss->multires) {
-				do_multires_smooth_brush(sd, ss, nodes[n],
-				                         iteration != count ? 1.0f : last, smooth_mask);
+			switch(type) {
+				case PBVH_GRIDS:
+					do_multires_smooth_brush(sd, ss, nodes[n], strength,
+										     smooth_mask);
+					break;
+				case PBVH_FACES:
+					do_mesh_smooth_brush(sd, ss, nodes[n], strength,
+			                             smooth_mask);
+					break;
 			}
-			else if (ss->pmap) {
-				do_mesh_smooth_brush(sd, ss, nodes[n],
-				                     iteration != count ? 1.0f : last, smooth_mask);
-			}
 		}
 
 		if (ss->multires)
@@ -3571,6 +3581,21 @@
 	sd->special_rotation = cache->special_rotation;
 }
 
+/* Returns true iff any of the smoothing modes are active (currently
+   one of smooth brush, autosmooth, mask smooth, or shift-key
+   smooth) */
+static int sculpt_any_smooth_mode(const Brush *brush,
+								  StrokeCache *cache,
+								  int stroke_mode)
+{
+	return ((stroke_mode == BRUSH_STROKE_SMOOTH) ||
+			(cache && cache->alt_smooth) ||
+			(brush->sculpt_tool == SCULPT_TOOL_SMOOTH) ||
+			(brush->autosmooth_factor > 0) ||
+			((brush->sculpt_tool == SCULPT_TOOL_MASK) &&
+			 (brush->mask_tool == BRUSH_MASK_SMOOTH)));
+}
+
 static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob)
 {
 	SculptSession *ss = ob->sculpt;
@@ -3579,7 +3604,8 @@
 		Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
 		Brush *brush = paint_brush(&sd->paint);
 
-		sculpt_update_mesh_elements(CTX_data_scene(C), sd, ob, brush->sculpt_tool == SCULPT_TOOL_SMOOTH);
+		sculpt_update_mesh_elements(CTX_data_scene(C), sd, ob,
+									sculpt_any_smooth_mode(brush, ss->cache, 0));
 	}
 }
 
@@ -3689,11 +3715,7 @@
 	view3d_operator_needs_opengl(C);
 	sculpt_brush_init_tex(scene, sd, ss);
 
-	is_smooth |= mode == BRUSH_STROKE_SMOOTH;
-	is_smooth |= brush->sculpt_tool == SCULPT_TOOL_SMOOTH;
-	is_smooth |= ((brush->sculpt_tool == SCULPT_TOOL_MASK) &&
-	              (brush->mask_tool == BRUSH_MASK_SMOOTH));
-
+	is_smooth = sculpt_any_smooth_mode(brush, NULL, mode);
 	sculpt_update_mesh_elements(scene, sd, ob, is_smooth);
 
 	return 1;




More information about the Bf-blender-cvs mailing list