[Bf-blender-cvs] [8f8c2386592] blender2.8: Merge branch 'master' into blender2.8

Campbell Barton noreply at git.blender.org
Fri Nov 30 05:12:12 CET 2018


Commit: 8f8c23865922a77458f548752ffccb048b96ea5b
Author: Campbell Barton
Date:   Fri Nov 30 15:11:32 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB8f8c23865922a77458f548752ffccb048b96ea5b

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index e59de4224c0,92640718b03..1485079c418
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@@ -956,23 -562,12 +956,23 @@@ void DepsgraphNodeBuilder::build_driver
  {
  	build_driver_id_property(id, fcurve->rna_path);
  	LISTBASE_FOREACH (DriverVar *, dvar, &fcurve->driver->variables) {
- 		DRIVER_TARGETS_USED_LOOPER(dvar)
+ 		DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
  		{
 +			if (dtar->id == NULL) {
 +				continue;
 +			}
  			build_id(dtar->id);
  			build_driver_id_property(dtar->id, dtar->rna_path);
 +			/* Corresponds to dtar_id_ensure_proxy_from(). */
 +			if ((GS(dtar->id->name) == ID_OB) &&
 +			    (((Object *)dtar->id)->proxy_from != NULL))
 +			{
 +				Object *proxy_from = ((Object *)dtar->id)->proxy_from;
 +				build_id(&proxy_from->id);
 +				build_driver_id_property(&proxy_from->id, dtar->rna_path);
 +			}
  		}
- 		DRIVER_TARGETS_LOOPER_END
+ 		DRIVER_TARGETS_LOOPER_END;
  	}
  }
  
diff --cc source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index b5a221a2215,19bf2983033..8af6b2f3a97
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@@ -1530,20 -1191,22 +1530,20 @@@ void DepsgraphRelationBuilder::build_dr
  					continue;
  				}
  				add_relation(variable_key, driver_key, "RNA Target -> Driver");
 +				if (proxy_from != NULL) {
 +					RNAPathKey proxy_from_variable_key(&proxy_from->id,
 +					                                   dtar->rna_path);
 +					add_relation(proxy_from_variable_key,
 +					             variable_key,
 +					             "Proxy From -> Variable");
 +				}
  			}
  			else {
 -				if (dtar->id == id) {
 -					/* Ignore input dependency if we're driving properties of
 -					 * the same ID, otherwise we'll be ending up in a cyclic
 -					 * dependency here.
 -					 */
 -					continue;
 -				}
 -				/* Resolve path to get node. */
 -				RNAPathKey target_key(dtar->id,
 -				                      dtar->rna_path ? dtar->rna_path : "");
 -				add_relation(target_key, driver_key, "RNA Target -> Driver");
 +				/* If rna_path is NULL, and DTAR_FLAG_STRUCT_REF isn't set, this
 +				 * is an incomplete target reference, so nothing to do here. */
  			}
  		}
- 		DRIVER_TARGETS_LOOPER_END
+ 		DRIVER_TARGETS_LOOPER_END;
  	}
  }
  
