[Bf-blender-cvs] [40a5629] soc-2013-paint: Paint Curves Transform:

Antony Riakiotakis noreply at git.blender.org
Sun Jul 20 13:10:43 CEST 2014


Commit: 40a562973b08f9e6ac704a9330181d40e667e992
Author: Antony Riakiotakis
Date:   Sun Jul 20 13:08:26 2014 +0200
Branches: soc-2013-paint
https://developer.blender.org/rB40a562973b08f9e6ac704a9330181d40e667e992

Paint Curves Transform:

* Cursor pivot working.
* Expose pivot in paint modes.

===================================================================

M	release/scripts/startup/bl_ui/space_image.py
M	source/blender/editors/space_view3d/view3d_header.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index bb911e4..b3ba3b6 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -420,8 +420,7 @@ class IMAGE_HT_header(Header):
             row = layout.row()
             row.template_ID(sima, "mask", new="mask.new")
 
-        if show_uvedit or show_maskedit:
-            layout.prop(sima, "pivot_point", icon_only=True)
+        layout.prop(sima, "pivot_point", icon_only=True)
 
         # uv editing
         if show_uvedit:
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 9bd0c8c..e4c3786 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -338,10 +338,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
 	uiItemR(layout, &v3dptr, "viewport_shade", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
 
 	if (obedit == NULL && is_paint) {
-		Paint *p = BKE_paint_get_active(scene);
-		Brush *br = BKE_paint_brush(p);
-
-		if ((ob->mode & OB_MODE_WEIGHT_PAINT) || (br && (br->flag & BRUSH_CURVE))) {
+		if (ob->mode & OB_MODE_ALL_PAINT) {
 			/* Only for Weight Paint. makes no sense in other paint modes. */
 			row = uiLayoutRow(layout, true);
 			uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 9288775..3e6e62a 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -100,6 +100,7 @@
 #include "WM_api.h"
 
 #include "UI_resources.h"
+#include "UI_view2d.h"
 
 #include "transform.h"
 
@@ -1559,6 +1560,13 @@ void calculateCenterCursor(TransInfo *t, float r_center[3])
 		invert_m3_m3(imat, mat);
 		mul_m3_v3(imat, r_center);
 	}
+	else if (t->options & CTX_PAINT_CURVE) {
+		if (ED_view3d_project_float_global(t->ar, cursor, r_center, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) {
+			r_center[0] = t->ar->winx / 2.0f;
+			r_center[1] = t->ar->winy / 2.0f;
+		}
+		r_center[2] = 0.0f;
+	}
 }
 
 void calculateCenterCursor2D(TransInfo *t, float r_center[2])
@@ -1606,6 +1614,12 @@ void calculateCenterCursor2D(TransInfo *t, float r_center[2])
 			r_center[0] = co[0] * aspx;
 			r_center[1] = co[1] * aspy;
 		}
+		else if (t->options & CTX_PAINT_CURVE) {
+			if (t->spacetype == SPACE_IMAGE) {
+				r_center[0] = UI_view2d_view_to_region_x(&t->ar->v2d, cursor[0]);
+				r_center[1] = UI_view2d_view_to_region_y(&t->ar->v2d, cursor[1]);
+			}
+		}
 		else {
 			r_center[0] = cursor[0] * aspx;
 			r_center[1] = cursor[1] * aspy;
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 06f63b1..653ba27 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -87,6 +87,18 @@ EnumPropertyItem space_type_items[] = {
 	{0, NULL, 0, NULL, NULL}
 };
 
+static EnumPropertyItem pivot_items_full[] = {
+	{V3D_CENTER, "BOUNDING_BOX_CENTER", ICON_ROTATE, "Bounding Box Center",
+				 "Pivot around bounding box center of selected object(s)"},
+	{V3D_CURSOR, "CURSOR", ICON_CURSOR, "3D Cursor", "Pivot around the 3D cursor"},
+	{V3D_LOCAL, "INDIVIDUAL_ORIGINS", ICON_ROTATECOLLECTION,
+				"Individual Origins", "Pivot around each object's own origin"},
+	{V3D_CENTROID, "MEDIAN_POINT", ICON_ROTATECENTER, "Median Point",
+				   "Pivot around the median point of selected objects"},
+	{V3D_ACTIVE, "ACTIVE_ELEMENT", ICON_ROTACTIVE, "Active Element", "Pivot around active object"},
+	{0, NULL, 0, NULL, NULL}
+};
+
 static EnumPropertyItem draw_channels_items[] = {
 	{SI_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha",
 	               "Draw image with RGB colors and alpha transparency"},
@@ -799,6 +811,24 @@ static void rna_SpaceImageEditor_scopes_update(Main *UNUSED(bmain), Scene *scene
 	ED_space_image_release_buffer(sima, ibuf, lock);
 }
 
+static EnumPropertyItem *rna_SpaceImageEditor_pivot_itemf(bContext *UNUSED(C), PointerRNA *ptr,
+												PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
+{
+	static EnumPropertyItem pivot_items[] = {
+		{V3D_CENTER, "CENTER", ICON_ROTATE, "Bounding Box Center", ""},
+		{V3D_CENTROID, "MEDIAN", ICON_ROTATECENTER, "Median Point", ""},
+		{V3D_CURSOR, "CURSOR", ICON_CURSOR, "2D Cursor", ""},
+		{0, NULL, 0, NULL, NULL}
+	};
+
+	SpaceImage *sima = (SpaceImage *)ptr->data;
+
+	if (sima->mode == SI_MODE_PAINT)
+		return pivot_items_full;
+	else
+		return pivot_items;
+}
+
 /* Space Text Editor */
 
 static void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, int value)
@@ -1753,18 +1783,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
 	StructRNA *srna;
 	PropertyRNA *prop;
 
-	static EnumPropertyItem pivot_items[] = {
-		{V3D_CENTER, "BOUNDING_BOX_CENTER", ICON_ROTATE, "Bounding Box Center",
-		             "Pivot around bounding box center of selected object(s)"},
-		{V3D_CURSOR, "CURSOR", ICON_CURSOR, "3D Cursor", "Pivot around the 3D cursor"},
-		{V3D_LOCAL, "INDIVIDUAL_ORIGINS", ICON_ROTATECOLLECTION,
-		            "Individual Origins", "Pivot around each object's own origin"},
-		{V3D_CENTROID, "MEDIAN_POINT", ICON_ROTATECENTER, "Median Point",
-		               "Pivot around the median point of selected objects"},
-		{V3D_ACTIVE, "ACTIVE_ELEMENT", ICON_ROTACTIVE, "Active Element", "Pivot around active object"},
-		{0, NULL, 0, NULL, NULL}
-	};
-
 	static EnumPropertyItem manipulators_items[] = {
 		{V3D_MANIP_TRANSLATE, "TRANSLATE", ICON_MAN_TRANS, "Manipulator Translate",
 		                      "Use the manipulator for movement transformations"},
@@ -2043,7 +2061,7 @@ static void rna_def_space_view3d(BlenderRNA *brna)
 
 	prop = RNA_def_property(srna, "pivot_point", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "around");
-	RNA_def_property_enum_items(prop, pivot_items);
+	RNA_def_property_enum_items(prop, pivot_items_full);
 	RNA_def_property_ui_text(prop, "Pivot Point", "Pivot center for rotation/scaling");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_pivot_update");
 	
@@ -2311,13 +2329,6 @@ static void rna_def_space_image(BlenderRNA *brna)
 		{0, NULL, 0, NULL, NULL}
 	};
 
-	static EnumPropertyItem pivot_items[] = {
-		{V3D_CENTER, "CENTER", ICON_ROTATE, "Bounding Box Center", ""},
-		{V3D_CENTROID, "MEDIAN", ICON_ROTATECENTER, "Median Point", ""},
-		{V3D_CURSOR, "CURSOR", ICON_CURSOR, "2D Cursor", ""},
-		{0, NULL, 0, NULL, NULL}
-	};
-
 	StructRNA *srna;
 	PropertyRNA *prop;
 
@@ -2405,7 +2416,8 @@ static void rna_def_space_image(BlenderRNA *brna)
 
 	prop = RNA_def_property(srna, "pivot_point", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "around");
-	RNA_def_property_enum_items(prop, pivot_items);
+	RNA_def_property_enum_items(prop, pivot_items_full);
+	RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_SpaceImageEditor_pivot_itemf");
 	RNA_def_property_ui_text(prop, "Pivot", "Rotation/Scaling Pivot");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);




More information about the Bf-blender-cvs mailing list