[Bf-blender-cvs] [6bf915e] id-remap: Merge branch 'master' into id-remap

Bastien Montagne noreply at git.blender.org
Tue Oct 27 15:05:00 CET 2015


Commit: 6bf915e925cc45616642f7db622ca7fb3e7b619a
Author: Bastien Montagne
Date:   Tue Oct 27 14:46:51 2015 +0100
Branches: id-remap
https://developer.blender.org/rB6bf915e925cc45616642f7db622ca7fb3e7b619a

Merge branch 'master' into id-remap

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



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

diff --cc source/blender/blenkernel/BKE_material.h
index ad98664,d32d679..948d373
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@@ -45,10 -45,11 +45,11 @@@ struct Scene
  /* materials */
  
  void init_def_material(void);
- void BKE_material_free(struct Material *ma);
 -void BKE_material_free(struct Material *sc); 
++void BKE_material_free(struct Material *ma); 
+ void BKE_material_free_ex(struct Material *ma, bool do_id_user);
  void test_object_materials(struct Main *bmain, struct ID *id);
  void BKE_material_resize_object(struct Object *ob, const short totcol, bool do_id_user);
- void BKE_init_material(struct Material *ma);
+ void BKE_material_init(struct Material *ma);
  void BKE_material_remap_object(struct Object *ob, const unsigned int *remap);
  struct Material *BKE_material_add(struct Main *bmain, const char *name);
  struct Material *BKE_material_copy(struct Material *ma);
diff --cc source/blender/blenkernel/intern/material.c
index 4589ad2,a69b5fd..dd5772a
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@@ -78,41 -78,53 +78,41 @@@ Material defmaterial
  /* called on startup, creator.c */
  void init_def_material(void)
  {
- 	BKE_init_material(&defmaterial);
+ 	BKE_material_init(&defmaterial);
  }
  
 -/* not material itself */
 +/** Free (or release) any data used by this material (does not free the material itself). */
  void BKE_material_free(Material *ma)
  {
 -	BKE_material_free_ex(ma, true);
 -}
 -
 -/* not material itself */
 -void BKE_material_free_ex(Material *ma, bool do_id_user)
 -{
 -	MTex *mtex;
  	int a;
 +
 +	BKE_animdata_free((ID *)ma);
  	
  	for (a = 0; a < MAX_MTEX; a++) {
 -		mtex = ma->mtex[a];
 -		if (do_id_user && mtex && mtex->tex) mtex->tex->id.us--;
 -		if (mtex) MEM_freeN(mtex);
 +		MEM_SAFE_FREE(ma->mtex[a]);
  	}
  	
 -	if (ma->ramp_col) MEM_freeN(ma->ramp_col);
 -	if (ma->ramp_spec) MEM_freeN(ma->ramp_spec);
 -	
 -	BKE_animdata_free((ID *)ma);
 -	
 -	if (ma->preview)
 -		BKE_previewimg_free(&ma->preview);
 -	BKE_icon_id_delete((struct ID *)ma);
 -	ma->id.icon_id = 0;
 +	MEM_SAFE_FREE(ma->ramp_col);
 +	MEM_SAFE_FREE(ma->ramp_spec);
  	
  	/* is no lib link block, but material extension */
  	if (ma->nodetree) {
 -		ntreeFreeTree_ex(ma->nodetree, do_id_user);
 +		ntreeFreeTree(ma->nodetree);
  		MEM_freeN(ma->nodetree);
 +		ma->nodetree = NULL;
  	}
  
 -	if (ma->texpaintslot)
 -		MEM_freeN(ma->texpaintslot);
 +	MEM_SAFE_FREE(ma->texpaintslot);
 +
 +	GPU_material_free(&ma->gpumaterial);
  
 -	if (ma->gpumaterial.first)
 -		GPU_material_free(&ma->gpumaterial);
 +	BKE_icon_id_delete((ID *)ma);
 +	BKE_previewimg_free(&ma->preview);
  }
  
- void BKE_init_material(Material *ma)
+ void BKE_material_init(Material *ma)
  {
- 	BLI_assert(MEMCMP_NULL_STRUCT_OFS(ma, id));
+ 	BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ma, id));
  
  	ma->r = ma->g = ma->b = ma->ref = 0.8;
  	ma->specr = ma->specg = ma->specb = 1.0;
diff --cc source/blender/blenkernel/intern/mball.c
index 3d7d4d4,bd9fd33..7e014fc
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@@ -66,15 -66,29 +66,15 @@@
  
  /* Functions */
  
 -void BKE_mball_unlink(MetaBall *mb)
 +/** Free (or release) any data used by this mball (does not free the mball itself). */
 +void BKE_mball_free(MetaBall *mb)
  {
 -	int a;
 -	
 -	for (a = 0; a < mb->totcol; a++) {
 -		if (mb->mat[a]) mb->mat[a]->id.us--;
 -		mb->mat[a] = NULL;
 -	}
 -}
 +	BKE_animdata_free((ID *)mb);
  
 +	MEM_SAFE_FREE(mb->mat);
  
 -/* do not free mball itself */
 -void BKE_mball_free(MetaBall *mb)
 -{
 -	BKE_mball_unlink(mb);
 -	
 -	if (mb->adt) {
 -		BKE_animdata_free((ID *)mb);
 -		mb->adt = NULL;
 -	}
 -	if (mb->mat) MEM_freeN(mb->mat);
  	BLI_freelistN(&mb->elems);
- 	BKE_displist_free(&mb->disp);
+ 	if (mb->disp.first) BKE_displist_free(&mb->disp);
  }
  
  void BKE_mball_init(MetaBall *mb)
