[Bf-blender-cvs] [833a2855fe3] greasepencil-object: Merge branch 'blender2.8' into greasepencil-object

Campbell Barton noreply at git.blender.org
Tue Oct 17 07:15:21 CEST 2017


Commit: 833a2855fe3a4ed80576811bd0b568c90d0400b9
Author: Campbell Barton
Date:   Tue Oct 17 16:17:46 2017 +1100
Branches: greasepencil-object
https://developer.blender.org/rB833a2855fe3a4ed80576811bd0b568c90d0400b9

Merge branch 'blender2.8' into greasepencil-object

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



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

diff --cc source/blender/editors/object/object_edit.c
index 5318d9ac195,879bbe6a714..2ccb71811c7
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@@ -1555,49 -1551,25 +1555,49 @@@ static int object_mode_set_exec(bContex
  {
  	Object *ob = CTX_data_active_object(C);
  	bGPdata *gpd = CTX_data_gpencil_data(C);
- 	ObjectMode mode = RNA_enum_get(op->ptr, "mode");
- 	ObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT;
+ 	eObjectMode mode = RNA_enum_get(op->ptr, "mode");
+ 	eObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT;
  	const bool toggle = RNA_boolean_get(op->ptr, "toggle");
 -	
 -	if (gpd) {
 -		/* GP Mode is not bound to a specific object. Therefore,
 -		 * we don't want it to be actually saved on any objects,
 -		 * as weirdness can happen if you select other objects,
 -		 * or load old files.
 -		 *
 -		 * Instead, we use the following 2 rules to ensure that
 -		 * the mode selector works as expected:
 -		 *  1) If there's no object, we want to enter editmode.
 -		 *     (i.e. with no object, we're in object mode)
 -		 *  2) Otherwise, exit stroke editmode, so that we can
 -		 *     enter another mode...
 -		 */
 -		if (!ob || (gpd->flag & GP_DATA_STROKE_EDITMODE)) {
 -			WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +
 +	/* if type is OB_GPENCIL, select mode for grease pencil strokes */	
 +	if ((ob) && (ob->type == OB_GPENCIL)) {
 +		if ((ob->gpd) && (ob->gpd == gpd)) {
 +			if (ELEM(mode, OB_MODE_OBJECT, OB_MODE_EDIT, OB_MODE_POSE)) {
 +				ob->restore_mode = OB_MODE_OBJECT;
 +				if (ELEM(ob->mode, OB_MODE_OBJECT, OB_MODE_EDIT, OB_MODE_GPENCIL_EDIT)) {
 +					WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				}
 +				if (ob->mode == OB_MODE_GPENCIL_PAINT) {
 +					WM_operator_name_call(C, "GPENCIL_OT_paintmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				}
 +				if (ob->mode == OB_MODE_GPENCIL_SCULPT) {
 +					WM_operator_name_call(C, "GPENCIL_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				}
 +				if (ob->mode == OB_MODE_GPENCIL_WEIGHT) {
 +					WM_operator_name_call(C, "GPENCIL_OT_weightmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				}
 +				return OPERATOR_FINISHED;
 +			}
 +			if (mode == OB_MODE_GPENCIL_EDIT) {
 +				ob->restore_mode = ob->mode;
 +				WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				return OPERATOR_FINISHED;
 +			}
 +			if (mode == OB_MODE_GPENCIL_PAINT) {
 +				ob->restore_mode = ob->mode;
 +				WM_operator_name_call(C, "GPENCIL_OT_paintmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				return OPERATOR_FINISHED;
 +			}
 +			if (mode == OB_MODE_GPENCIL_SCULPT) {
 +				ob->restore_mode = ob->mode;
 +				WM_operator_name_call(C, "GPENCIL_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				return OPERATOR_FINISHED;
 +			}
 +			if (mode == OB_MODE_GPENCIL_WEIGHT) {
 +				ob->restore_mode = ob->mode;
 +				WM_operator_name_call(C, "GPENCIL_OT_weightmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 +				return OPERATOR_FINISHED;
 +			}
  		}
  	}
  	
diff --cc source/blender/editors/sculpt_paint/paint_ops.c
index 7a30901cda6,d3dcf283052..dbedf7909fc
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@@ -322,22 -202,13 +322,22 @@@ static int palette_color_add_exec(bCont
  	color = BKE_palette_color_add(palette);
  	palette->active_color = BLI_listbase_count(&palette->colors) - 1;
  
 -	if (ELEM(mode, ePaintTextureProjective, ePaintTexture2D, ePaintVertex)) {
 -		copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush));
 -		color->value = 0.0;
 -	}
 -	else if (mode == ePaintWeight) {
 -		zero_v3(color->rgb);
 -		color->value = brush->weight;
 +	/* For Grease Pencil, the active palette won't be the one the current
 +	 * Paint context stores (as it comes from the active Palette Slot on the
 +	 * current GP Object instead)
 +	 */
 +	if (palette != paint->palette) {
- 		PaintMode mode = BKE_paintmode_get_active_from_context(C);
++		ePaintMode mode = BKE_paintmode_get_active_from_context(C);
 +		Brush *brush = paint->brush;
 +		
 +		if (ELEM(mode, ePaintTextureProjective, ePaintTexture2D, ePaintVertex)) {
 +			copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush));
 +			color->value = 0.0;
 +		}
 +		else if (mode == ePaintWeight) {
 +			zero_v3(color->rgb);
 +			color->value = brush->weight;
 +		}
  	}
  
  	return OPERATOR_FINISHED;
diff --cc source/blender/makesdna/DNA_object_types.h
index 68811c7b5c2,ea3af3834b4..c7f36a328f8
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@@ -725,11 -717,8 +725,11 @@@ typedef enum eObjectMode 
  	OB_MODE_TEXTURE_PAINT = 1 << 4,
  	OB_MODE_PARTICLE_EDIT = 1 << 5,
  	OB_MODE_POSE          = 1 << 6,
 -	OB_MODE_GPENCIL       = 1 << 7,  /* NOTE: Just a dummy to make the UI nicer */
 +	OB_MODE_GPENCIL_EDIT  = 1 << 7,
 +	OB_MODE_GPENCIL_PAINT = 1 << 8,
 +	OB_MODE_GPENCIL_SCULPT = 1 << 9,
 +	OB_MODE_GPENCIL_WEIGHT = 1 << 10,
- } ObjectMode;
+ } eObjectMode;
  
  /* any mode where the brush system is used */
  #define OB_MODE_ALL_PAINT (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)



More information about the Bf-blender-cvs mailing list