[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30104] branches/soc-2010-jwilkins: == Radial Symmetry ==

Jason Wilkins Jason.A.Wilkins at gmail.com
Thu Jul 8 10:26:11 CEST 2010


Revision: 30104
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30104
Author:   jwilkins
Date:     2010-07-08 10:26:10 +0200 (Thu, 08 Jul 2010)

Log Message:
-----------
== Radial Symmetry ==
Now there is mirror symmetry and radial symmetry that can be mixed and matched at the same time (never trust me when I say something is difficult :)

Modified Paths:
--------------
    branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
    branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2010-jwilkins/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_sculpt_paint.c

Modified: branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py	2010-07-08 07:49:42 UTC (rev 30103)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py	2010-07-08 08:26:10 UTC (rev 30104)
@@ -1030,22 +1030,17 @@
         split = self.layout.split()
 
         col = split.column()
-        col.label(text="Symmetry:")
-        col.prop(sculpt, "symmetry_mode", text="")
 
-        if sculpt.symmetry_mode == 'PLANAR':
-            col.prop(sculpt, "symmetry_x", text="X")
-            col.prop(sculpt, "symmetry_y", text="Y")
-            col.prop(sculpt, "symmetry_z", text="Z")
-        elif sculpt.symmetry_mode == 'RADIAL':
-            col.label(text="Count:")
-            col.prop(sculpt, "radial_symmetry_count", text="")
-            col.label(text="Axis:")
-            col.prop(sculpt, "radial_symmetry_axis", text="")
+        col.label(text="Mirror:")
+        col.prop(sculpt, "symmetry_x", text="X")
+        col.prop(sculpt, "symmetry_y", text="Y")
+        col.prop(sculpt, "symmetry_z", text="Z")
 
-        #if sculpt.symmetry_mode != 'NONE':
-        #    col.prop(sculpt, "use_symmetry_feather", text="Feather")
+        col.prop(sculpt, "radial_symm", text="Radial")
 
+        #col.separator()
+        #col.prop(sculpt, "use_symmetry_feather", text="Feather")
+
         col = split.column()
         col.label(text="Lock:")
         col.prop(sculpt, "lock_x", text="X")

Modified: branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c	2010-07-08 07:49:42 UTC (rev 30103)
+++ branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c	2010-07-08 08:26:10 UTC (rev 30104)
@@ -10987,17 +10987,6 @@
 				brush->crease_pinch_factor = 2.0f/3.0f;
 		}
 	}
-	{
-		Scene *scene;
-		for (scene= main->scene.first; scene; scene= scene->id.next) {
-			if ( scene->toolsettings &&
-				 scene->toolsettings->sculpt && 
-				(scene->toolsettings->sculpt->flags & (SCULPT_RADIAL_SYMM_X|SCULPT_RADIAL_SYMM_Y|SCULPT_RADIAL_SYMM_Z)) == 0)
-			{
-				scene->toolsettings->sculpt->flags |= SCULPT_RADIAL_SYMM_Z;
-			}
-		}
-	}
 
 	/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
 	/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-07-08 07:49:42 UTC (rev 30103)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-07-08 08:26:10 UTC (rev 30104)
@@ -209,13 +209,14 @@
 
 	int symmetry; /* Symmetry index between 0 and 7 bit combo 0 is Brush only;
 		1 is X mirror; 2 is Y mirror; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
-	int planar_symmetry_pass; /* the symmetry pass we are currently on between 0 and 7*/
-	float view_normal[3], view_normal_symmetry[3];
+	int mirror_symmetry_pass; /* the symmetry pass we are currently on between 0 and 7*/
+	float view_normal[3];
 	float last_area_normal[3];
 	float last_view_normal_symmetry[3];
 	float last_center[3];
 	int radial_symmetry_pass;
 	float symm_rot_mat[4][4];
+	float symm_rot_mat_inv[4][4];
 	int last_rake[2]; /* Last location of updating rake rotation */
 	int original;
 
@@ -340,7 +341,7 @@
 
 	//float true_location[3];
 	//int symmetry;
-	//int planar_symmetry_pass;
+	//int mirror_symmetry_pass;
 } SculptBrushTest;
 
 static void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test)
