[Bf-blender-cvs] [296d059] soc-2016-layer_manager: Merge branch 'master' into soc-2016-layer_manager

Julian Eisel noreply at git.blender.org
Mon Jul 11 15:54:05 CEST 2016


Commit: 296d0592e1253e220a20b6728c3bfb1510af3764
Author: Julian Eisel
Date:   Mon Jul 11 15:53:22 2016 +0200
Branches: soc-2016-layer_manager
https://developer.blender.org/rB296d0592e1253e220a20b6728c3bfb1510af3764

Merge branch 'master' into soc-2016-layer_manager

And make manual adjustments of merged parts to fit changes in branch.
Conflicts:
	source/blender/blenkernel/intern/library_remap.c
	source/blender/blenkernel/intern/object.c
	source/blender/editors/animation/anim_filter.c

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



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

diff --cc source/blender/blenkernel/intern/library_remap.c
index 7920525,b158b3f..1e60a34
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@@ -231,6 -231,145 +232,147 @@@ static int foreach_libblock_remap_callb
  	return IDWALK_RET_NOP;
  }
  
+ /* Some reamapping unfortunately require extra and/or specific handling, tackle those here. */
+ static void libblock_remap_data_preprocess_scene_base_unlink(
+         IDRemap *r_id_remap_data, Scene *sce, Base *base, const bool skip_indirect, const bool is_indirect)
+ {
+ 	if (skip_indirect && is_indirect) {
+ 		r_id_remap_data->skipped_indirect++;
+ 		r_id_remap_data->skipped_refcounted++;
+ 	}
+ 	else {
+ 		id_us_min((ID *)base->object);
+ 		BKE_scene_base_unlink(sce, base);
+ 		MEM_freeN(base);
+ 		if (!is_indirect) {
+ 			r_id_remap_data->status |= ID_REMAP_IS_LINKED_DIRECT;
+ 		}
+ 	}
+ }
+ 
+ static void libblock_remap_data_preprocess(IDRemap *r_id_remap_data)
+ {
+ 	switch (GS(r_id_remap_data->id->name)) {
+ 		case ID_SCE:
+ 		{
+ 			Scene *sce = (Scene *)r_id_remap_data->id;
+ 
+ 			if (!r_id_remap_data->new_id) {
+ 				const bool is_indirect = (sce->id.lib != NULL);
+ 				const bool skip_indirect = (r_id_remap_data->flag & ID_REMAP_SKIP_INDIRECT_USAGE) != 0;
+ 
+ 				/* In case we are unlinking... */
+ 				if (!r_id_remap_data->old_id) {
+ 					/* ... everything from scene. */
+ 					Base *base, *base_next;
+ 					for (base = sce->base.first; base; base = base_next) {
+ 						base_next = base->next;
+ 						libblock_remap_data_preprocess_scene_base_unlink(
+ 						            r_id_remap_data, sce, base, skip_indirect, is_indirect);
+ 					}
+ 				}
+ 				else if (GS(r_id_remap_data->old_id->name) == ID_OB) {
+ 					/* ... a specific object from scene. */
+ 					Object *old_ob = (Object *)r_id_remap_data->old_id;
+ 					Base *base = BKE_scene_base_find(sce, old_ob);
+ 
+ 					if (base) {
+ 						libblock_remap_data_preprocess_scene_base_unlink(
+ 						            r_id_remap_data, sce, base, skip_indirect, is_indirect);
+ 					}
+ 				}
+ 			}
+ 			break;
+ 		}
+ 		case ID_OB:
+ 		{
+ 			ID *old_id = r_id_remap_data->old_id;
+ 			if (!old_id || GS(old_id->name) == ID_AR) {
+ 				Object *ob = (Object *)r_id_remap_data->id;
+ 				/* Object's pose holds reference to armature bones... sic */
+ 				/* Note that in theory, we should have to bother about linked/non-linked/never-null/etc. flags/states.
+ 				 * Fortunately, this is just a tag, so we can accept to 'over-tag' a bit for pose recalc, and avoid
+ 				 * another complex and risky condition nightmare like the one we have in
+ 				 * foreach_libblock_remap_callback()... */
+ 				if (ob->pose && (!old_id || ob->data == old_id)) {
+ 					BLI_assert(ob->type == OB_ARMATURE);
+ 					ob->pose->flag |= POSE_RECALC;
+ 				}
+ 			}
+ 			break;
+ 		}
+ 		default:
+ 			break;
+ 	}
+ }
+ 
+ static void libblock_remap_data_postprocess_object_fromgroup_update(Main *bmain, Object *old_ob, Object *new_ob)
+ {
+ 	if (old_ob->flag & OB_FROMGROUP) {
+ 		/* Note that for Scene's BaseObject->flag, either we:
+ 		 *     - unlinked old_ob (i.e. new_ob is NULL), in which case scenes' bases have been removed already.
+ 		 *     - remapped old_ob by new_ob, in which case scenes' bases are still valid as is.
+ 		 * So in any case, no need to update them here. */
+ 		if (BKE_group_object_find(NULL, old_ob) == NULL) {
+ 			old_ob->flag &= ~OB_FROMGROUP;
+ 		}
+ 		if (new_ob == NULL) {  /* We need to remove NULL-ified groupobjects... */
+ 			for (Group *group = bmain->group.first; group; group = group->id.next) {
+ 				BKE_group_object_unlink(group, NULL, NULL, NULL);
+ 			}
+ 		}
+ 		else {
+ 			new_ob->flag |= OB_FROMGROUP;
+ 		}
+ 	}
+ }
+ 
+ static void libblock_remap_data_postprocess_group_scene_unlink(Main *UNUSED(bmain), Scene *sce, ID *old_id)
+ {
+ 	/* Note that here we assume no object has no base (i.e. all objects are assumed instanced
+ 	 * in one scene...). */
 -	for (Base *base = sce->base.first; base; base = base->next) {
++	BKE_BASES_ITER_START(sce)
++	{
+ 		if (base->flag & OB_FROMGROUP) {
+ 			Object *ob = base->object;
+ 
+ 			if (ob->flag & OB_FROMGROUP) {
+ 				Group *grp = BKE_group_object_find(NULL, ob);
+ 
+ 				/* Unlinked group (old_id) is still in bmain... */
+ 				if (grp && (&grp->id == old_id || grp->id.us == 0)) {
+ 					grp = BKE_group_object_find(grp, ob);
+ 				}
+ 				if (!grp) {
+ 					ob->flag &= ~OB_FROMGROUP;
+ 				}
+ 			}
+ 			if (!(ob->flag & OB_FROMGROUP)) {
+ 				base->flag &= ~OB_FROMGROUP;
+ 			}
+ 		}
+ 	}
++	BKE_BASES_ITER_END;
+ }
+ 
+ static void libblock_remap_data_postprocess_obdata_relink(Main *UNUSED(bmain), Object *ob, ID *new_id)
+ {
+ 	if (ob->data == new_id) {
+ 		switch (GS(new_id->name)) {
+ 			case ID_ME:
+ 				multires_force_update(ob);
+ 				break;
+ 			case ID_CU:
+ 				BKE_curve_type_test(ob);
+ 				break;
+ 			default:
+ 				break;
+ 		}
+ 		test_object_modifiers(ob);
+ 		test_object_materials(ob, new_id);
+ 	}
+ }
+ 
  /**
   * Execute the 'data' part of the remapping (that is, all ID pointers from other ID datablocks).
   *
diff --cc source/blender/blenkernel/intern/object.c
index b268e7c,4031afb..b431039
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@@ -92,8 -92,9 +92,10 @@@
  #include "BKE_key.h"
  #include "BKE_lamp.h"
  #include "BKE_lattice.h"
 +#include "BKE_layer.h"
  #include "BKE_library.h"
+ #include "BKE_library_query.h"
+ #include "BKE_library_remap.h"
  #include "BKE_linestyle.h"
  #include "BKE_mesh.h"
  #include "BKE_editmesh.h"
diff --cc source/blender/blenloader/intern/writefile.c
index 46e0d59,bd19f2a..156f9af
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@@ -2849,18 -2825,10 +2849,18 @@@ static void write_scenes(WriteData *wd
  		write_previews(wd, sce->preview);
  		write_curvemapping_curves(wd, &sce->r.mblur_shutter_curve);
  
 -		sce = sce->id.next;
 +#ifdef WITH_ADVANCED_LAYERS
 +		if (sce->object_layers) {
 +			writestruct(wd, DATA, LayerTree, 1, sce->object_layers);
 +			writedata(wd, DATA, sizeof(LayerTreeItem *) * sce->object_layers->tot_items, sce->object_layers->items_all);
 +			write_layeritems(wd, sce, &sce->object_layers->items);
 +		}
 +#endif
 +
 +		sce= sce->id.next;
  	}
- 	/* flush helps the compression for undo-save */
- 	mywrite(wd, MYWRITE_FLUSH, 0);
+ 
+ 	mywrite_flush(wd);
  }
  
  static void write_gpencils(WriteData *wd, ListBase *lb)
