[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59250] trunk/blender/source/blender/ editors/sculpt_paint/sculpt.c: Fix #34485 sculpt strength weirdly inverted with some mesh part.

Antony Riakiotakis kalast at gmail.com
Mon Aug 19 00:44:43 CEST 2013


Revision: 59250
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59250
Author:   psy-fi
Date:     2013-08-18 22:44:43 +0000 (Sun, 18 Aug 2013)
Log Message:
-----------
Fix #34485 sculpt strength weirdly inverted with some mesh part.

The view vector was not being calculated correctly. Shamelessly rip off
correct transform to object space from projective texture painting code.

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	2013-08-18 22:25:37 UTC (rev 59249)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2013-08-18 22:44:43 UTC (rev 59250)
@@ -3716,7 +3716,8 @@
 	Brush *brush = BKE_paint_brush(&sd->paint);
 	ViewContext *vc = paint_stroke_view_context(op->customdata);
 	Object *ob = CTX_data_active_object(C);
-	float rot[3][3], scale[3], loc[3];
+	float mat[3][3];
+	float viewDir[3] = {0.0f, 0.0f, 1.0f};
 	int i;
 	int mode;
 
@@ -3784,12 +3785,13 @@
 	/* cache projection matrix */
 	ED_view3d_ob_project_mat_get(cache->vc->rv3d, ob, cache->projection_mat);
 
-	mat4_to_loc_rot_size(loc, rot, scale, ob->obmat);
-	/* transposing an orthonormal matrix inverts */
-	transpose_m3(rot);
-	ED_view3d_global_to_vector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal);
-	/* This takes care of rotated mesh. Instead of rotating every normal, we inverse rotate view normal. */
-	mul_m3_v3(rot, cache->true_view_normal);
+	invert_m4_m4(ob->imat, ob->obmat);
+	copy_m3_m4(mat, cache->vc->rv3d->viewinv);
+	mul_m3_v3(mat, viewDir);
+	copy_m3_m4(mat, ob->imat);
+	mul_m3_v3(mat, viewDir);
+	normalize_v3_v3(cache->true_view_normal, viewDir);
+
 	/* Initialize layer brush displacements and persistent coords */
 	if (brush->sculpt_tool == SCULPT_TOOL_LAYER) {
 		/* not supported yet for multires or dynamic topology */




More information about the Bf-blender-cvs mailing list