diff --cc source/blender/editors/gpencil/gpencil_data.c
index e9b65009781,1bdeeefe223..236d6964c26
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@@ -1842,315 -1399,111 +1842,315 @@@ static int gpencil_vertex_group_smooth_
  	return OPERATOR_FINISHED;
  }
  
 -void GPENCIL_OT_palette_add(wmOperatorType *ot)
 +void GPENCIL_OT_vertex_group_smooth(wmOperatorType *ot)
  {
  	/* identifiers */
 -	ot->name = "Add Palette";
 -	ot->idname = "GPENCIL_OT_palette_add";
 -	ot->description = "Add new Grease Pencil palette for the active Grease Pencil data-block";
 +	ot->name = "Smooth Vertex Group";
 +	ot->idname = "GPENCIL_OT_vertex_group_smooth";
 +	ot->description = "Smooth weights to the active vertex group";
 +
 +	/* api callbacks */
 +	ot->poll = gpencil_vertex_group_weight_poll;
 +	ot->exec = gpencil_vertex_group_smooth_exec;
  
 +	/* flags */
  	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
  
 -	/* callbacks */
 -	ot->exec = gp_palette_add_exec;
 -	ot->poll = gp_add_poll;
 +	RNA_def_float(ot->srna, "factor", 0.5f, 0.0f, 1.0, "Factor", "", 0.0f, 1.0f);
 +	RNA_def_int(ot->srna, "repeat", 1, 1, 10000, "Iterations", "", 1, 200);
  }
  
 -/* ******************* Remove Active Palette ************************* */
 +/****************************** Join ***********************************/
  
 -static int gp_palette_remove_exec(bContext *C, wmOperator *op)
 -{
 -	bGPdata *gpd = ED_gpencil_data_get_active(C);
 -	bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd);
 +/* userdata for joined_gpencil_fix_animdata_cb() */
 +typedef struct tJoinGPencil_AdtFixData {
 +	bGPdata *src_gpd;
 +	bGPdata *tar_gpd;
  
 -	/* sanity checks */
 -	if (ELEM(NULL, gpd, palette))
 -		return OPERATOR_CANCELLED;
 +	GHash *names_map;
 +} tJoinGPencil_AdtFixData;
  
 -	if (BLI_listbase_count_at_most(&gpd->palettes, 2) < 2) {
 -		BKE_report(op->reports, RPT_ERROR, "Grease Pencil needs a palette, unable to delete the last one");
 -		return OPERATOR_CANCELLED;
 -	}
 +/* Callback to pass to BKE_fcurves_main_cb() for RNA Paths attached to each F-Curve used in the AnimData */
 +static void joined_gpencil_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data)
 +{
 +	tJoinGPencil_AdtFixData *afd = (tJoinGPencil_AdtFixData *)user_data;
 +	ID *src_id = &afd->src_gpd->id;
 +	ID *dst_id = &afd->tar_gpd->id;
  
 +	GHashIterator gh_iter;
  
 -	/* make the palette before this the new active palette
 -	 * - use the one after if this is the first
 -	 * - if this is the only palette, this naturally becomes NULL
 -	 */
 -	if (palette->prev)
 -		BKE_gpencil_palette_setactive(gpd, palette->prev);
 -	else
 -		BKE_gpencil_palette_setactive(gpd, palette->next);
 +	/* Fix paths - If this is the target datablock, it will have some "dirty" paths */
 +	if ((id == src_id) && fcu->rna_path && strstr(fcu->rna_path, "layers[")) {
 +		GHASH_ITER(gh_iter, afd->names_map) {
 +			const char *old_name = BLI_ghashIterator_getKey(&gh_iter);
 +			const char *new_name = BLI_ghashIterator_getValue(&gh_iter);
  
 -	/* delete the palette now... */
 -	BKE_gpencil_palette_delete(gpd, palette);
 +			/* only remap if changed; this still means there will be some waste if there aren't many drivers/keys */
 +			if (!STREQ(old_name, new_name) && strstr(fcu->rna_path, old_name)) {
 +				fcu->rna_path = BKE_animsys_fix_rna_path_rename(
 +				        id, fcu->rna_path, "layers",
 +				        old_name, new_name, 0, 0, false);
  
 -	/* notifiers */
 -	WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 +				/* we don't want to apply a second remapping on this F-Curve now,
 +				 * so stop trying to fix names names
 +				 */
 +				break;
 +			}
 +		}
 +	}
  
 -	return OPERATOR_FINISHED;
 +	/* Fix driver targets */
 +	if (fcu->driver) {
 +		/* Fix driver references to invalid ID's */
 +		for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) {
 +			/* only change the used targets, since the others will need fixing manually anyway */
- 			DRIVER_TARGETS_USED_LOOPER(dvar)
++			DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
 +			{
 +				/* change the ID's used... */
 +				if (dtar->id == src_id) {
 +					dtar->id = dst_id;
 +
 +					/* also check on the subtarget...
 +					 * XXX: We duplicate the logic from drivers_path_rename_fix() here, with our own
 +					 *      little twists so that we know that it isn't going to clobber the wrong data
 +					 */
 +					if (dtar->rna_path && strstr(dtar->rna_path, "layers[")) {
 +						GHASH_ITER(gh_iter, afd->names_map) {
 +							const char *old_name = BLI_ghashIterator_getKey(&gh_iter);
 +							const char *new_name = BLI_ghashIterator_getValue(&gh_iter);
 +
 +							/* only remap if changed */
 +							if (!STREQ(old_name, new_name)) {
 +								if ((dtar->rna_path) && strstr(dtar->rna_path, old_name)) {
 +									/* Fix up path */
 +									dtar->rna_path = BKE_animsys_fix_rna_path_rename(
 +									        id, dtar->rna_path, "layers",
 +									        old_name, new_name, 0, 0, false);
 +									break; /* no need to try any more names for layer path */
 +								}
 +							}
 +						}
 +					}
 +				}
 +			}
- 			DRIVER_TARGETS_LOOPER_END
++			DRIVER_TARGETS_LOOPER_END;
 +		}
 +	}
  }
  
 -void GPENCIL_OT_palette_remove(wmOperatorType *ot)
 +/* join objects called from OBJECT_OT_join */
 +int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
  {
 -	/* identifiers */
 -	ot->name = "Remove palette";
 -	ot->idname = "GPENCIL_OT_palette_remove";
 -	ot->description = "Remove active Grease Pencil palette";
 +	Main *bmain = CTX_data_main(C);
 +	Scene *scene = CTX_data_scene(C);
 +	Depsgraph *depsgraph = CTX_data_depsgraph(C);
 +	Object  *ob_active = CTX_data_active_object(C);
 +	bGPdata *gpd_dst = NULL;
 +	bool ok = false;
 +
 +	/* Ensure we're in right mode and that the active object is correct */
 +	if (!ob_active || ob_active->type != OB_GPENCIL)
 +		return OPERATOR_CANCELLED;
  
 -	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 +	bGPdata *gpd = (bGPdata *)ob_active->data;
 +	if ((!gpd) || GPENCIL_ANY_MODE(gpd)) {
 +		return OPERATOR_CANCELLED;
 +	}
  
 -	/* callbacks */
 -	ot->exec = gp_palette_remove_exec;
 -	ot->poll = gp_active_palette_poll;
 -}
 +	/* Ensure all rotations are applied before */
 +	// XXX: Why don't we apply them here instead of warning?
 +	CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
 +	{
 +		if (ob_iter->type == OB_GPENCIL) {
 +			if ((ob_iter->rot[0] != 0) ||
 +			    (ob_iter->rot[1] != 0) ||
 +			    (ob_iter->rot[2] != 0))
 +			{
 +				BKE_report(op->reports, RPT_ERROR, "Apply all rotations before join objects");
 +				return OPERATOR_CANCELLED;
 +			}
 +		}
 +	}
 +	CTX_DATA_END;
  
 -/* ********************** Change Palette ***************************** */
 +	CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
 +	{
 +		if (ob_iter == ob_active) {
 +			ok = true;
 +			break;
 +		}
 +	}
 +	CTX_DATA_END;
  
 -static int gp_palette_change_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(evt))
 -{
 -	uiPopupMenu *pup;
 -	uiLayout *layout;
 +	/* that way the active object is always selected */
 +	if (ok == false) {
 +		BKE_report(op->reports, RPT_WARNING, "Active object is not a selected grease pencil");
 +		return OPERATOR_CANCELLED;
 +	}
  
 -	/* call the menu, which will call this operator again, hence the canceled */
 -	pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
 -	layout = UI_popup_menu_layout(pup);
 -	uiItemsEnumO(layout, "GPENCIL_OT_palette_change", "palette");
 -	UI_popup_menu_end(C, pup);
 +	gpd_dst = ob_active->data;
 +	Object *ob_dst = ob_active;
 +
 +	/* loop and join all data */
 +	CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
 +	{
 +		if ((ob_iter->type == OB_GPENCIL) && (ob_iter != ob_activ

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list