diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2020-08-31 00:20:51 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2020-08-31 00:49:38 +0300 |
commit | 429afe0c626a6d608385c6bc3a348b3ac8cfa8c0 (patch) | |
tree | 3240319bcb09b1737c5b2759a3ecbdd3b45ca59f /intern/cycles/blender/blender_light.cpp | |
parent | 19363880a6770852a8f94565c162a987850d58e3 (diff) |
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
Diffstat (limited to 'intern/cycles/blender/blender_light.cpp')
-rw-r--r-- | intern/cycles/blender/blender_light.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/intern/cycles/blender/blender_light.cpp b/intern/cycles/blender/blender_light.cpp index 6f95821e31e..117e9214e5a 100644 --- a/intern/cycles/blender/blender_light.cpp +++ b/intern/cycles/blender/blender_light.cpp @@ -39,9 +39,9 @@ void BlenderSync::sync_light(BL::Object &b_parent, BL::Light b_light(b_ob.data()); /* Update if either object or light data changed. */ - if (!light_map.add_or_update(&light, b_ob, b_parent, key)) { + if (!light_map.add_or_update(scene, &light, b_ob, b_parent, key)) { Shader *shader; - if (!shader_map.add_or_update(&shader, b_light)) { + if (!shader_map.add_or_update(scene, &shader, b_light)) { if (light->is_portal) *use_portal = true; return; @@ -176,7 +176,7 @@ void BlenderSync::sync_background_light(BL::SpaceView3D &b_v3d, bool use_portal) Light *light; ObjectKey key(b_world, 0, b_world, false); - if (light_map.add_or_update(&light, b_world, b_world, key) || world_recalc || + if (light_map.add_or_update(scene, &light, b_world, b_world, key) || world_recalc || b_world.ptr.data != world_map) { light->type = LIGHT_BACKGROUND; if (sampling_method == SAMPLING_MANUAL) { |