Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2016-06-22 18:29:38 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-06-22 18:53:50 +0300
commit897e97f078e64e5ee5fbbd929fd1e46240371ef4 (patch)
tree1450381a5bf063cd5d935df58ee36548d9c54af7 /source/blender/blenkernel/intern/scene.c
parent73cfbb0ab937d837a40a03765108b3af11606b7c (diff)
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock was pretty much impossible, except for a few special cases. Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite a few ID usages were missed or wrongly handled that way). One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling by using library_query utils to allow generic handling of those, which is now the case (now, generic ID links handling is only "knwon" from readfile.c and library_query.c). This commit also adds backends to allow live replacement and deletion of datablocks in Blender (so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one, or NULL one in case of unlinking). This will allow nice new features, like ability to easily reload or relocate libraries, real immediate deletion of datablocks in blender, replacement of one datablock by another, etc. Some of those are for next commits. A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core. Though it was tested rather deeply, being totally impossible to check all possible ID usage cases, it's likely there are some remaining issues and bugs in new code... Please report them! ;) Review task: D2027 (https://developer.blender.org/D2027). Reviewed by campbellbarton, thanks a bunch.
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r--source/blender/blenkernel/intern/scene.c86
1 files changed, 20 insertions, 66 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index a3393b6b9c0..0e8efca04d0 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -357,41 +357,34 @@ void BKE_scene_groups_relink(Scene *sce)
BKE_rigidbody_world_groups_relink(sce->rigidbody_world);
}
-/* do not free scene itself */
+/** Free (or release) any data used by this scene (does not free the scene itself). */
void BKE_scene_free(Scene *sce)
{
- Base *base;
SceneRenderLayer *srl;
+ BKE_animdata_free((ID *)sce, false);
+
/* check all sequences */
BKE_sequencer_clear_scene_in_allseqs(G.main, sce);
- base = sce->base.first;
- while (base) {
- id_us_min(&base->object->id);
- base = base->next;
- }
- /* do not free objects! */
-
- if (sce->gpd) {
-#if 0 /* removed since this can be invalid memory when freeing everything */
- /* since the grease pencil data is freed before the scene.
- * since grease pencil data is not (yet?), shared between objects
- * its probably safe not to do this, some save and reload will free this. */
- id_us_min(&sce->gpd->id);
-#endif
- sce->gpd = NULL;
- }
-
+ sce->basact = NULL;
BLI_freelistN(&sce->base);
BKE_sequencer_editing_free(sce);
- BKE_animdata_free((ID *)sce);
BKE_keyingsets_free(&sce->keyingsets);
-
- if (sce->rigidbody_world)
+
+ /* is no lib link block, but scene extension */
+ if (sce->nodetree) {
+ ntreeFreeTree(sce->nodetree);
+ MEM_freeN(sce->nodetree);
+ sce->nodetree = NULL;
+ }
+
+ if (sce->rigidbody_world) {
BKE_rigidbody_free_world(sce->rigidbody_world);
-
+ sce->rigidbody_world = NULL;
+ }
+
if (sce->r.avicodecdata) {
free_avicodecdata(sce->r.avicodecdata);
MEM_freeN(sce->r.avicodecdata);
@@ -444,15 +437,8 @@ void BKE_scene_free(Scene *sce)
if (sce->depsgraph)
DEG_graph_free(sce->depsgraph);
- if (sce->nodetree) {
- ntreeFreeTree(sce->nodetree);
- MEM_freeN(sce->nodetree);
- }
-
- if (sce->stats)
- MEM_freeN(sce->stats);
- if (sce->fps_info)
- MEM_freeN(sce->fps_info);
+ MEM_SAFE_FREE(sce->stats);
+ MEM_SAFE_FREE(sce->fps_info);
BKE_sound_destroy_scene(sce);
@@ -904,40 +890,6 @@ Scene *BKE_scene_set_name(Main *bmain, const char *name)
return NULL;
}
-void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce)
-{
- Scene *sce1;
- bScreen *screen;
-
- /* check all sets */
- for (sce1 = bmain->scene.first; sce1; sce1 = sce1->id.next)
- if (sce1->set == sce)
- sce1->set = NULL;
-
- for (sce1 = bmain->scene.first; sce1; sce1 = sce1->id.next) {
- bNode *node;
-
- if (sce1 == sce || !sce1->nodetree)
- continue;
-
- for (node = sce1->nodetree->nodes.first; node; node = node->next) {
- if (node->id == &sce->id)
- node->id = NULL;
- }
- }
-
- /* all screens */
- for (screen = bmain->screen.first; screen; screen = screen->id.next) {
- if (screen->scene == sce) {
- screen->scene = newsce;
- }
-
- /* editors are handled by WM_main_remove_editor_id_reference */
- }
-
- BKE_libblock_free(bmain, sce);
-}
-
/* Used by metaballs, return *all* objects (including duplis) existing in the scene (including scene's sets) */
int BKE_scene_base_iter_next(EvaluationContext *eval_ctx, SceneBaseIter *iter,
Scene **scene, int val, Base **base, Object **ob)
@@ -1193,6 +1145,8 @@ void BKE_scene_base_unlink(Scene *sce, Base *base)
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)