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

Jason Wilkins Jason.A.Wilkins at gmail.com
Thu Jul 8 08:45:21 CEST 2010


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

Log Message:
-----------
== Radial Symmetry ==
Symmetry has two modes now, planar and radial.  They are mutually exclusive currently but could probably be mixed and matched later (thats too complicated for a simple feature atm).

I have not added a new feature for a bit so I thought I'd throw this in since it was requested just to let our feedback team know I'm alive :)

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 06:16:08 UTC (rev 30100)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py	2010-07-08 06:45:21 UTC (rev 30101)
@@ -599,7 +599,7 @@
 
 
                 row = col.row()
-                row.prop(brush, "strength_multiplier", slider=True)
+                row.prop(brush, "strength_multiplier")
 
 
 
@@ -841,7 +841,7 @@
             col.active = tex_slot.map_mode in ('TILED')
 
             col = row.column()
-            col.prop(brush, "texture_overlay_alpha", slider=True, text="Alpha")
+            col.prop(brush, "texture_overlay_alpha", text="Alpha")
             col.active = tex_slot.map_mode in ('TILED') and brush.use_texture_overlay
 
 
@@ -915,7 +915,7 @@
                 col.separator()
                 row = col.row()
                 row.active = brush.use_space
-                row.prop(brush, "spacing", text="Spacing", slider=True)
+                row.prop(brush, "spacing", text="Spacing")
 
             if brush.sculpt_tool not in ('GRAB', 'THUMB', 'SNAKE_HOOK', 'ROTATE') and (not brush.use_anchor) and (not brush.restore_mesh):
                 col = layout.column()
@@ -1031,11 +1031,21 @@
 
         col = split.column()
         col.label(text="Symmetry:")
-        col.prop(sculpt, "symmetry_x", text="X")
-        col.prop(sculpt, "symmetry_y", text="Y")
-        col.prop(sculpt, "symmetry_z", text="Z")
-        #col.prop(sculpt, "use_symmetry_feather", text="Feather")
+        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="")
+
+        #if sculpt.symmetry_mode != 'NONE':
+        #    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 06:16:08 UTC (rev 30100)
+++ branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c	2010-07-08 06:45:21 UTC (rev 30101)
@@ -10987,6 +10987,17 @@
 				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 06:16:08 UTC (rev 30100)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-07-08 06:45:21 UTC (rev 30101)
@@ -190,7 +190,6 @@
 	float mouse[2];
 	float bstrength;
 	float tex_mouse[2];
-	int sculpt_plane;
 
 	/* The rest is temporary storage that isn't saved as a property */
 
@@ -210,11 +209,13 @@
 
 	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 symmetry_pass; /* the symmetry pass we are currently on between 0 and 7*/
+	int planar_symmetry_pass; /* the symmetry pass we are currently on between 0 and 7*/
 	float view_normal[3], view_normal_symmetry[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];
 	int last_rake[2]; /* Last location of updating rake rotation */
 	int original;
 
@@ -339,7 +340,7 @@
 
 	//float true_location[3];
 	//int symmetry;
-	//int symmetry_pass;
+	//int planar_symmetry_pass;
 } SculptBrushTest;
 
 static void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test)
@@ -349,7 +350,7 @@
 
 	//copy_v3_v3(test->true_location, ss->cache->true_location);
 	//test->symmetry = ss->cache->symmetry;
-	//test->symmetry_pass = ss->cache->symmetry_pass;
+	//test->planar_symmetry_pass = ss->cache->planar_symmetry_pass;
 }
 
 //static int sculpt_brush_test_clip(SculptBrushTest* test, float co[3])
@@ -358,7 +359,7 @@
 //		int i;
 //
 //		for (i = 0; i < 3; i++) {
-//			if (test->symmetry_pass & (1<<i)) {
+//			if (test->planar_symmetry_pass & (1<<i)) {
 //				if (test->true_location[i] >= 0) {
 //					if (co[i] >= 0) return 0;
 //				}
@@ -690,7 +691,7 @@
 		/* 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->symmetry_pass);
+		flip_coord(point_2d, point, ss->cache->planar_symmetry_pass);
 		projectf(ss->cache->mats, point_2d, point_2d);
 
 		/* if fixed mode, keep coordinates relative to mouse */
