[Bf-blender-cvs] [c75e751] render-layers: Merge remote-tracking branch 'origin/blender2.8' into render-layers

Dalai Felinto noreply at git.blender.org
Tue Dec 13 13:48:44 CET 2016


Commit: c75e7516c32fd6181ab4232032d5ad6ace5fd630
Author: Dalai Felinto
Date:   Tue Dec 13 12:35:00 2016 +0100
Branches: render-layers
https://developer.blender.org/rBc75e7516c32fd6181ab4232032d5ad6ace5fd630

Merge remote-tracking branch 'origin/blender2.8' into render-layers

plus manual rna fixup

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



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

diff --cc source/blender/blenkernel/intern/scene.c
index 2000417,cab0a87..e634fea
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@@ -78,8 -77,8 +78,9 @@@
  #include "BKE_icons.h"
  #include "BKE_idprop.h"
  #include "BKE_image.h"
 +#include "BKE_layer.h"
  #include "BKE_library.h"
+ #include "BKE_library_remap.h"
  #include "BKE_linestyle.h"
  #include "BKE_main.h"
  #include "BKE_mask.h"
diff --cc source/blender/editors/object/object_relations.c
index 109074a,088ade6..eb410ac
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@@ -74,9 -73,9 +74,10 @@@
  #include "BKE_fcurve.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_main.h"
  #include "BKE_material.h"
  #include "BKE_mball.h"
@@@ -1732,92 -1731,48 +1733,82 @@@ void OBJECT_OT_make_links_data(wmOperat
  
  /**************************** Make Single User ********************************/
  
 +static Object *single_object_users_object(Main *bmain, Scene *scene, Object *ob, const bool copy_groups)
 +{
 +	if (!ID_IS_LINKED_DATABLOCK(ob) && ob->id.us > 1) {
 +		/* base gets copy of object */
- 		Object *obn = BKE_object_copy(bmain, ob);
++		Object *obn = ID_NEW_SET(ob, BKE_object_copy(bmain, ob));
 +
 +		if (copy_groups) {
 +			if (ob->flag & OB_FROMGROUP) {
 +				obn->flag |= OB_FROMGROUP;
 +			}
 +		}
 +		else {
 +			/* copy already clears */
 +		}
 +		/* remap gpencil parenting */
 +
 +		if (scene->gpd) {
 +			bGPdata *gpd = scene->gpd;
 +			for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
 +				if (gpl->parent == ob) {
 +					gpl->parent = obn;
 +				}
 +			}
 +		}
 +
 +		id_us_min(&ob->id);
 +		return obn;
 +	}
 +	return NULL;
 +}
 +
 +static void libblock_relink_scene_collection(SceneCollection *sc)
 +{
 +	for (LinkData *link = sc->objects.first; link; link = link->next) {
- 		BKE_libblock_relink(link->data);
++		BKE_libblock_relink_to_newid(link->data);
 +	}
 +
 +	for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
 +		libblock_relink_scene_collection(nsc);
 +	}
 +}
 +
 +static void single_object_users_scene_collection(Main *bmain, Scene *scene, SceneCollection *sc, const int flag, const bool copy_groups)
 +{
 +	for (LinkData *link = sc->objects.first; link; link = link->next) {
 +		Object *ob = link->data;
 +		/* an object may be in more than one collection */
 +		if ((ob->id.newid == NULL) && ((ob->flag & flag) == flag)) {
 +			link->data = single_object_users_object(bmain, scene, link->data, copy_groups);
 +		}
 +	}
 +
 +	/* we reset filter objects because they should be regenerated after this */
 +	BLI_freelistN(&sc->filter_objects);
 +
 +	for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
 +		single_object_users_scene_collection(bmain, scene, nsc, flag, copy_groups);
 +	}
 +}
 +
