[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42555] trunk/blender: Fix #29516: Twist brush giving crazy results

Sergey Sharybin sergey.vfx at gmail.com
Sat Dec 10 15:45:37 CET 2011


Revision: 42555
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42555
Author:   nazgul
Date:     2011-12-10 14:45:30 +0000 (Sat, 10 Dec 2011)
Log Message:
-----------
Fix #29516: Twist brush giving crazy results

- Rotation now happens around initial stroke location rather than around scene origin
- Added slider for rotation strength which helps in cases only few rotation is needed
  to be to increase the precision of such strokes

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    trunk/blender/source/blender/blenkernel/BKE_blender.h
    trunk/blender/source/blender/blenkernel/intern/brush.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2011-12-10 13:54:51 UTC (rev 42554)
+++ trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2011-12-10 14:45:30 UTC (rev 42555)
@@ -546,6 +546,11 @@
                 row.prop(brush, "strength", text="Strength", slider=True)
                 row.prop(brush, "use_pressure_strength", text="")
 
+            if tool == 'ROTATE':
+                row = col.row(align=True)
+                row.prop(brush, "strength", text="Strength", slider=True)
+                row.prop(brush, "use_pressure_strength", text="")
+
             if tool != 'SMOOTH':
                 col.separator()
 

Modified: trunk/blender/source/blender/blenkernel/BKE_blender.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_blender.h	2011-12-10 13:54:51 UTC (rev 42554)
+++ trunk/blender/source/blender/blenkernel/BKE_blender.h	2011-12-10 14:45:30 UTC (rev 42555)
@@ -42,7 +42,7 @@
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION			260
-#define BLENDER_SUBVERSION		7
+#define BLENDER_SUBVERSION		8
 
 #define BLENDER_MINVERSION		250
 #define BLENDER_MINSUBVERSION	0

Modified: trunk/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/brush.c	2011-12-10 13:54:51 UTC (rev 42554)
+++ trunk/blender/source/blender/blenkernel/intern/brush.c	2011-12-10 14:45:30 UTC (rev 42555)
@@ -384,6 +384,7 @@
 		br->sub_col[1] = 1.000000;
 		break;
 	case SCULPT_TOOL_ROTATE:
+		br->alpha = 1.0;
 		break;
 	case SCULPT_TOOL_SMOOTH:
 		br->flag &= ~BRUSH_SPACE_ATTEN;

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2011-12-10 13:54:51 UTC (rev 42554)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2011-12-10 14:45:30 UTC (rev 42555)
@@ -12655,6 +12655,16 @@
 		}
 	}
 
+	if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 8))
+	{
+		Brush *brush;
+
+		for (brush= main->brush.first; brush; brush= brush->id.next) {
+			if (brush->sculpt_tool == SCULPT_TOOL_ROTATE)
+				brush->alpha= 1.0f;
+		}
+	}
+
 	/* put compatibility code here until next subversion bump */
 	{
 		/* nothing! */

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2011-12-10 13:54:51 UTC (rev 42554)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2011-12-10 14:45:30 UTC (rev 42555)
@@ -648,9 +648,11 @@
 			return feather;
 
 		case SCULPT_TOOL_GRAB:
-		case SCULPT_TOOL_ROTATE:
 			return feather;
 
+		case SCULPT_TOOL_ROTATE:
+			return alpha*pressure*feather;
+
 		default:
 			return 0;
 	}
@@ -1502,14 +1504,21 @@
 	float bstrength= ss->cache->bstrength;
 	float an[3];
 	int n;
-	float m[3][3];
+	float m[4][4], rot[4][4], lmat[4][4], ilmat[4][4];
 	static const int flip[8] = { 1, -1, -1, 1, -1, 1, 1, -1 };
 	float angle = ss->cache->vertex_rotation * flip[ss->cache->mirror_symmetry_pass];
 
 	calc_sculpt_normal(sd, ob, an, nodes, totnode);
 
-	axis_angle_to_mat3(m, an, angle);
+	unit_m4(m);
+	unit_m4(lmat);
 
+	copy_v3_v3(lmat[3], ss->cache->location);
+	invert_m4_m4(ilmat, lmat);
+	axis_angle_to_mat4(rot, an, angle);
+
+	mul_serie_m4(m, lmat, rot, ilmat, NULL, NULL, NULL, NULL, NULL);
+
 	#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
 	for(n=0; n<totnode; n++) {
 		PBVHVertexIter vd;
@@ -1532,7 +1541,7 @@
 				const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist,
 				                                          an, origno[vd.i], NULL);
 
-				mul_v3_m3v3(proxy[vd.i], m, origco[vd.i]);
+				mul_v3_m4v3(proxy[vd.i], m, origco[vd.i]);
 				sub_v3_v3(proxy[vd.i], origco[vd.i]);
 				mul_v3_fl(proxy[vd.i], fade);
 
@@ -3160,7 +3169,7 @@
 		dx = cache->mouse[0] - cache->initial_mouse[0];
 		dy = cache->mouse[1] - cache->initial_mouse[1];
 
-		cache->vertex_rotation = -atan2(dx, dy);
+		cache->vertex_rotation = -atan2(dx, dy) * cache->bstrength;
 
 		sd->draw_anchored = 1;
 		copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse);




More information about the Bf-blender-cvs mailing list