@@ -839,13 +840,11 @@
 {
 	Brush *brush = paint_brush(&sd->paint);
 
-	if (ss->cache->symmetry_pass == 0 &&
+	if (ss->cache->planar_symmetry_pass == 0 &&
+	    ss->cache->radial_symmetry_pass == 0 &&
 	   (ss->cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL)))
 	{
-		//int sculpt_plane = (brush->flag & BRUSH_ORIGINAL_NORMAL) ? brush->sculpt_plane : SCULPT_DISP_DIR_AREA;
-		int sculpt_plane = brush->sculpt_plane;
-
-		switch (sculpt_plane) {
+		switch (brush->sculpt_plane) {
 			case SCULPT_DISP_DIR_VIEW:
 				viewvector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
 				break;
@@ -941,10 +940,16 @@
 	}
 	else {
 		copy_v3_v3(an, ss->cache->last_area_normal);
-		flip_coord(an, an, ss->cache->symmetry_pass);
+		copy_v3_v3(ss->cache->view_normal_symmetry, ss->cache->last_view_normal_symmetry);
 
-		copy_v3_v3(ss->cache->view_normal_symmetry, ss->cache->last_view_normal_symmetry);
-		flip_coord(ss->cache->view_normal_symmetry, ss->cache->view_normal_symmetry, ss->cache->symmetry_pass);
+		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);
+		}
 	}
 }
 
@@ -1488,7 +1493,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->symmetry_pass];
+	float angle = ss->cache->vertex_rotation * flip[ss->cache->planar_symmetry_pass];
 
 	calc_area_normal(sd, ss, an, nodes, totnode);
 
@@ -1683,13 +1688,11 @@
 {
 	Brush *brush = paint_brush(&sd->paint);
 
-	if (ss->cache->symmetry_pass == 0 &&
+	if (ss->cache->planar_symmetry_pass == 0 &&
+	    ss->cache->radial_symmetry_pass == 0 &&
 	   (ss->cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL)))
 	{
-		//int sculpt_plane = (brush->flag & BRUSH_ORIGINAL_NORMAL) ? brush->sculpt_plane : SCULPT_DISP_DIR_AREA;
-		int sculpt_plane = brush->sculpt_plane;
-
-		switch (sculpt_plane) {
+		switch (brush->sculpt_plane) {
 			case SCULPT_DISP_DIR_VIEW:
 				viewvector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
 				break;
@@ -1809,7 +1812,7 @@
 
 		// fc
 		/* flatten center has not been calculated yet if we are not using the area normal */
-		if (sculpt_plane != SCULPT_DISP_DIR_AREA)
+		if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA)
 			calc_flatten_center(sd, ss, nodes, totnode, fc);
 
 		// an
@@ -1822,14 +1825,21 @@
 	else {
 		// an
 		copy_v3_v3(an, ss->cache->last_area_normal);
-		flip_coord(an, an, ss->cache->symmetry_pass);
-
 		copy_v3_v3(ss->cache->view_normal_symmetry, ss->cache->last_view_normal_symmetry);
-		flip_coord(ss->cache->view_normal_symmetry, ss->cache->view_normal_symmetry, ss->cache->symmetry_pass);
 
 		// fc
 		copy_v3_v3(fc, ss->cache->last_center);
-		flip_coord(fc, fc, ss->cache->symmetry_pass);
+
+		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);
+		}
 	}
 }
 
@@ -2431,6 +2441,27 @@
 	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';
+	else if (sd->flags & SCULPT_RADIAL_SYMM_Y)
+		axis = 'Y';
+	else if (sd->flats & SCULPT_RADIAL_SYMM_Z)
+		axis = 'Z';
+	else
+		return;
+
+	unit_m4(cache->symm_rot_mat);
+	rotate_m4(cache->symm_rot_mat, axis, angle);
+
+	mul_v3_m4v3(cache->location, cache->symm_rot_mat, cache->true_location);
+	mul_v3_m4v3(cache->view_normal_symmetry, cache->symm_rot_mat, cache->view_normal);
+	mul_v3_m4v3(cache->grab_delta_symmetry, cache->symm_rot_mat, cache->grab_delta);
+}
+
 static void do_symmetrical_brush_actions(Sculpt *sd, SculptSession *ss)
 {
 	Brush *brush = paint_brush(&sd->paint);
@@ -2441,15 +2472,27 @@
 	copy_v3_v3(cache->location, cache->true_location);
 	copy_v3_v3(cache->grab_delta_symmetry, cache->grab_delta);
 	cache->symmetry= symm;
-	cache->symmetry_pass= 0;
+	cache->planar_symmetry_pass= 0;
+	unit_m4(cache->symm_rot_mat);
+	cache->radial_symmetry_pass= 0;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list