[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46978] branches/soc-2012-bratwurst: Reuse UVCALC_TRANSFORM_CORRECT as Campbell suggested.

Antony Riakiotakis kalast at gmail.com
Thu May 24 18:21:16 CEST 2012


Revision: 46978
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46978
Author:   psy-fi
Date:     2012-05-24 16:21:15 +0000 (Thu, 24 May 2012)
Log Message:
-----------
Reuse UVCALC_TRANSFORM_CORRECT as Campbell suggested. I have enabled it
default for now to test with all transforms when ready and will probably
disable for certain transformations later. This resolves #29771.
Also fixed evil crasher due to index variable strolling out of bounds.

Modified Paths:
--------------
    branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    branches/soc-2012-bratwurst/source/blender/editors/transform/transform_conversions.c
    branches/soc-2012-bratwurst/source/blender/editors/transform/transform_generics.c
    branches/soc-2012-bratwurst/source/blender/editors/transform/transform_ops.c
    branches/soc-2012-bratwurst/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2012-bratwurst/source/blender/makesrna/intern/rna_scene.c

Modified: branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2012-05-24 15:29:50 UTC (rev 46977)
+++ branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2012-05-24 16:21:15 UTC (rev 46978)
@@ -207,7 +207,7 @@
         col.label("Edge Select Mode:")
         col.prop(tool_settings, "edge_path_mode", text="")
         col.prop(tool_settings, "edge_path_live_unwrap")
-        col.prop(tool_settings, "retain_image_pos")
+        col.prop(tool_settings, "correct_uv")
 
         col.label("Double Threshold:")
         col.prop(tool_settings, "double_threshold", text="")

Modified: branches/soc-2012-bratwurst/source/blender/editors/transform/transform_conversions.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/transform/transform_conversions.c	2012-05-24 15:29:50 UTC (rev 46977)
+++ branches/soc-2012-bratwurst/source/blender/editors/transform/transform_conversions.c	2012-05-24 16:21:15 UTC (rev 46978)
@@ -1945,7 +1945,7 @@
 	float *mappedcos = NULL, *quats= NULL;
 	float mtx[3][3], smtx[3][3], (*defmats)[3][3] = NULL, (*defcos)[3] = NULL;
 	float *dists=NULL;
-	int count=0, countsel=0, a, totleft;
+	int count=0, countsel=0, a, i, totleft;
 	int propmode = (t->flag & T_PROP_EDIT) ? (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) : 0;
 	int mirror = 0;
 	char *selstate = NULL;
@@ -2097,7 +2097,7 @@
 	}
 
 	eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
-	for (a=0; eve; eve=BM_iter_step(&iter), a++) {
+	for (a=0, i=0; eve; eve=BM_iter_step(&iter), a++) {
 		if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
 			if (propmode || selstate[a]) {
 				float *bweight = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_BWEIGHT);
@@ -2107,7 +2107,7 @@
 					tx++;
 
 				if(t->flag & T_IMAGE_PRESERVE_CALC)
-					t->affected_verts[a] = eve;
+					t->affected_verts[i] = eve;
 
 				/* selected */
 				if (selstate[a]) tob->flag |= TD_SELECTED;
@@ -2160,6 +2160,7 @@
 					}
 				}
 				tob++;
+				i++;
 			}
 		}
 	}

Modified: branches/soc-2012-bratwurst/source/blender/editors/transform/transform_generics.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/transform/transform_generics.c	2012-05-24 15:29:50 UTC (rev 46977)
+++ branches/soc-2012-bratwurst/source/blender/editors/transform/transform_generics.c	2012-05-24 16:21:15 UTC (rev 46978)
@@ -1049,7 +1049,7 @@
 			v3d->twtype = 0;
 		}
 
-		if(ts->retain_image_pos)
+		if(ts->uvcalc_flag & UVCALC_TRANSFORM_CORRECT)
 			t->flag |= T_IMAGE_PRESERVE_CALC;
 
 		if (v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN;
@@ -1089,8 +1089,8 @@
 				RNA_boolean_set(op->ptr, "correct_uv", t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT);
 			}
 		}
+	}
 
-	}
 	else if (t->spacetype==SPACE_IMAGE) {
 		SpaceImage *sima = sa->spacedata.first;
 		// XXX for now, get View2D from the active region
@@ -1269,8 +1269,10 @@
 			v3d->twtype = t->twtype;
 		}
 		if(t->flag & T_IMAGE_PRESERVE_CALC) {
-			if(t->affected_verts)
+			if(t->affected_verts) {
 				MEM_freeN(t->affected_verts);
+				t->affected_verts = NULL;
+			}
 		}
 	}
 	

Modified: branches/soc-2012-bratwurst/source/blender/editors/transform/transform_ops.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/transform/transform_ops.c	2012-05-24 15:29:50 UTC (rev 46977)
+++ branches/soc-2012-bratwurst/source/blender/editors/transform/transform_ops.c	2012-05-24 16:21:15 UTC (rev 46978)
@@ -498,13 +498,11 @@
 		RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space");
 	}
 
-	if (flags & P_CORRECT_UV) {
-		RNA_def_boolean(ot->srna, "correct_uv", 0, "Correct UVs", "Correct UV coordinates when transforming");
-	}
 
 	// Add confirm method all the time. At the end because it's not really that important and should be hidden only in log, not in keymap edit
 	/*prop =*/ RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button");
 	//RNA_def_property_flag(prop, PROP_HIDDEN);
+	RNA_def_boolean(ot->srna, "correct_uv", 0, "Correct UVs", "Correct UV coordinates when transforming");
 }
 
 static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
@@ -778,7 +776,7 @@
 
 	RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
 
-	Transform_Properties(ot, P_MIRROR|P_SNAP|P_CORRECT_UV);
+	Transform_Properties(ot, P_MIRROR|P_SNAP);
 }
 
 static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot)

Modified: branches/soc-2012-bratwurst/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/makesdna/DNA_scene_types.h	2012-05-24 15:29:50 UTC (rev 46977)
+++ branches/soc-2012-bratwurst/source/blender/makesdna/DNA_scene_types.h	2012-05-24 16:21:15 UTC (rev 46978)
@@ -998,8 +998,7 @@
 	short snap_flag, snap_target;
 	short proportional, prop_mode;
 	char proportional_objects; /* proportional edit, object mode */
-	char retain_image_pos;
-	char pad[4];
+	char pad[5];
 
 	char auto_normalize; /*auto normalizing mode in wpaint*/
 	char multipaint; /* paint multiple bones in wpaint */

Modified: branches/soc-2012-bratwurst/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/makesrna/intern/rna_scene.c	2012-05-24 15:29:50 UTC (rev 46977)
+++ branches/soc-2012-bratwurst/source/blender/makesrna/intern/rna_scene.c	2012-05-24 16:21:15 UTC (rev 46978)
@@ -1636,9 +1636,9 @@
 	RNA_def_property_ui_icon(prop, ICON_ORTHO, 0);
 	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
 
-	prop= RNA_def_property(srna, "retain_image_pos", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "retain_image_pos", 1);
-	RNA_def_property_ui_text(prop, "Retain Image", "Retain image position when transforming a vertex");
+	prop= RNA_def_property(srna, "correct_uv", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "uvcalc_flag", UVCALC_TRANSFORM_CORRECT);
+	RNA_def_property_ui_text(prop, "Correct UVs", "Correct UV coordinates when transforming");
 
 	/* Grease Pencil */
 	prop = RNA_def_property(srna, "use_grease_pencil_sessions", PROP_BOOLEAN, PROP_NONE);




More information about the Bf-blender-cvs mailing list