diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2020-10-29 16:40:29 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2020-10-29 19:39:21 +0300 |
commit | 8c3d42bd0f0160ba58c6a932c0e4c228ce6b0426 (patch) | |
tree | a9e020a29c532c227e0a7be9d9c33411e4b8a807 /intern/cycles/blender/blender_id_map.h | |
parent | 2e41db5277a5f90250f398ef3ea8777118dc34ee (diff) |
Fix T82129: Cycles "Persistent Images" incorrectly retains scene data
The issue stems from the fact that scene arrays are not cleared when rendering is done. This was not really an issue before the introduction of the ownership system (rB429afe0c626a) as the id_map would recreate scene data arrays based on their new content. However, now that the id_maps do not have access to the scene data anymore the arrays are never created.
Another related issue is that the BlenderSync instance is never freed when the persistent data option is activated.
To fix this, we delete nodes created by the id_maps in their destructors, and delete the BlenderSync instance before creating a new one, so the id_maps destructors are actually called.
Reviewed By: brecht
Maniphest Tasks: T82129
Differential Revision: https://developer.blender.org/D9378
Diffstat (limited to 'intern/cycles/blender/blender_id_map.h')
-rw-r--r-- | intern/cycles/blender/blender_id_map.h | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/intern/cycles/blender/blender_id_map.h b/intern/cycles/blender/blender_id_map.h index 8ce1d23665d..198cfb4b29a 100644 --- a/intern/cycles/blender/blender_id_map.h +++ b/intern/cycles/blender/blender_id_map.h @@ -35,10 +35,22 @@ CCL_NAMESPACE_BEGIN template<typename K, typename T> class id_map { public: - id_map() + id_map(Scene *scene_) : scene(scene_) { } + ~id_map() + { + set<T *> nodes; + + typename map<K, T *>::iterator jt; + for (jt = b_map.begin(); jt != b_map.end(); jt++) { + nodes.insert(jt->second); + } + + scene->delete_nodes(nodes); + } + T *find(const BL::ID &id) { return find(id.ptr.owner_id); @@ -98,16 +110,15 @@ template<typename K, typename T> class id_map { } /* Combined add and update as needed. */ - bool add_or_update(Scene *scene, T **r_data, const BL::ID &id) + bool add_or_update(T **r_data, const BL::ID &id) { - return add_or_update(scene, r_data, id, id, id.ptr.owner_id); + return add_or_update(r_data, id, id, id.ptr.owner_id); } - bool add_or_update(Scene *scene, T **r_data, const BL::ID &id, const K &key) + bool add_or_update(T **r_data, const BL::ID &id, const K &key) { - return add_or_update(scene, r_data, id, id, key); + return add_or_update(r_data, id, id, key); } - bool add_or_update( - Scene *scene, T **r_data, const BL::ID &id, const BL::ID &parent, const K &key) + bool add_or_update(T **r_data, const BL::ID &id, const BL::ID &parent, const K &key) { T *data = find(key); bool recalc; @@ -146,7 +157,7 @@ template<typename K, typename T> class id_map { b_map[NULL] = data; } - void post_sync(Scene *scene, bool do_delete = true) + void post_sync(bool do_delete = true) { map<K, T *> new_map; typedef pair<const K, T *> TMapPair; @@ -177,6 +188,7 @@ template<typename K, typename T> class id_map { map<K, T *> b_map; set<T *> used_set; set<void *> b_recalc; + Scene *scene; }; /* Object Key |