diff options
author | Brecht Van Lommel <brecht@blender.org> | 2020-07-09 19:54:42 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-07-10 18:10:05 +0300 |
commit | e65c78cd43aa8d50612365f6b506de53d1bbfd86 (patch) | |
tree | 2a557cb12b1bced635c02cb66e5267d8d9965902 /intern/cycles/blender | |
parent | ad45b8d6a439f131bae545e054ba5e31a95bb0ea (diff) |
Cleanup: minor refactoring in Cycles update detection code
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/blender_object.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.cpp | 53 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.h | 2 |
3 files changed, 36 insertions, 23 deletions
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index d3a37563ef4..3ea6892a349 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -59,7 +59,7 @@ bool BlenderSync::BKE_object_is_modified(BL::Object &b_ob) return false; } -bool BlenderSync::object_is_mesh(BL::Object &b_ob) +bool BlenderSync::object_is_geometry(BL::Object &b_ob) { BL::ID b_ob_data = b_ob.data(); @@ -143,7 +143,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph, } /* only interested in object that we can create meshes from */ - if (!object_is_mesh(b_ob)) { + if (!object_is_geometry(b_ob)) { return NULL; } diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index bf065cc5492..ee2445e44c4 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -147,30 +147,43 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d /* Object */ else if (b_id.is_a(&RNA_Object)) { BL::Object b_ob(b_id); - const bool updated_geometry = b_update->is_updated_geometry(); + const bool is_geometry = object_is_geometry(b_ob); + const bool is_light = !is_geometry && object_is_light(b_ob); - if (b_update->is_updated_transform() || b_update->is_updated_shading()) { - object_map.set_recalc(b_ob); - light_map.set_recalc(b_ob); - } + if (is_geometry || is_light) { + const bool updated_geometry = b_update->is_updated_geometry(); - if (object_is_mesh(b_ob)) { - if (updated_geometry || - (object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) { - BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data(); - geometry_map.set_recalc(key); - } - } - else if (object_is_light(b_ob)) { - if (updated_geometry) { - light_map.set_recalc(b_ob); + /* Geometry (mesh, hair, volume). */ + if (is_geometry) { + if (b_update->is_updated_transform() || b_update->is_updated_shading()) { + object_map.set_recalc(b_ob); + } + + if (updated_geometry || + (object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) { + BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data(); + geometry_map.set_recalc(key); + } + + if (updated_geometry) { + BL::Object::particle_systems_iterator b_psys; + for (b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end(); + ++b_psys) { + particle_system_map.set_recalc(b_ob); + } + } } - } + /* Light */ + else if (is_light) { + if (b_update->is_updated_transform() || b_update->is_updated_shading()) { + object_map.set_recalc(b_ob); + light_map.set_recalc(b_ob); + } - if (updated_geometry) { - BL::Object::particle_systems_iterator b_psys; - for (b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end(); ++b_psys) - particle_system_map.set_recalc(b_ob); + if (updated_geometry) { + light_map.set_recalc(b_ob); + } + } } } /* Mesh */ diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 0214d9eb3b8..a551ec31e04 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -208,7 +208,7 @@ class BlenderSync { /* util */ void find_shader(BL::ID &id, vector<Shader *> &used_shaders, Shader *default_shader); bool BKE_object_is_modified(BL::Object &b_ob); - bool object_is_mesh(BL::Object &b_ob); + bool object_is_geometry(BL::Object &b_ob); bool object_is_light(BL::Object &b_ob); /* variables */ |