[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60682] trunk/blender/source/blender/ editors/sculpt_paint/paint_image.c: Fix #36905: backport of fix in soc-2013-paint.

Antony Riakiotakis kalast at gmail.com
Fri Oct 11 04:23:21 CEST 2013


Revision: 60682
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60682
Author:   psy-fi
Date:     2013-10-11 02:23:20 +0000 (Fri, 11 Oct 2013)
Log Message:
-----------
Fix #36905: backport of fix in soc-2013-paint. This commit ensures that during color sampling the cursor of the current brush is disabled. This avoids sampling of the brush cursor for really small brushes. Only caveat is that if operator exec is called then cursor might be visible in new sample location. This is not so common though.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-10-11 00:22:00 UTC (rev 60681)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-10-11 02:23:20 UTC (rev 60682)
@@ -926,9 +926,15 @@
 }
 
 /******************** sample color operator ********************/
+typedef struct {
+	bool show_cursor;
+	short event_type;
+} SampleColorData;
+
 static int sample_color_exec(bContext *C, wmOperator *op)
 {
-	Brush *brush = image_paint_brush(C);
+	Paint *paint = BKE_paint_get_active_from_context(C);
+	Brush *brush = BKE_paint_brush(paint);
 	ARegion *ar = CTX_wm_region(C);
 	int location[2];
 
@@ -942,11 +948,17 @@
 
 static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
+	Paint *paint = BKE_paint_get_active_from_context(C);
+	SampleColorData *data = MEM_mallocN(sizeof(SampleColorData), "sample color custom data");
+
+	data->event_type = event->type;
+	data->show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0);
+	op->customdata = data;
+	paint->flags &= ~PAINT_SHOW_BRUSH;
+
 	RNA_int_set_array(op->ptr, "location", event->mval);
 	sample_color_exec(C, op);
 
-	op->customdata = SET_INT_IN_POINTER(event->type);
-
 	WM_event_add_modal_handler(C, op);
 
 	return OPERATOR_RUNNING_MODAL;
@@ -954,8 +966,18 @@
 
 static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
 {
-	if (event->type == (intptr_t)(op->customdata) && event->val == KM_RELEASE)
+	SampleColorData *data = op->customdata;
+
+	if ((event->type == data->event_type) && (event->val == KM_RELEASE)) {
+		Paint *paint = BKE_paint_get_active_from_context(C);
+
+		if(data->show_cursor) {
+			paint->flags |= PAINT_SHOW_BRUSH;
+		}
+
+		MEM_freeN(data);
 		return OPERATOR_FINISHED;
+	}
 
 	switch (event->type) {
 		case MOUSEMOVE:




More information about the Bf-blender-cvs mailing list