diff --cc source/blender/blenkernel/intern/scene.c
index 5ebdf96,d73797c..139a7ba
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@@ -1082,10 -1130,8 +1082,10 @@@ void BKE_scene_base_unlink(Scene *sce, 
  	/* remove rigid body object from world before removing object */
  	if (base->object->rigidbody_object)
  		BKE_rigidbody_remove_object(sce, base->object);
- 
+ 	
  	BLI_remlink(&sce->base, base);
 +	if (sce->basact == base)
 +		sce->basact = NULL;
  }
  
  void BKE_scene_base_deselect_all(Scene *sce)
diff --cc source/blender/editors/space_outliner/outliner_intern.h
index 541608d,f10e6be..410a749
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@@ -150,8 -150,15 +150,15 @@@ int outliner_item_do_activate(struct bC
  
  /* outliner_edit.c ---------------------------------------------- */
  
- void outliner_do_object_operation(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, struct ListBase *lb,
-                                   void (*operation_cb)(struct bContext *C, struct Scene *scene, struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *, void *));
+ void outliner_do_object_operation_ex(
+         struct bContext *C, struct Scene *scene, struct SpaceOops *soops, struct ListBase *lb,
+         void (*operation_cb)(struct bContext *C, struct Scene *scene,
 -                             struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *),
++                             struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *, void *),
+         bool recurse_selected);
+ void outliner_do_object_operation(
+         struct bContext *C, struct Scene *scene, struct SpaceOops *soops, struct ListBase *lb,
+         void (*operation_cb)(struct bContext *C, struct Scene *scene,
 -                             struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *));
++                             struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *, void *));
  
  int common_restrict_check(struct bContext *C, struct Object *ob);
  
diff --cc source/blender/editors/space_outliner/outliner_tools.c
index 02506f1,863f09d..7758f2f
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@@ -522,15 -516,20 +522,20 @@@ static void group_instance_cb(bContext 
  	id_lib_extern(&group->id);
  }
  
- void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb, 
-                                   void (*operation_cb)(bContext *C, Scene *scene, TreeElement *,
-                                                        TreeStoreElem *, TreeStoreElem *, void *))
+ /**
+  * \param select_recurse: Set to false for operations which are already recursively operating on their children.
+  */
+ void outliner_do_object_operation_ex(
+         bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb,
+         void (*operation_cb)(bContext *C, Scene *scene, TreeElement *,
 -                             TreeStoreElem *, TreeStoreElem *),
++                             TreeStoreElem *, TreeStoreElem *, void *),
+         bool select_recurse)
  {
  	TreeElement *te;
- 	TreeStoreElem *tselem;
  	
  	for (te = lb->first; te; te = te->next) {
- 		tselem = TREESTORE(te);
+ 		TreeStoreElem *tselem = TREESTORE(te);
+ 		bool select_handled = false;
  		if (tselem->flag & TSE_SELECTED) {
  			if (tselem->type == 0 && te->idcode == ID_OB) {
  				// when objects selected in other scenes... dunno if that should be allowed
@@@ -541,7 -540,8 +546,8 @@@
  				/* important to use 'scene_owner' not scene_act else deleting objects can crash.
  				 * only use 'scene_act' when 'scene_owner' is NULL, which can happen when the
  				 * outliner isn't showing scenes: Visible Layer draw mode for eg. */
 -				operation_cb(C, scene_owner ? scene_owner : scene_act, te, NULL, tselem);
 +				operation_cb(C, scene_owner ? scene_owner : scene_act, te, NULL, tselem, NULL);
+ 				select_handled = true;
  			}
  		}
  		if (TSELEM_OPEN(tselem, soops)) {
@@@ -550,6 -552,14 +558,12 @@@
  	}
  }
  
 -void outliner_do_object_operation(
 -        bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb,
 -        void (*operation_cb)(bContext *C, Scene *scene, TreeElement *,
 -                             TreeStoreElem *, TreeStoreElem *))
++void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb,
++        void (*operation_cb)(bContext *, Scene *, TreeElement *, TreeStoreElem *, TreeStoreElem *, void *))
+ {
+ 	outliner_do_object_operation_ex(C, scene_act, soops, lb, operation_cb, true);
+ }
+ 
  /* ******************************************** */
  
  static void clear_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te),
diff --cc source/blender/makesrna/intern/rna_ID.c
index ed40f5c,43ffc77..fdd957c
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@@ -981,15 -974,9 +981,15 @@@ static void rna_def_ID(BlenderRNA *brna
  	RNA_def_function_return(func, parm);
  
  	func = RNA_def_function(srna, "user_clear", "rna_ID_user_clear");
- 	RNA_def_function_ui_description(func, "Clear the user count of a datablock so its not saved, "
+ 	RNA_def_function_ui_description(func, "Clear the user count of a data-block so its not saved, "
  	                                "on reload the data will be removed");
  
 +	func = RNA_def_function(srna, "user_remap", "rna_ID_user_remap");
 +	RNA_def_function_ui_description(func, "Replace all usage in the .blend file of this ID by new given one");
 +	RNA_def_function_flag(func, FUNC_USE_MAIN);
 +	parm = RNA_def_pointer(func, "new_id", "ID", "", "New ID to use");
 +	RNA_def_property_flag(parm, PROP_NEVER_NULL);
 +
  	func = RNA_def_function(srna, "animation_data_create", "rna_ID_animation_data_create");
  	RNA_def_function_flag(func, FUNC_USE_MAIN);
  	RNA_def_function_ui_description(func, "Create animation data to this ID, note that not all ID types support this");




More information about the Bf-blender-cvs mailing list