diff options
author | Kevin Dietrich <kevin.dietrich@mailoo.org> | 2021-01-25 16:47:56 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-01-25 17:48:39 +0300 |
commit | 3656fc3aeecc3b92b525c2d1ea18524e7380f82b (patch) | |
tree | a5e0459d2bf565185c29ab53cb2d9f5e71e2dce2 /intern/cycles | |
parent | 2a81d948ad00c5099ecdbdf2505c8732c99a1fba (diff) |
Cleanup: move code to find geometry shaders into own function
Ref D3089
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/blender/blender_geometry.cpp | 32 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.h | 1 |
2 files changed, 21 insertions, 12 deletions
diff --git a/intern/cycles/blender/blender_geometry.cpp b/intern/cycles/blender/blender_geometry.cpp index 99df8b7b1c9..53557e0fe38 100644 --- a/intern/cycles/blender/blender_geometry.cpp +++ b/intern/cycles/blender/blender_geometry.cpp @@ -42,23 +42,12 @@ static Geometry::Type determine_geom_type(BL::Object &b_ob, bool use_particle_ha return Geometry::MESH; } -Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph, - BL::Object &b_ob, - BL::Object &b_ob_instance, - bool object_updated, - bool use_particle_hair, - TaskPool *task_pool) +array<Node *> BlenderSync::find_used_shaders(BL::Object &b_ob) { - /* Test if we can instance or if the object is modified. */ - BL::ID b_ob_data = b_ob.data(); - BL::ID b_key_id = (BKE_object_is_modified(b_ob)) ? b_ob_instance : b_ob_data; BL::Material material_override = view_layer.material_override; Shader *default_shader = (b_ob.type() == BL::Object::type_VOLUME) ? scene->default_volume : scene->default_surface; - Geometry::Type geom_type = determine_geom_type(b_ob, use_particle_hair); - GeometryKey key(b_key_id.ptr.data, geom_type); - /* Find shader indices. */ array<Node *> used_shaders; BL::Object::material_slots_iterator slot; @@ -79,6 +68,25 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph, used_shaders.push_back_slow(default_shader); } + return used_shaders; +} + +Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph, + BL::Object &b_ob, + BL::Object &b_ob_instance, + bool object_updated, + bool use_particle_hair, + TaskPool *task_pool) +{ + /* Test if we can instance or if the object is modified. */ + BL::ID b_ob_data = b_ob.data(); + BL::ID b_key_id = (BKE_object_is_modified(b_ob)) ? b_ob_instance : b_ob_data; + Geometry::Type geom_type = determine_geom_type(b_ob, use_particle_hair); + GeometryKey key(b_key_id.ptr.data, geom_type); + + /* Find shader indices. */ + array<Node *> used_shaders = find_used_shaders(b_ob); + /* Ensure we only sync instanced geometry once. */ Geometry *geom = geometry_map.find(key); if (geom) { diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index ccf059d7704..1c43522a57e 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -134,6 +134,7 @@ class BlenderSync { void sync_view(); /* Shader */ + array<Node *> find_used_shaders(BL::Object &b_ob); void sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, bool update_all); void sync_shaders(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d); void sync_nodes(Shader *shader, BL::ShaderNodeTree &b_ntree); |