[Bf-blender-cvs] [dca705d] id-remap: Huuuuuuuge commit - replace ugly scene/object/group_unlink by new generic libblock_unlink.

Bastien Montagne noreply at git.blender.org
Wed Oct 7 20:40:27 CEST 2015


Commit: dca705d1c329af4222997a3801d29d82661ad821
Author: Bastien Montagne
Date:   Wed Oct 7 20:32:59 2015 +0200
Branches: id-remap
https://developer.blender.org/rBdca705d1c329af4222997a3801d29d82661ad821

Huuuuuuuge commit - replace ugly scene/object/group_unlink by new generic libblock_unlink.

Previous situation was pretty much horrible, a few data types having their own coocking to
unlink, often doing more than only unlinking, often doing the same thing two times or more,
often messing with areas they should not have touched (like editors from withing BKE)...

Now we hope to have something generic, working the same way for all ID types
(we do have to add some specific handling for groups/objects/scene unfortunately,
but this remains reasonable).

Needless to say such a change is calling for troubles - I tried to follow and reproduce
as best as I could previous code, but most likely some areas will become buggy. Do not think
previous code was 100% correct anyway, things like Objects have a really big and complicated
usage of IDs...

Also, foreach_id tool has been enhanced, again for complex types like objects & co, we should
cover much better all possible IDs now (e.g. rigidbody & logic bricks were
totally missing from there).

And there is more to come...

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

M	source/blender/blenkernel/BKE_group.h
M	source/blender/blenkernel/BKE_library.h
M	source/blender/blenkernel/BKE_linestyle.h
M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/BKE_particle.h
M	source/blender/blenkernel/BKE_rigidbody.h
M	source/blender/blenkernel/BKE_sca.h
M	source/blender/blenkernel/BKE_scene.h
M	source/blender/blenkernel/BKE_screen.h
M	source/blender/blenkernel/intern/group.c
M	source/blender/blenkernel/intern/library.c
M	source/blender/blenkernel/intern/library_query.c
M	source/blender/blenkernel/intern/linestyle.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/blenkernel/intern/sca.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenkernel/intern/screen.c
M	source/blender/editors/include/ED_util.h
M	source/blender/editors/object/object_add.c
M	source/blender/editors/object/object_group.c
M	source/blender/editors/screen/screen_edit.c
M	source/blender/editors/space_buttons/space_buttons.c
M	source/blender/editors/space_clip/space_clip.c
M	source/blender/editors/space_image/space_image.c
M	source/blender/editors/space_logic/space_logic.c
M	source/blender/editors/space_node/space_node.c
M	source/blender/editors/space_outliner/outliner_tools.c
M	source/blender/editors/space_outliner/space_outliner.c
M	source/blender/editors/space_sequencer/space_sequencer.c
M	source/blender/editors/space_text/space_text.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/util/ed_util.c
M	source/blender/makesrna/intern/rna_main_api.c
M	source/blender/render/intern/source/pipeline.c
M	source/blender/windowmanager/intern/wm_event_system.c

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

diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h
index d27bdd3..31400fb 100644
--- a/source/blender/blenkernel/BKE_group.h
+++ b/source/blender/blenkernel/BKE_group.h
@@ -41,7 +41,6 @@ struct Object;
 struct Scene;
 
 void          BKE_group_free(struct Group *group, const bool do_id_user);
-void          BKE_group_unlink(struct Group *group);
 struct Group *BKE_group_add(struct Main *bmain, const char *name);
 struct Group *BKE_group_copy(struct Group *group);
 bool          BKE_group_object_add(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 172ebdf..daa0799 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -59,9 +59,11 @@ void  BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const bool
 
 /* Note: Requiring new_id to be non-null, this *may* not be the case ultimately, but makes things simpler for now. */
 void BKE_libblock_remap_locked(
-        struct Main *bmain, struct ID *old_id, struct ID *new_id, const bool skip_indirect_usage) ATTR_NONNULL();
+        struct Main *bmain, struct ID *old_id, struct ID *new_id, const bool skip_indirect_usage) ATTR_NONNULL(1, 2);
 void BKE_libblock_remap(
-        struct Main *bmain, struct ID *old_id, struct ID *new_id, const bool skip_indirect_usage) ATTR_NONNULL();
+        struct Main *bmain, struct ID *old_id, struct ID *new_id, const bool skip_indirect_usage) ATTR_NONNULL(1, 2);
+
+void BKE_libblock_unlink(struct Main *bmain, void *idv) ATTR_NONNULL();
 
 void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id);
 void id_lib_extern(struct ID *id);
