diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-05-30 16:21:21 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-05-30 19:17:49 +0300 |
commit | 17ce968c5972573df67c578b068f02f8b1478846 (patch) | |
tree | e2ea7492d1f39b3b9be4d2f4345688f52cd898f2 /intern/cycles | |
parent | 08862b8246b49331ddfb7ed6812c9e31989bf8b1 (diff) |
Depsgraph API: renaming, more granular update information.
* depsgraph.ids: all evaluated datablocks in the depsgraph
* depsgraph.objects: all evaluated objects in the depsgraph
* depsgraph.object_instances: all object instances to display or render
* depsgraph.updates: list of updates to datablocks
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/blender/blender_object.cpp | 37 | ||||
-rw-r--r-- | intern/cycles/blender/blender_particles.cpp | 8 | ||||
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.cpp | 40 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.h | 4 |
5 files changed, 53 insertions, 42 deletions
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index 090682c8e14..3c38c7a4584 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -278,25 +278,25 @@ void BlenderSync::sync_background_light(bool use_portal) /* Object */ Object *BlenderSync::sync_object(BL::Depsgraph& b_depsgraph, - BL::Depsgraph::duplis_iterator& b_dupli_iter, + BL::DepsgraphObjectInstance& b_instance, uint layer_flag, float motion_time, bool hide_tris, BlenderObjectCulling& culling, bool *use_portal) { - const bool is_instance = b_dupli_iter->is_instance(); - BL::Object b_ob = b_dupli_iter->object(); - BL::Object b_parent = is_instance ? b_dupli_iter->parent() - : b_dupli_iter->object(); - BL::Object b_ob_instance = is_instance ? b_dupli_iter->instance_object() + const bool is_instance = b_instance.is_instance(); + BL::Object b_ob = b_instance.object(); + BL::Object b_parent = is_instance ? b_instance.parent() + : b_instance.object(); + BL::Object b_ob_instance = is_instance ? b_instance.instance_object() : b_ob; const bool motion = motion_time != 0.0f; /*const*/ Transform tfm = get_transform(b_ob.matrix_world()); int *persistent_id = NULL; BL::Array<int, OBJECT_PERSISTENT_ID_SIZE> persistent_id_array; if(is_instance) { - persistent_id_array = b_dupli_iter->persistent_id(); + persistent_id_array = b_instance.persistent_id(); persistent_id = persistent_id_array.data; } @@ -310,7 +310,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph& b_depsgraph, persistent_id, b_ob, b_ob_instance, - is_instance ? b_dupli_iter->random_id() : 0, + is_instance ? b_instance.random_id() : 0, tfm, use_portal); } @@ -448,12 +448,12 @@ Object *BlenderSync::sync_object(BL::Depsgraph& b_depsgraph, /* dupli texture coordinates and random_id */ if(is_instance) { - object->dupli_generated = 0.5f*get_float3(b_dupli_iter->orco()) - make_float3(0.5f, 0.5f, 0.5f); - object->dupli_uv = get_float2(b_dupli_iter->uv()); - object->random_id = b_dupli_iter->random_id(); + object->dupli_generated = 0.5f*get_float3(b_instance.orco()) - make_float3(0.5f, 0.5f, 0.5f); + object->dupli_uv = get_float2(b_instance.uv()); + object->random_id = b_instance.random_id(); /* Sync possible particle data. */ - sync_dupli_particle(b_ob, *b_dupli_iter, object); + sync_dupli_particle(b_ob, b_instance, object); } else { object->dupli_generated = make_float3(0.0f, 0.0f, 0.0f); @@ -563,12 +563,13 @@ void BlenderSync::sync_objects(BL::Depsgraph& b_depsgraph, float motion_time) bool cancel = false; bool use_portal = false; - BL::Depsgraph::duplis_iterator b_dupli_iter; - for(b_depsgraph.duplis.begin(b_dupli_iter); - b_dupli_iter != b_depsgraph.duplis.end() && !cancel; - ++b_dupli_iter) + BL::Depsgraph::object_instances_iterator b_instance_iter; + for(b_depsgraph.object_instances.begin(b_instance_iter); + b_instance_iter != b_depsgraph.object_instances.end() && !cancel; + ++b_instance_iter) { - BL::Object b_ob = b_dupli_iter->object(); + BL::DepsgraphObjectInstance b_instance = *b_instance_iter; + BL::Object b_ob = b_instance.object(); if(!b_ob.is_visible()) { continue; } @@ -584,7 +585,7 @@ void BlenderSync::sync_objects(BL::Depsgraph& b_depsgraph, float motion_time) if(!object_render_hide(b_ob, true, true, hide_tris)) { /* object itself */ sync_object(b_depsgraph, - b_dupli_iter, + b_instance, ~(0), /* until we get rid of layers */ motion_time, hide_tris, diff --git a/intern/cycles/blender/blender_particles.cpp b/intern/cycles/blender/blender_particles.cpp index e365061722e..bb8e2e1398e 100644 --- a/intern/cycles/blender/blender_particles.cpp +++ b/intern/cycles/blender/blender_particles.cpp @@ -28,11 +28,11 @@ CCL_NAMESPACE_BEGIN /* Utilities */ bool BlenderSync::sync_dupli_particle(BL::Object& b_ob, - BL::DepsgraphIter& b_dup, + BL::DepsgraphObjectInstance& b_instance, Object *object) { /* test if this dupli was generated from a particle sytem */ - BL::ParticleSystem b_psys = b_dup.particle_system(); + BL::ParticleSystem b_psys = b_instance.particle_system(); if(!b_psys) return false; @@ -43,7 +43,7 @@ bool BlenderSync::sync_dupli_particle(BL::Object& b_ob, return false; /* don't handle child particles yet */ - BL::Array<int, OBJECT_PERSISTENT_ID_SIZE> persistent_id = b_dup.persistent_id(); + BL::Array<int, OBJECT_PERSISTENT_ID_SIZE> persistent_id = b_instance.persistent_id(); if(persistent_id[0] >= b_psys.particles.length()) return false; @@ -53,7 +53,7 @@ bool BlenderSync::sync_dupli_particle(BL::Object& b_ob, ParticleSystem *psys; bool first_use = !particle_system_map.is_used(key); - bool need_update = particle_system_map.sync(&psys, b_ob, b_dup.object(), key); + bool need_update = particle_system_map.sync(&psys, b_ob, b_instance.object(), key); /* no update needed? */ if(!need_update && !object->mesh->need_update && !scene->object_manager->need_update) diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index e991533a17e..740416e3a8a 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -659,7 +659,9 @@ static ShaderNode *add_node(Scene *scene, image->animated = b_image_node.image_user().use_auto_refresh(); image->use_alpha = b_image.use_alpha(); + /* TODO: restore */ /* TODO(sergey): Does not work properly when we change builtin type. */ +#if 0 if(b_image.is_updated()) { scene->image_manager->tag_reload_image( image->filename.string(), @@ -668,6 +670,7 @@ static ShaderNode *add_node(Scene *scene, get_image_extension(b_image_node), image->use_alpha); } +#endif } image->color_space = (NodeImageColorSpace)b_image_node.color_space(); image->projection = (NodeImageProjection)b_image_node.projection(); @@ -707,7 +710,9 @@ static ShaderNode *add_node(Scene *scene, env->animated = b_env_node.image_user().use_auto_refresh(); env->use_alpha = b_image.use_alpha(); + /* TODO: restore */ /* TODO(sergey): Does not work properly when we change builtin type. */ +#if 0 if(b_image.is_updated()) { scene->image_manager->tag_reload_image( env->filename.string(), @@ -716,6 +721,7 @@ static ShaderNode *add_node(Scene *scene, EXTENSION_REPEAT, env->use_alpha); } +#endif } env->color_space = (NodeImageColorSpace)b_env_node.color_space(); env->interpolation = get_image_interpolation(b_env_node); diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index e54fe1246dc..0c27786f241 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -104,28 +104,32 @@ void BlenderSync::sync_recalc(BL::Depsgraph& b_depsgraph) } /* Iterate over all IDs in this depsgraph. */ - BL::Depsgraph::ids_updated_iterator b_id; - for(b_depsgraph.ids_updated.begin(b_id); b_id != b_depsgraph.ids_updated.end(); ++b_id) { + BL::Depsgraph::updates_iterator b_update; + for(b_depsgraph.updates.begin(b_update); b_update != b_depsgraph.updates.end(); ++b_update) { + BL::ID b_id(b_update->id()); + /* Material */ - if (b_id->is_a(&RNA_Material)) { - BL::Material b_mat(*b_id); + if (b_id.is_a(&RNA_Material)) { + BL::Material b_mat(b_id); shader_map.set_recalc(b_mat); } /* Lamp */ - else if (b_id->is_a(&RNA_Lamp)) { - BL::Lamp b_lamp(*b_id); + else if (b_id.is_a(&RNA_Lamp)) { + BL::Lamp b_lamp(b_id); shader_map.set_recalc(b_lamp); } /* Object */ - else if (b_id->is_a(&RNA_Object)) { - BL::Object b_ob(*b_id); - const bool updated_data = b_ob.is_updated_data(); + else if (b_id.is_a(&RNA_Object)) { + BL::Object b_ob(b_id); + const bool updated_geometry = b_update->updated_geometry(); - object_map.set_recalc(b_ob); - light_map.set_recalc(b_ob); + if (b_update->updated_transform()) { + object_map.set_recalc(b_ob); + light_map.set_recalc(b_ob); + } if(object_is_mesh(b_ob)) { - if(updated_data || + if(updated_geometry || (dicing_prop_changed && object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) { BL::ID key = BKE_object_is_modified(b_ob)? b_ob: b_ob.data(); @@ -133,25 +137,25 @@ void BlenderSync::sync_recalc(BL::Depsgraph& b_depsgraph) } } else if(object_is_light(b_ob)) { - if(updated_data) { + if(updated_geometry) { light_map.set_recalc(b_ob); } } - if(updated_data) { + 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); } } /* Mesh */ - else if (b_id->is_a(&RNA_Mesh)) { - BL::Mesh b_mesh(*b_id); + else if (b_id.is_a(&RNA_Mesh)) { + BL::Mesh b_mesh(b_id); mesh_map.set_recalc(b_mesh); } /* World */ - else if (b_id->is_a(&RNA_World)) { - BL::World b_world(*b_id); + else if (b_id.is_a(&RNA_World)) { + BL::World b_world(b_id); if(world_map == b_world.ptr.data) { world_recalc = true; } diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index e2286ffc753..77ee590335c 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -126,7 +126,7 @@ private: bool motion, int motion_step = 0); Object *sync_object(BL::Depsgraph& b_depsgraph, - BL::Depsgraph::duplis_iterator& b_dupli_iter, + BL::DepsgraphObjectInstance& b_instance, uint layer_flag, float motion_time, bool hide_tris, @@ -151,7 +151,7 @@ private: /* particles */ bool sync_dupli_particle(BL::Object& b_ob, - BL::DepsgraphIter& b_dup, + BL::DepsgraphObjectInstance& b_instance, Object *object); /* Images. */ |