+ /* Warning, sets ID->newid pointers of objects and groups, but does not clear them. */
  static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const int flag, const bool copy_groups)
  {
 -	Base *base;
 -	Object *ob, *obn;
  	Group *group, *groupn;
  	GroupObject *go;
  
- 	clear_sca_new_poins();  /* sensor/contr/act */
- 
- 	/* newid may still have some trash from Outliner tree building, so clear that first to avoid errors, see T26002.
- 	 * We have to clear whole datablocks, not only Object one may be accessed here, see T49905. */
- 	ListBase *lbarray[MAX_LIBARRAY];
- 	int a = set_listbasepointers(bmain, lbarray);
- 	while (a--) {
- 		ListBase *lb = lbarray[a];
- 		for (ID *id = lb->first; id; id = id->next) {
- 			id->newid = NULL;
- 		}
- 	}
+ 	clear_sca_new_poins();  /* BGE logic */
  
 -	/* duplicate (must set newid) */
 -	for (base = FIRSTBASE; base; base = base->next) {
 -		ob = base->object;
 +	/* duplicate all the objects of the scene */
 +	SceneCollection *msc = BKE_collection_master(scene);
 +	single_object_users_scene_collection(bmain, scene, msc, flag, copy_groups);
  
 -		if ((base->flag & flag) == flag) {
 -			if (!ID_IS_LINKED_DATABLOCK(ob) && ob->id.us > 1) {
 -				/* base gets copy of object */
 -				base->object = obn = ID_NEW_SET(ob, BKE_object_copy(bmain, ob));
 -
 -				if (copy_groups) {
 -					if (ob->flag & OB_FROMGROUP) {
 -						obn->flag |= OB_FROMGROUP;
 -					}
 -				}
 -				else {
 -					/* copy already clears */
 -				}
 -				/* remap gpencil parenting */
 -
 -				if (scene->gpd) {
 -					bGPdata *gpd = scene->gpd;
 -					for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
 -						if (gpl->parent == ob) {
 -							gpl->parent = obn;
 -						}
 -					}
 -				}
 -
 -				base->flag = obn->flag;
 -
 -				id_us_min(&ob->id);
 -			}
 +	/* loop over SceneLayers and assign the pointers accordingly */
 +	for (SceneLayer *sl = scene->render_layers.first; sl; sl = sl->next) {
 +		for (ObjectBase *ob_base = sl->object_bases.first; ob_base; ob_base = ob_base->next) {
- 			ID_NEW(ob_base->object);
++			ID_NEW_REMAP(ob_base->object);
  		}
  	}
  
@@@ -1847,30 -1801,32 +1837,31 @@@
  	/* group pointers in scene */
  	BKE_scene_groups_relink(scene);
  
- 	ID_NEW(scene->camera);
- 	if (v3d) ID_NEW(v3d->camera);
+ 	ID_NEW_REMAP(scene->camera);
+ 	if (v3d) ID_NEW_REMAP(v3d->camera);
  
  	/* object and group pointers */
 -	for (base = FIRSTBASE; base; base = base->next) {
 -		BKE_libblock_relink_to_newid(&base->object->id);
 -	}
 +	libblock_relink_scene_collection(msc);
  
  	set_sca_new_poins();
 +
 +	/* TODO redo filter */
 +	TODO_LAYER_SYNC_FILTER
 +}
 +
 +static void object_untag_OB_DONE(Object *ob, void *UNUSED(data))
 +{
 +	ob->flag &= ~OB_DONE;
  }
  
  /* not an especially efficient function, only added so the single user
   * button can be functional.*/
  void ED_object_single_user(Main *bmain, Scene *scene, Object *ob)
  {
 -	Base *base;
 -	const bool copy_groups = false;
 -
 -	for (base = FIRSTBASE; base; base = base->next) {
 -		if (base->object == ob) base->flag |=  OB_DONE;
 -		else base->flag &= ~OB_DONE;
 -	}
 -
 -	single_object_users(bmain, scene, NULL, OB_DONE, copy_groups);
 -
 +	BKE_scene_objects_callback(scene, object_untag_OB_DONE, NULL);
 +	ob->flag |= OB_DONE;
 +	single_object_users(bmain, scene, NULL, OB_DONE, false);
+ 	BKE_main_id_clear_newpoins(bmain);
  }
  
  static void new_id_matar(Main *bmain, Material **matar, const int totcol)
@@@ -2413,18 -2366,8 +2403,16 @@@ static int make_single_user_exec(bConte
  	const bool copy_groups = false;
  	bool update_deps = false;
  
- 	BKE_main_id_clear_newpoins(bmain);
- 
  	if (RNA_boolean_get(op->ptr, "object")) {
 -		single_object_users(bmain, scene, v3d, flag, copy_groups);
 +		if (flag == SELECT) {
 +			SceneLayer *sl = CTX_data_scene_layer(C);
 +
 +			BKE_scene_layer_selected_objects_tag(sl, OB_DONE);
 +			single_object_users(bmain, scene, v3d, OB_DONE, copy_groups);
 +		}
 +		else {
 +			single_object_users(bmain, scene, v3d, 0, copy_groups);
 +		}
  
  		/* needed since object relationships may have changed */
  		update_deps = true;
diff --cc source/blender/makesrna/intern/rna_scene.c
index 1c7c352,b4201dd..57d4efd
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@@ -5220,281 -4903,6 +5220,281 @@@ static void rna_def_gpu_fx(BlenderRNA *
  	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPUFXSettings_fx_update");
  }
  
 +/* Render Layers and Collections */
 +
 +static void rna_def_scene_collections(BlenderRNA *brna, PropertyRNA *cprop)
 +{
 +	StructRNA *srna;
 +	FunctionRNA *func;
 +	PropertyRNA *parm;
 +
 +	RNA_def_property_srna(cprop, "SceneCollections");
 +	srna = RNA_def_struct(brna, "SceneCollections", NULL);
 +	RNA_def_struct_sdna(srna, "SceneCollection");
 +	RNA_def_struct_ui_text(srna, "Scene Collection", "Collection of scene collections");
 +
 +	func = RNA_def_function(srna, "new", "rna_SceneCollection_new");
 +	RNA_def_function_ui_description(func, "Add a collection to scene");
 +	RNA_def_function_flag(func, FUNC_USE_SELF_ID);
 +	parm = RNA_def_string(func, "name", "SceneCollection", 0, "", "New name for the collection (not unique)");
- 	RNA_def_property_flag(parm, PROP_REQUIRED);
++	RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
 +	parm = RNA_def_pointer(func, "result", "SceneCollection", "", "Newly created collection");
 +	RNA_def_function_return(func, parm);
 +
 +	func = RNA_def_function(srna, "remove", "rna_SceneCollection_remove");
 +	RNA_def_function_ui_description(func, "Remove a collection layer");
 +	RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
 +	parm = RNA_def_pointer(func, "layer", "SceneCollection", "", "Collection to remove");
- 	RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
- 	RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
++	RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
++	RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
 +}
 +
 +static void rna_def_collection_objects(BlenderRNA *brna, PropertyRNA *cprop)
 +{
 +	StructRNA *srna;
 +	FunctionRNA *func;
 +	PropertyRNA *parm;
 +
 +	RNA_def_property_srna(cprop, "CollectionObjects");
 +	srna = RNA_def_struct(brna, "CollectionObjects", NULL);
 +	RNA_def_struct_sdna(srna, "SceneCollection");
 +	RNA_def_struct_ui_text(srna, "Collection Objects", "Objects of a collection");
 +
 +	func = RNA_def_function(srna, "link", "rna_SceneCollection_object_link");
 +	RNA_def_function_ui_description(func, "Link an object to collection");
 +	RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
 +	parm = RNA_def_pointer(func, "object", "Object", "", "Object to add to collection");
- 	RNA_def_property_flag(parm, PROP_REQUIRED |  PROP_NEVER_NULL);
++	RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
 +
 +	func = RNA_def_function(srna, "unlink", "rna_SceneCollection_object_unlink");
 +	RNA_def_function_ui_description(func, "Unlink object from collection");
 +	RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
 +	parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove from colle

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list