@@ -73,7 +75,6 @@ void id_us_min(struct ID *id);
 bool id_make_local(struct ID *id, bool test);
 bool id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop);
 bool id_copy(struct ID *id, struct ID **newid, bool test);
-bool id_unlink(struct ID *id, int test);
 void id_sort_by_name(struct ListBase *lb, struct ID *id);
 
 bool new_id(struct ListBase *lb, struct ID *id, const char *name);
diff --git a/source/blender/blenkernel/BKE_linestyle.h b/source/blender/blenkernel/BKE_linestyle.h
index 76e64d4..5b41b70 100644
--- a/source/blender/blenkernel/BKE_linestyle.h
+++ b/source/blender/blenkernel/BKE_linestyle.h
@@ -79,8 +79,6 @@ void BKE_linestyle_geometry_modifier_move(FreestyleLineStyle *linestyle, LineSty
 void BKE_linestyle_modifier_list_color_ramps(FreestyleLineStyle *linestyle, ListBase *listbase);
 char *BKE_linestyle_path_to_color_ramp(FreestyleLineStyle *linestyle, struct ColorBand *color_ramp);
 
-void BKE_linestyle_target_object_unlink(FreestyleLineStyle *linestyle, struct Object *ob);
-
 bool BKE_linestyle_use_textures(FreestyleLineStyle *linestyle, const bool use_shading_nodes);
 
 void BKE_linestyle_default_shader(const struct bContext *C, FreestyleLineStyle *linestyle);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 9738acc..6272e70 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -78,7 +78,6 @@ void BKE_object_free_modifiers(struct Object *ob);
 void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob);
 void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target);
 
