[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58350] branches/soc-2013-paint: Fix vertex painting not having palettes and colour sample operator (S)

Antony Riakiotakis kalast at gmail.com
Wed Jul 17 20:19:53 CEST 2013


Revision: 58350
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58350
Author:   psy-fi
Date:     2013-07-17 18:19:52 +0000 (Wed, 17 Jul 2013)
Log Message:
-----------
Fix vertex painting not having palettes and colour sample operator (S)

Modified Paths:
--------------
    branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_ops.c
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_utils.c

Modified: branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2013-07-17 17:53:36 UTC (rev 58349)
+++ branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2013-07-17 18:19:52 UTC (rev 58350)
@@ -748,6 +748,8 @@
             col.template_color_picker(brush, "color", value_slider=True)
             col.prop(brush, "color", text="")
             col.template_ID(settings, "palette", new="palette.new")
+            if settings.palette:
+                col.template_palette(settings, "palette", color=True)      
 
             row = col.row(align=True)
             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c	2013-07-17 17:53:36 UTC (rev 58349)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c	2013-07-17 18:19:52 UTC (rev 58350)
@@ -1033,11 +1033,11 @@
 static int sample_color_exec(bContext *C, wmOperator *op)
 {
 	Brush *brush = image_paint_brush(C);
+	PaintMode mode = BKE_paintmode_get_active_from_context(C);
 	ARegion *ar = CTX_wm_region(C);
 	int location[2];
-	bool foreground = RNA_boolean_get(op->ptr, "foreground");
 	RNA_int_get_array(op->ptr, "location", location);
-	paint_sample_color(C, ar, location[0], location[1], foreground);
+	paint_sample_color(C, ar, location[0], location[1], mode == PAINT_TEXTURE_PROJECTIVE);
 
 	WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
 
@@ -1085,6 +1085,11 @@
 	return OPERATOR_RUNNING_MODAL;
 }
 
+static int sample_color_poll(bContext *C)
+{
+	return image_paint_poll(C) || vertex_paint_poll(C);
+}
+
 void PAINT_OT_sample_color(wmOperatorType *ot)
 {
 	/* identifiers */
@@ -1096,14 +1101,13 @@
 	ot->exec = sample_color_exec;
 	ot->invoke = sample_color_invoke;
 	ot->modal = sample_color_modal;
-	ot->poll = image_paint_poll;
+	ot->poll = sample_color_poll;
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
 	/* properties */
 	RNA_def_int_vector(ot->srna, "location", 2, NULL, 0, INT_MAX, "Location", "Cursor location in region coordinates", 0, 16384);
-	RNA_def_boolean(ot->srna, "foreground", true, "Foreground", "Sample for the foreground color");
 }
 
 /******************** texture paint toggle operator ********************/

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h	2013-07-17 17:53:36 UTC (rev 58349)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h	2013-07-17 18:19:52 UTC (rev 58350)
@@ -208,7 +208,7 @@
 void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);
 void brush_drawcursor_texpaint_uvsculpt(struct bContext *C, int x, int y, void *customdata);
 
-void paint_sample_color(bContext *C, struct ARegion *ar, int x, int y, bool foreground);
+void paint_sample_color(bContext *C, struct ARegion *ar, int x, int y, bool texpaint_proj);
 void BRUSH_OT_curve_preset(struct wmOperatorType *ot);
 
 void PAINT_OT_face_select_linked(struct wmOperatorType *ot);

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_ops.c	2013-07-17 17:53:36 UTC (rev 58349)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_ops.c	2013-07-17 18:19:52 UTC (rev 58350)
@@ -1007,6 +1007,7 @@
 	/* palette */
 	WM_operatortype_append(PALETTE_OT_new);
 	WM_operatortype_append(PALETTE_OT_color_add);
+
 	/* brush */
 	WM_operatortype_append(BRUSH_OT_add);
 	WM_operatortype_append(BRUSH_OT_scale_size);

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_utils.c	2013-07-17 17:53:36 UTC (rev 58349)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_utils.c	2013-07-17 18:19:52 UTC (rev 58350)
@@ -369,7 +369,7 @@
 }
 
 /* used for both 3d view and image window */
-void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool foreground)    /* frontbuf */
+void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_proj)    /* frontbuf */
 {
 	Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));
 	unsigned int col;
@@ -378,7 +378,7 @@
 	CLAMP(x, 0, ar->winx);
 	CLAMP(y, 0, ar->winy);
 	
-	if (CTX_wm_view3d(C)) {
+	if (CTX_wm_view3d(C) && texpaint_proj) {
 		/* first try getting a colour directly from the mesh faces if possible */
 		Scene *scene = CTX_data_scene(C);
 		Object *ob = OBACT;
@@ -453,16 +453,9 @@
 	cp = (char *)&col;
 	
 	if (br) {
-		if (foreground) {
-			br->rgb[0] = cp[0] / 255.0f;
-			br->rgb[1] = cp[1] / 255.0f;
-			br->rgb[2] = cp[2] / 255.0f;
-		}
-		else {
-			br->secondary_rgb[0] = cp[0] / 255.0f;
-			br->secondary_rgb[1] = cp[1] / 255.0f;
-			br->secondary_rgb[2] = cp[2] / 255.0f;
-		}
+		br->rgb[0] = cp[0] / 255.0f;
+		br->rgb[1] = cp[1] / 255.0f;
+		br->rgb[2] = cp[2] / 255.0f;
 	}
 }
 




More information about the Bf-blender-cvs mailing list