[Bf-blender-cvs] [0034765] master: Project Paint: add sample merged option

Campbell Barton noreply at git.blender.org
Thu Feb 4 05:35:48 CET 2016


Commit: 0034765208f7b22077fdd75395eb5ebb2aeb8629
Author: Campbell Barton
Date:   Thu Feb 4 15:26:07 2016 +1100
Branches: master
https://developer.blender.org/rB0034765208f7b22077fdd75395eb5ebb2aeb8629

Project Paint: add sample merged option

This picks the on-screen color instead of using the active layers texture color.

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

M	source/blender/editors/sculpt_paint/paint_image.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 7f1a421..377ba3d 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -1199,9 +1199,8 @@ static int sample_color_exec(bContext *C, wmOperator *op)
 	PaintMode mode = BKE_paintmode_get_active_from_context(C);
 	ARegion *ar = CTX_wm_region(C);
 	wmWindow *win = CTX_wm_window(C);
-	bool show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0);
+	const bool show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0);
 	int location[2];
-	bool use_palette;
 	paint->flags &= ~PAINT_SHOW_BRUSH;
 
 	/* force redraw without cursor */
@@ -1209,9 +1208,10 @@ static int sample_color_exec(bContext *C, wmOperator *op)
 	WM_redraw_windows(C);
 
 	RNA_int_get_array(op->ptr, "location", location);
-	use_palette = RNA_boolean_get(op->ptr, "palette");
+	const bool use_palette = RNA_boolean_get(op->ptr, "palette");
+	const bool use_sample_texture = (mode == ePaintTextureProjective) && !RNA_boolean_get(op->ptr, "merged");
 
-	paint_sample_color(C, ar, location[0], location[1], mode == ePaintTextureProjective, use_palette);
+	paint_sample_color(C, ar, location[0], location[1], use_sample_texture, use_palette);
 
 	if (show_cursor) {
 		paint->flags |= PAINT_SHOW_BRUSH;
@@ -1263,7 +1263,6 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
 	SampleColorData *data = op->customdata;
 	Paint *paint = BKE_paint_get_active_from_context(C);
 	Brush *brush = BKE_paint_brush(paint);
-	PaintMode mode = BKE_paintmode_get_active_from_context(C);
 
 	if ((event->type == data->event_type) && (event->val == KM_RELEASE)) {
 		ScrArea *sa = CTX_wm_area(C);
@@ -1283,12 +1282,15 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
 		return OPERATOR_FINISHED;
 	}
 
+	PaintMode mode = BKE_paintmode_get_active_from_context(C);
+	const bool use_sample_texture = (mode == ePaintTextureProjective) && !RNA_boolean_get(op->ptr, "merged");
+
 	switch (event->type) {
 		case MOUSEMOVE:
 		{
 			ARegion *ar = CTX_wm_region(C);
 			RNA_int_set_array(op->ptr, "location", event->mval);
-			paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == ePaintTextureProjective, false);
+			paint_sample_color(C, ar, event->mval[0], event->mval[1], use_sample_texture, false);
 			WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
 			break;
 		}
@@ -1297,7 +1299,7 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
 			if (event->val == KM_PRESS) {
 				ARegion *ar = CTX_wm_region(C);
 				RNA_int_set_array(op->ptr, "location", event->mval);
-				paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == ePaintTextureProjective, true);
+				paint_sample_color(C, ar, event->mval[0], event->mval[1], use_sample_texture, true);
 				if (!data->sample_palette) {
 					data->sample_palette = true;
 					sample_color_update_header(data, C);
@@ -1332,8 +1334,13 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
 	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, "palette", 0, "Palette", "Add color to palette");
+	PropertyRNA *prop;
+
+	prop = RNA_def_int_vector(ot->srna, "location", 2, NULL, 0, INT_MAX, "Location", "", 0, 16384);
+	RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
+
+	RNA_def_boolean(ot->srna, "merged", 0, "Sample Merged", "Sample the output display color");
+	RNA_def_boolean(ot->srna, "palette", 0, "Add to Palette", "");
 }
 
 /******************** texture paint toggle operator ********************/




More information about the Bf-blender-cvs mailing list