diff --cc source/blender/editors/animation/anim_channels_edit.c
index baefbc6,af9b0a1..888bbb3
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@@ -2707,6 -2705,10 +2707,10 @@@ static int mouse_anim_channels(bContex
  			if ((adt) && (adt->flag & ADT_UI_SELECTED))
  				adt->flag |= ADT_UI_ACTIVE;
  			
+ 			/* ensure we exit editmode on whatever object was active before to avoid getting stuck there - T48747 */
 -			if (ob != sce->obedit)
++			if (anim_ob != sce->obedit)
+ 				ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
+ 			
  			notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
  			break;
  		}
diff --cc source/blender/editors/animation/anim_filter.c
index 5545481,88d96c5..afdec59
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@@ -2708,6 -2730,93 +2733,95 @@@ static size_t animdata_filter_dopesheet
  	return items;
  }
  
+ 
+ /* Helper for animdata_filter_dopesheet() - For checking if an object should be included or not */
+ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Scene *scene, Base *base, int filter_mode)
+ {
+ 	Object *ob = base->object;
+ 	
+ 	if (base->object == NULL)
+ 		return false;
+ 	
+ 	/* firstly, check if object can be included, by the following factors:
+ 	 *	- if only visible, must check for layer and also viewport visibility
+ 	 *		--> while tools may demand only visible, user setting takes priority
+ 	 *			as user option controls whether sets of channels get included while
+ 	 *			tool-flag takes into account collapsed/open channels too
+ 	 *	- if only selected, must check if object is selected 
+ 	 *	- there must be animation data to edit (this is done recursively as we 
+ 	 *	  try to add the channels)
+ 	 */
+ 	if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) {
+ 		/* layer visibility - we check both object and base, since these may not be in sync yet */
+ 		if ((scene->lay & (ob->lay | base->lay)) == 0)
+ 			return false;
+ 		
+ 		/* outliner restrict-flag */
+ 		if (ob->restrictflag & OB_RESTRICT_VIEW)
+ 			return false;
+ 	}
+ 	
+ 	/* if only F-Curves with visible flags set can be shown, check that 
+ 	 * datablock hasn't been set to invisible 
+ 	 */
+ 	if (filter_mode & ANIMFILTER_CURVE_VISIBLE) {
+ 		if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE))
+ 			return false;
+ 	}
+ 	
+ 	/* check selection and object type filters */
+ 	if ((ads->filterflag & ADS_FILTER_ONLYSEL) && !((base->flag & SELECT) /*|| (base == sce->basact)*/)) {
+ 		/* only selected should be shown */
+ 		return false;
+ 	}
+ 	
+ 	/* check if object belongs to the filtering group if option to filter 
+ 	 * objects by the grouped status is on
+ 	 *	- used to ease the process of doing multiple-character choreographies
+ 	 */
+ 	if (ads->filterflag & ADS_FILTER_ONLYOBGROUP) {
+ 		if (BKE_group_object_exists(ads->filter_grp, ob) == 0)
+ 			return false;
+ 	}
+ 	
+ 	/* no reason to exclude this object... */
+ 	return true;
+ }
+ 
+ /* Helper for animdata_filter_ds_sorted_bases() - Comparison callback for two Base pointers... */
+ static int ds_base_sorting_cmp(const void *base1_ptr, const void *base2_ptr)
+ {
+ 	const Base *b1 = *((const Base **)base1_ptr);
+ 	const Base *b2 = *((const Base **)base2_ptr);
+ 	
+ 	return strcmp(b1->object->id.name + 2, b2->object->id.name + 2);
+ }
+ 
+ /* Get a sorted list of all the bases - for inclusion in dopesheet (when drawing channels) */
+ static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads, Scene *scene, int filter_mode, size_t *r_usable_bases)
+ {
+ 	/* Create an array with space for all the

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list