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

Antonio Vazquez noreply at git.blender.org
Tue Feb 6 16:30:12 CET 2018


Commit: c1401c7966bd00b6be80bf885a4244a4cac8ebfc
Author: Antonio Vazquez
Date:   Tue Feb 6 16:18:59 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBc1401c7966bd00b6be80bf885a4244a4cac8ebfc

Merge branch 'blender2.8' into greasepencil-object

 Conflicts:
	source/blender/editors/object/object_modifier.c
	source/blender/editors/space_outliner/outliner_tree.c
	source/blender/makesdna/DNA_object_types.h

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



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

diff --cc source/blender/blenkernel/BKE_object.h
index 2e9cdba667c,7ee70b12c91..76c48af1866
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@@ -50,8 -49,9 +50,10 @@@ struct Main
  struct RigidBodyWorld;
  struct HookModifierData;
  struct ModifierData;
 +struct GpencilHookModifierData;
  
+ #include "DNA_object_enums.h"
+ 
  void BKE_object_workob_clear(struct Object *workob);
  void BKE_object_workob_calc_parent(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct Object *workob);
  
diff --cc source/blender/blenkernel/intern/paint.c
index 261fe64746d,5ba4face835..91e725e543f
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@@ -599,59 -461,9 +609,59 @@@ bool BKE_palette_is_empty(const struct 
  	return BLI_listbase_is_empty(&palette->colors);
  }
  
 +/* get the palettecolor looking by name */
 +PaletteColor *BKE_palette_color_getbyname(Palette *palette, char *name)
 +{
 +	/* error checking */
 +	if (ELEM(NULL, palette, name)) {
 +		return NULL;
 +	}
 +
 +	return BLI_findstring(&palette->colors, name, offsetof(PaletteColor, info));
 +}
 +
 +/* get the palettecolor looking by rgb */
 +PaletteColor *BKE_gpencil_palettecolor_getbyrgb(Palette *palette, float rgb[3])
 +{
 +	PaletteColor *palcolor;
 +
 +	/* error checking */
 +	if (ELEM(NULL, palette, palette->colors.first)) {
 +		return NULL;
 +	}
 +	/* loop over colors until found */
 +	for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
 +		if (equals_v3v3(palcolor->rgb, rgb)) {
 +			return palcolor;
 +		}
 +	}
 +
 +	/* no active color found */
 +	return NULL;
 +}
 +
 +/* get the palettecolor looking by rgba */
 +PaletteColor *BKE_gpencil_palettecolor_getbyrgba(Palette *palette, float rgba[4])
 +{
 +	PaletteColor *palcolor;
 +
 +	/* error checking */
 +	if (ELEM(NULL, palette, palette->colors.first)) {
 +		return NULL;
 +	}
 +	/* loop over colors until found */
 +	for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
 +		if (equals_v4v4(palcolor->rgb, rgba)) {
 +			return palcolor;
 +		}
 +	}
 +
 +	/* no active color found */
 +	return NULL;
 +}
  
  /* are we in vertex paint or weight pain face select mode? */