@@ -350,7 +351,7 @@
 
 	//copy_v3_v3(test->true_location, ss->cache->true_location);
 	//test->symmetry = ss->cache->symmetry;
-	//test->planar_symmetry_pass = ss->cache->planar_symmetry_pass;
+	//test->mirror_symmetry_pass = ss->cache->mirror_symmetry_pass;
 }
 
 //static int sculpt_brush_test_clip(SculptBrushTest* test, float co[3])
@@ -359,7 +360,7 @@
 //		int i;
 //
 //		for (i = 0; i < 3; i++) {
-//			if (test->planar_symmetry_pass & (1<<i)) {
+//			if (test->mirror_symmetry_pass & (1<<i)) {
 //				if (test->true_location[i] >= 0) {
 //					if (co[i] >= 0) return 0;
 //				}
@@ -689,9 +690,15 @@
 		float diameter;
 
 		/* if the active area is being applied for symmetry, flip it
-		   across the symmetry axis in order to project it. This insures
-		   that the brush texture will be oriented correctly. */
-		flip_coord(point_2d, point, ss->cache->planar_symmetry_pass);
+		   across the symmetry axis and rotate it back to the orignal
+		   position in order to project it. This insures that the 
+		   brush texture will be oriented correctly. */
+
+		flip_coord(point_2d, point, ss->cache->mirror_symmetry_pass);
+
+		if (ss->cache->radial_symmetry_pass)
+			mul_m4_v3(ss->cache->symm_rot_mat_inv, point_2d);
+
 		projectf(ss->cache->mats, point_2d, point_2d);
 
 		/* if fixed mode, keep coordinates relative to mouse */
@@ -840,7 +847,7 @@
 {
 	Brush *brush = paint_brush(&sd->paint);
 
-	if (ss->cache->planar_symmetry_pass == 0 &&
+	if (ss->cache->mirror_symmetry_pass == 0 &&
 	    ss->cache->radial_symmetry_pass == 0 &&
 	   (ss->cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL)))
 	{
@@ -896,7 +903,7 @@
 									float fno[3];
 
 									normal_short_to_float_v3(fno, unode->no[vd.i]);
-									add_norm_if(ss->cache->view_normal_symmetry, private_an, private_out_flip, fno);
+									add_norm_if(ss->cache->view_normal, private_an, private_out_flip, fno);
 								}
 							}
 							BLI_pbvh_vertex_iter_end;
@@ -908,10 +915,10 @@
 										float fno[3];
 
 										normal_short_to_float_v3(fno, vd.no);
-										add_norm_if(ss->cache->view_normal_symmetry, private_an, private_out_flip, fno);
+										add_norm_if(ss->cache->view_normal, private_an, private_out_flip, fno);
 									}
 									else {
-										add_norm_if(ss->cache->view_normal_symmetry, private_an, private_out_flip, vd.fno);
+										add_norm_if(ss->cache->view_normal, private_an, private_out_flip, vd.fno);
 									}
 								}
 							}
@@ -936,20 +943,11 @@
 		}
 
 		copy_v3_v3(ss->cache->last_area_normal, an);
-		copy_v3_v3(ss->cache->last_view_normal_symmetry, ss->cache->view_normal_symmetry);
 	}
 	else {
 		copy_v3_v3(an, ss->cache->last_area_normal);
-		copy_v3_v3(ss->cache->view_normal_symmetry, ss->cache->last_view_normal_symmetry);
-
-		if (sd->flags & SCULPT_RADIAL_SYMM) {
-			mul_v3_m4v3(an, ss->cache->symm_rot_mat, an);
-			mul_v3_m4v3(ss->cache->view_normal_symmetry, ss->cache->symm_rot_mat, ss->cache->view_normal_symmetry);
-		}
-		else {
-			flip_coord(an, an, ss->cache->planar_symmetry_pass);
-			flip_coord(ss->cache->view_normal_symmetry, ss->cache->view_normal_symmetry, ss->cache->planar_symmetry_pass);
-		}
+		flip_coord(an, an, ss->cache->mirror_symmetry_pass);
+		mul_m4_v3(ss->cache->symm_rot_mat, an);
 	}
 }
 
@@ -1493,7 +1491,7 @@
 	int n;
 	float m[3][3];
 	static const int flip[8] = { 1, -1, -1, 1, -1, 1, 1, -1 };