-void BKE_object_unlink(struct Object *ob);
 bool BKE_object_exists_check(struct Object *obtest);
 bool BKE_object_is_in_editmode(struct Object *ob);
 bool BKE_object_is_in_editmode_vgroup(struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index a71c4e5..2269a78 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -378,6 +378,11 @@ void psys_get_birth_coords(struct ParticleSimulationData *sim, struct ParticleDa
 
 void particle_system_update(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
 
+/* Callback format for performing operations on ID-pointers for particle systems */
+typedef void (*ParticleSystemIDFunc)(struct ParticleSystem *psys, struct ID **idpoin, void *userdata, int cd_flag);
+
+void BKE_particlesystem_id_loop(struct ParticleSystem *psys, ParticleSystemIDFunc func, void *userdata);
+
 /* ----------- functions needed only inside particlesystem ------------ */
 /* particle.c */
 void psys_disable_all(struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index a30ce6c..272abc4 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -53,6 +53,11 @@ struct RigidBodyOb *BKE_rigidbody_copy_object(struct Object *ob);
 struct RigidBodyCon *BKE_rigidbody_copy_constraint(struct Object *ob);
 void BKE_rigidbody_relink_constraint(struct RigidBodyCon *rbc);
 
+/* Callback format for performing operations on ID-pointers for rigidbody world. */
+typedef void (*RigidbodyWorldIDFunc)(struct RigidBodyWorld *rbw, struct ID **idpoin, void *userdata, int cd_flag);
+
+void BKE_rigidbody_world_id_loop(struct RigidBodyWorld *rbw, RigidbodyWorldIDFunc func, void *userdata);
+
 /* -------------- */
 /* Setup */
 
diff --git a/source/blender/blenkernel/BKE_sca.h b/source/blender/blenkernel/BKE_sca.h
index 341d949..1743a44 100644
--- a/source/blender/blenkernel/BKE_sca.h
+++ b/source/blender/blenkernel/BKE_sca.h
@@ -67,13 +67,12 @@ void clear_sca_new_poins_ob(struct Object *ob);
 void clear_sca_new_poins(void);
 void set_sca_new_poins_ob(struct Object *ob);
 void set_sca_new_poins(void);
-void sca_remove_ob_poin(struct Object *obt, struct Object *ob);
 
 void sca_move_sensor(struct bSensor *sens_to_move, struct Object *ob, int move_up);
 void sca_move_controller(struct bController *cont_to_move, struct Object *ob, int move_up);
 void sca_move_actuator(struct bActuator *act_to_move, struct Object *ob, int move_up);
 
-/* Callback format for performing operations on ID-pointers for Constraints */
+/* Callback format for performing operations on ID-pointers for sensors/controllers/actuators. */
 typedef void (*SCASensorIDFunc)(struct bSensor *sensor, struct ID **idpoin, void *userdata, int cd_flag);
 typedef void (*SCAControllerIDFunc)(struct bController *controller, struct ID **idpoin, void *userdata, int cd_flag);
 typedef void (*SCAActuatorIDFunc)(struct bActuator *actuator, struct ID **idpoin, void *userdata, int cd_flag);
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 14c7ace..74f1414 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -100,10 +100,11 @@ struct Scene *BKE_scene_set_name(struct Main *bmain, const char *name);
 
 struct Scene *BKE_scene_copy(struct Scene *sce, int type);
 void BKE_scene_groups_relink(struct Scene *sce);
-void BKE_scene_unlink(struct Main *bmain, struct Scene *sce, struct Scene *newsce);
 
 struct Object *BKE_scene_camera_find(struct Scene *sc);
+#ifdef DURIAN_CAMERA_SWITCH
 struct Object *BKE_scene_camera_switch_find(struct Scene *scene); // DURIAN_CAMERA_SWITCH
+#endif
 int BKE_scene_camera_switch_update(struct Scene *scene);
 
 char *BKE_scene_find_marker_name(struct Scene *scene, int frame);
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 876575a..dac53de 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -99,7 +99,7 @@ typedef struct SpaceType {
 	int (*context)(const struct bContext *, const char *, struct bContextDataResult *);
 
 	/* Used when we want to replace an ID by another (or NULL). */
-	void (*id_remap)(struct SpaceLink *, struct ID *, struct ID *);
+	void (*id_remap)(struct ScrArea *, struct SpaceLink *, struct ID *, struct ID *);
 
 	/* region type definitions */
 	ListBase regiontypes;
@@ -276,8 +276,8 @@ void BKE_spacedata_freelist(ListBase *lb);
 void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2);
 void BKE_spacedata_draw_locks(int set);
 
-void BKE_spacedata_callback_id_remap_set(void (*func)(struct SpaceLink *sl, struct ID *, struct ID *));
-void BKE_spacedata_id_unref(struct SpaceLink *sl, struct ID *id);
+void BKE_spacedata_callback_id_remap_set(void (*func)(struct ScrArea *, struct SpaceLink *, struct ID *, struct ID *));
+void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID *id);
 
 /* area/regions */
 struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 68987e2..21f01d4 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -82,70 +82,6 @@ void BKE_group_free(Group *group, const bool UNUSED(do_id_user))
 	BKE_previewimg_free(&group->preview);
 }
 
-void BKE_group_unlink(Group *group)
-{
-	Main *bmain = G.main;
-	Material *ma;
-	Object *ob;
-	Scene *sce;
-	SceneRenderLayer *srl;
-	ParticleSystem *psys;
-	
-	for (ma = bmain->mat.first; ma; ma = ma->id.next) {
-		if (ma->group == group)
-			ma->group = NULL;
-	}
-	for (ma = bmain->mat.first; ma; ma = ma->id.next) {
-		if (ma->group == group)
-			ma->group = NULL;
-	}
-	for (sce = bmain->scene.first; sce; sce = sce->id.next) {
-		Base *base = sce->base.first;
-		
-		/* ensure objects are not in this group */
-		for (; base; base = base->next) {
-			if (BKE_group_object_unlink(group, base->object, sce, base) &&
-			    BKE_group_object_find(NULL, base->object) == NULL)
-			{
-				base->object->flag &= ~OB_FROMGROUP;
-				base->flag &= ~OB_FROMGROUP;
-			}
-		}
-		
-		for (srl = sce->r.layers.first; srl; srl = srl->next) {
-			FreestyleLineSet *lineset;
-
-			if (srl->light_override == group)
-				srl->light_override = NULL;
-			for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
-				if (lineset->group == group)
-					lineset->group = NULL;
-			}
-		}
-	}
-	
-	for (ob = bmain->object.first; ob; ob = ob->id.next) {
-		
-		if (ob->dup_group == group) {


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list