[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56411] trunk/blender: Fix another part of #35141: there was no way to reset the stencil transform after e.g.

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Apr 30 12:32:03 CEST 2013


Revision: 56411
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56411
Author:   blendix
Date:     2013-04-30 10:32:02 +0000 (Tue, 30 Apr 2013)
Log Message:
-----------
Fix another part of #35141: there was no way to reset the stencil transform after e.g.
scaling it along one axis, now there's a Reset Transform button.

The Image Aspect button is now also hidden unless the texture is an image texture.
And also hide the color wheel for painting tools that don't use colors.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py
    trunk/blender/release/scripts/startup/bl_ui/space_image.py
    trunk/blender/source/blender/blenkernel/intern/brush.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py	2013-04-30 09:59:40 UTC (rev 56410)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_paint_common.py	2013-04-30 10:32:02 UTC (rev 56411)
@@ -84,7 +84,9 @@
         layout.separator()
 
     if tex_slot.map_mode == 'STENCIL':
-        layout.operator("brush.stencil_fit_image_aspect")
+        if brush.texture and brush.texture.type == 'IMAGE':
+            layout.operator("brush.stencil_fit_image_aspect")
+        layout.operator("brush.stencil_reset_transform")
 
     # angle and texture_angle_source
     col = layout.column()
@@ -127,7 +129,9 @@
     layout.separator()
 
     if mask_tex_slot.map_mode == 'STENCIL':
-        layout.operator("brush.stencil_fit_image_aspect").mask = True
+        if brush.mask_texture and brush.mask_texture.type == 'IMAGE':
+            layout.operator("brush.stencil_fit_image_aspect").mask = True
+        layout.operator("brush.stencil_reset_transform")
 
     if brush.mask_texture:
         layout.label(text="Mask Mapping:")

Modified: trunk/blender/release/scripts/startup/bl_ui/space_image.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_image.py	2013-04-30 09:59:40 UTC (rev 56410)
+++ trunk/blender/release/scripts/startup/bl_ui/space_image.py	2013-04-30 10:32:02 UTC (rev 56411)
@@ -696,9 +696,11 @@
 
         if brush:
             col = layout.column()
-            col.template_color_picker(brush, "color", value_slider=True)
-            col.prop(brush, "color", text="")
 
+            if brush.image_tool == 'DRAW' and brush.blend not in ('ERASE_ALPHA', 'ADD_ALPHA'):
+                col.template_color_picker(brush, "color", value_slider=True)
+                col.prop(brush, "color", text="")
+
             row = col.row(align=True)
             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
             self.prop_unified_size(row, context, brush, "use_pressure_size")

Modified: trunk/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/brush.c	2013-04-30 09:59:40 UTC (rev 56410)
+++ trunk/blender/source/blender/blenkernel/intern/brush.c	2013-04-30 10:32:02 UTC (rev 56411)
@@ -777,7 +777,7 @@
 	const int radius = BKE_brush_size_get(scene, brush);
 	unsigned char *dst, crgb[3];
 	const float alpha = (use_brush_alpha)? BKE_brush_alpha_get(scene, brush): 1.0f;
-	float brush_rgb[3];
+	float brush_rgb[3] = {1.0f, 1.0f, 1.0f};
 	int thread = 0;
 
 	imbflag = (flt) ? IB_rectfloat : IB_rect;
@@ -791,9 +791,11 @@
 		ibuf = IMB_allocImBuf(bufsize, bufsize, 32, imbflag);
 
 	if (flt) {
-		copy_v3_v3(brush_rgb, brush->rgb);
-		if (use_color_correction) {
-			srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb);
+		if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
+			copy_v3_v3(brush_rgb, brush->rgb);
+			if (use_color_correction) {
+				srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb);
+			}
 		}
 
 		for (y = 0; y < ibuf->y; y++) {
@@ -834,8 +836,12 @@
 	}
 	else {
 		float alpha_f; /* final float alpha to convert to char */
-		rgb_float_to_uchar(crgb, brush->rgb);
 
+		if (brush->imagepaint_tool == PAINT_TOOL_DRAW)
+			rgb_float_to_uchar(crgb, brush->rgb);
+		else
+			rgb_float_to_uchar(crgb, brush_rgb);
+
 		for (y = 0; y < ibuf->y; y++) {
 			dst = (unsigned char *)ibuf->rect + y * rowbytes;
 

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c	2013-04-30 09:59:40 UTC (rev 56410)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c	2013-04-30 10:32:02 UTC (rev 56411)
@@ -807,7 +807,7 @@
 {
 	/* identifiers */
 	ot->name = "Image Aspect";
-	ot->description = "Adjust the stencil size to fit image aspect ratio";
+	ot->description = "When using an image texture, adjust the stencil size to fit the image aspect ratio";
 	ot->idname = "BRUSH_OT_stencil_fit_image_aspect";
 
 	/* api callbacks */
@@ -823,6 +823,45 @@
 }
 
 
+static int stencil_reset_transform(bContext *C, wmOperator *UNUSED(op))
+{
+	Paint *paint = BKE_paint_get_active_from_context(C);
+	Brush *br = BKE_paint_brush(paint);
+
+	if (!br)
+		return OPERATOR_CANCELLED;
+
+	br->stencil_pos[0] = 256;
+	br->stencil_pos[1] = 256;
+
+	br->stencil_dimension[0] = 256;
+	br->stencil_dimension[1] = 256;
+
+	br->mtex.rot = 0;
+	br->mask_mtex.rot = 0;
+
+	WM_event_add_notifier(C, NC_WINDOW, NULL);
+
+	return OPERATOR_FINISHED;
+}
+
+
+static void BRUSH_OT_stencil_reset_transform(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Reset Transform";
+	ot->description = "Reset the stencil transformation to the default";
+	ot->idname = "BRUSH_OT_stencil_reset_transform";
+
+	/* api callbacks */
+	ot->exec = stencil_reset_transform;
+	ot->poll = stencil_control_poll;
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+
 static void ed_keymap_stencil(wmKeyMap *keymap)
 {
 	wmKeyMapItem *kmi;
@@ -856,6 +895,7 @@
 	WM_operatortype_append(BRUSH_OT_reset);
 	WM_operatortype_append(BRUSH_OT_stencil_control);
 	WM_operatortype_append(BRUSH_OT_stencil_fit_image_aspect);
+	WM_operatortype_append(BRUSH_OT_stencil_reset_transform);
 
 	/* note, particle uses a different system, can be added with existing operators in wm.py */
 	WM_operatortype_append(PAINT_OT_brush_select);




More information about the Bf-blender-cvs mailing list