-	float angle = ss->cache->vertex_rotation * flip[ss->cache->planar_symmetry_pass];
+	float angle = ss->cache->vertex_rotation * flip[ss->cache->mirror_symmetry_pass];
 
 	calc_area_normal(sd, ss, an, nodes, totnode);
 
@@ -1688,7 +1686,7 @@
 {
 	Brush *brush = paint_brush(&sd->paint);
 
-	if (ss->cache->planar_symmetry_pass == 0 &&
+	if (ss->cache->mirror_symmetry_pass == 0 &&
 	    ss->cache->radial_symmetry_pass == 0 &&
 	   (ss->cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL)))
 	{
@@ -1753,7 +1751,7 @@
 									float fno[3];
 
 									normal_short_to_float_v3(fno, unode->no[vd.i]);
-									add_norm_if(ss->cache->view_normal_symmetry, private_an, private_out_flip, fno);
+									add_norm_if(ss->cache->view_normal, private_an, private_out_flip, fno);
 
 									// fc
 									add_v3_v3(private_fc, vd.co);
@@ -1770,10 +1768,10 @@
 										float fno[3];
 
 										normal_short_to_float_v3(fno, vd.no);
-										add_norm_if(ss->cache->view_normal_symmetry, private_an, private_out_flip, fno);
+										add_norm_if(ss->cache->view_normal, private_an, private_out_flip, fno);
 									}
 									else {
-										add_norm_if(ss->cache->view_normal_symmetry, private_an, private_out_flip, vd.fno);
+										add_norm_if(ss->cache->view_normal, private_an, private_out_flip, vd.fno);
 									}
 
 									// fc
@@ -1817,7 +1815,6 @@
 
 		// an
 		copy_v3_v3(ss->cache->last_area_normal, an);
-		copy_v3_v3(ss->cache->last_view_normal_symmetry, ss->cache->view_normal_symmetry);
 
 		// fc
 		copy_v3_v3(ss->cache->last_center, fc);
@@ -1825,21 +1822,21 @@
 	else {
 		// an
 		copy_v3_v3(an, ss->cache->last_area_normal);
-		copy_v3_v3(ss->cache->view_normal_symmetry, ss->cache->last_view_normal_symmetry);
 
 		// fc
 		copy_v3_v3(fc, ss->cache->last_center);
 
-		if (sd->flags & SCULPT_RADIAL_SYMM) {
-			mul_v3_m4v3(an, ss->cache->symm_rot_mat, an);
-			mul_v3_m4v3(ss->cache->view_normal_symmetry, ss->cache->symm_rot_mat, ss->cache->view_normal_symmetry);
-			mul_v3_m4v3(fc, ss->cache->symm_rot_mat, fc);
-		}
-		else {
-			flip_coord(an, an, ss->cache->planar_symmetry_pass);
-			flip_coord(ss->cache->view_normal_symmetry, ss->cache->view_normal_symmetry, ss->cache->planar_symmetry_pass);
-			flip_coord(fc, fc, ss->cache->planar_symmetry_pass);
-		}
+		// an
+		flip_coord(an, an, ss->cache->mirror_symmetry_pass);
+
+		// fc
+		flip_coord(fc, fc, ss->cache->mirror_symmetry_pass);
+
+		// an
+		mul_m4_v3(ss->cache->symm_rot_mat, an);
+
+		// fc
+		mul_m4_v3(ss->cache->symm_rot_mat, fc);
 	}
 }
 
@@ -2434,34 +2431,32 @@
 
 /* Flip all the editdata across the axis/axes specified by symm. Used to
    calculate multiple modifications to the mesh when symmetry is enabled. */
-static void calc_brushdata_symm(StrokeCache *cache, const char symm)
+static void calc_brushdata_symm(StrokeCache *cache, const char symm, const char axis, const float angle)
 {
 	flip_coord(cache->location, cache->true_location, symm);
-	flip_coord(cache->view_normal_symmetry, cache->view_normal, symm);
 	flip_coord(cache->grab_delta_symmetry, cache->grab_delta, symm);
-}
 
-static void calc_brushdata_radial_symm(Sculpt* sd, StrokeCache *cache, const float angle)
-{
-	char axis;
-
-	if (sd->flags & SCULPT_RADIAL_SYMM_X)
-		axis = 'X';

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list