- bool BKE_paint_select_face_test(Object *ob)
+ bool BKE_paint_select_face_test(const EvaluationContext *eval_ctx, Object *ob)
  {
  	return ( (ob != NULL) &&
  	         (ob->type == OB_MESH) &&
diff --cc source/blender/editors/sculpt_paint/paint_ops.c
index 018f74b1fb0,214b260250d..6ea51b32569
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@@ -40,10 -38,10 +40,12 @@@
  #include "BKE_brush.h"
  #include "BKE_context.h"
  #include "BKE_paint.h"
 +#include "BKE_gpencil.h"
  #include "BKE_main.h"
 +#include "BKE_report.h"
  
+ #include "DEG_depsgraph.h"
+ 
  #include "ED_paint.h"
  #include "ED_screen.h"
  #include "ED_image.h"
@@@ -396,467 -261,10 +398,469 @@@ static void PALETTE_OT_color_delete(wmO
  	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
  }
  
 +/* ********************** Isolate palette color **************************** */
 +
 +static int palettecolor_isolate_exec(bContext *C, wmOperator *op)
 +{
 +	Main *bmain = CTX_data_main(C);
 +	bGPdata *gpd = ED_gpencil_data_get_active(C);
 +	Palette *palette = BKE_palette_get_active_from_context(C);
 +
 +	PaletteColor *active_color = BKE_palette_color_get_active(palette);
 +	PaletteColor *palcolor;
 +
 +	int flags = PC_COLOR_LOCKED;
 +	bool isolate = false;
 +
 +	if (RNA_boolean_get(op->ptr, "affect_visibility"))
 +		flags |= PC_COLOR_HIDE;
 +
 +	if (ELEM(NULL, gpd, active_color)) {
 +		BKE_report(op->reports, RPT_ERROR, "No active color to isolate");
 +		return OPERATOR_CANCELLED;
 +	}
 +
 +	/* Test whether to isolate or clear all flags */
 +	for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
 +		/* Skip if this is the active one */
 +		if (palcolor == active_color)
 +			continue;
 +
 +		/* If the flags aren't set, that means that the color is
 +		* not alone, so we have some colors to isolate still
 +		*/
 +		if ((palcolor->flag & flags) == 0) {
 +			isolate = true;
 +			break;
 +		}
 +	}
 +
 +	/* Set/Clear flags as appropriate */
 +	if (isolate) {
 +		/* Set flags on all "other" colors */
 +		for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
 +			if (palcolor == active_color)
 +				continue;
 +			else
 +				palcolor->flag |= flags;
 +		}
 +	}
 +	else {
 +		/* Clear flags - Restore everything else */
 +		for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
 +			palcolor->flag &= ~flags;
 +		}
 +	}
 +
 +	/* notifiers */
 +	BKE_gpencil_batch_cache_alldirty_main(bmain);
 +	WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 +
 +	return OPERATOR_FINISHED;
 +}
 +
 +static void PALETTE_OT_palettecolor_isolate(wmOperatorType *ot)
 +{
 +	/* identifiers */
 +	ot->name = "Isolate Palette Color";
 +	ot->idname = "PALETTE_OT_palettecolor_isolate";
 +	ot->description = "Toggle whether the active color is the only one that is editable and/or visible";
 +
 +	/* callbacks */
 +	ot->exec = palettecolor_isolate_exec;
 +	ot->poll = palettecolor_active_poll;
 +
 +	/* flags */
 +	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 +
 +	/* properties */
 +	RNA_def_boolean(ot->srna, "affect_visibility", false, "Affect Visibility", "In addition to toggling "
 +		"the editability, also affect the visibility");
 +}
 +
 +/* *********************** Hide Palette colors ******************************** */
 +
 +static int palettecolor_hide_exec(bContext *C, wmOperator *op)
 +{
 +	Palette *palette = BKE_palette_get_active_from_context(C);
 +	PaletteColor *palcolor = BKE_palette_color_get_active(palette);
 +
 +	bool unselected = RNA_boolean_get(op->ptr, "unselected");
 +
 +	/* sanity checks */
 +	if (ELEM(NULL, palette, palcolor))
 +		return OPERATOR_CANCELLED;
 +
 +	if (unselected) {
 +		PaletteColor *color;
 +
 +		/* hide unselected */
 +		for (color = palette->colors.first; color; color = color->next) {
 +			if (color != palcolor) {
 +				color->flag |= PC_COLOR_HIDE;
 +			}
 +		}
 +	}
 +	else {
 +		/* hide selected/active */
 +		palcolor->flag |= PC_COLOR_HIDE;
 +	}
 +
 +	/* notifiers */
 +	WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 +
 +	return OPERATOR_FINISHED;
 +}
 +
 +static void PALETTE_OT_palettecolor_hide(wmOperatorType *ot)
 +{
 +	/* identifiers */
 +	ot->name = "Hide Color(s)";
 +	ot->idname = "PALETTE_OT_palettecolor_hide";
 +	ot->description = "Hide selected/unselected Grease Pencil colors";
 +
 +	/* callbacks */
 +	ot->exec = palettecolor_hide_exec;
 +	ot->poll = palettecolor_active_poll; /* NOTE: we need an active color to play with */
 +
 +											/* flags */
 +	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 +
 +	/* props */
 +	RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected colors");
 +}
 +
 +/* ********************** Show All Colors ***************************** */
 +
 +static int palettecolor_reveal_exec(bContext *C, wmOperator *UNUSED(op))
 +{
 +	Palette *palette = BKE_palette_get_active_from_context(C);
 +	PaletteColor *palcolor;
 +
 +	/* sanity checks */
 +	if (ELEM(NULL, palette))
 +		return OPERATOR_CANCELLED;
 +
 +	/* make all colors visible */
 +	for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
 +		palcolor->flag &= ~PC_COLOR_HIDE;
 +	}
 +
 +	/* notifiers */
 +	WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 +
 +	return OPERATOR_FINISHED;
 +}
 +
 +static void PALETTE_OT_palettecolor_reveal(wmOperatorType *ot)
 +{
 +	/* identifiers */
 +	ot->name = "Show All Colors";
 +	ot->idname = "PALETTE_OT_palettecolor_reveal";
 +	ot->description = "Unhide all hidden Grease Pencil palette colors";
 +
 +	/* callbacks */
 +	ot->exec = palettecolor_reveal_exec;
 +	ot->poll = palette_active_poll;
 +
 +	/* flags */
 +	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 +}
 +
 +/* ***************** Lock/Unlock All Palette colors ************************ */
 +
 +static int palettecolor_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
 +{
 +	Palette *palette = BKE_palette_get_active_from_context(C);
 +	PaletteColor *palcolor;
 +
 +	/* sanity checks */
 +	if (ELEM(NULL, palette))
 +		return OPERATOR_CANCELLED;
 +
 +	/* make all layers non-editable */
 +	for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
 +		palcolor->flag |= PC_COLOR_LOCKED;
 +	}
 +
 +	/* notifiers */
 +	WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 +
 +	return OPERATOR_FINISHED;
 +}
 +
 +static void PALETTE_OT_palettecolor_lock_all(wmOperatorType *ot)
 +{
 +	/* identifiers */
 +	ot->name = "Lock All Colors";
 +	ot->idname = "PALETTE_OT_palettecolor_lock_all";
 +	ot->description = "Lock all Grease Pencil colors to prevent them from being accidentally modified";
 +
 +	/* callbacks */
 +	ot->exec = palettecolor_lock_all_exec;
 +	ot->poll = palette_active_poll;
 +
 +											/* flags */
 +	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 +}
 +
 +/* -------------------------- */
 +
 +static int palettecolor_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
 +{
 +	Palette *palette = BKE_palette_get_active_from_context(C);
 +	PaletteColor *palcolor;
 +
 +	/* sanity checks */
 +	if (ELEM(NULL, palette))
 +		return OPERATOR_CANCELLED;
 +
 +	/* make all layers editable again*/
 +	for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
 +		palcolor->flag &= ~PC_COLOR_LOCKED;
 +	}
 +
 +	/* notifiers */
 +	WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 +
 +	return OPERATOR_FINISHED;
 +}
 +
 +static void PALETTE_OT_palettecolor_unlock_all(wmOperatorType *ot)
 +{
 +	/* identifiers */
 +	ot->name = "Unlock All Colors";
 +	ot->idname = "PALETTE_OT_palettecolor_unlock_all";
 +	ot->description = "Unlock all Grease Pencil colors so that they can be edited";
 +
 +	/* callbacks */
 +	ot->exec = palettecolor_unlock_all_exec;
 +	ot->poll = palette_active_poll;
 +
 +											/* flags */
 +	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 +}
 +
 +/* ******************* Move Color Up/Down ************************** *

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list