From 17ce968c5972573df67c578b068f02f8b1478846 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 30 May 2018 15:21:21 +0200 Subject: 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 --- intern/cycles/blender/blender_object.cpp | 37 ++--- intern/cycles/blender/blender_particles.cpp | 8 +- intern/cycles/blender/blender_shader.cpp | 6 + intern/cycles/blender/blender_sync.cpp | 40 +++--- intern/cycles/blender/blender_sync.h | 4 +- source/blender/makesrna/RNA_access.h | 4 +- source/blender/makesrna/intern/rna_ID.c | 35 ----- source/blender/makesrna/intern/rna_depsgraph.c | 190 +++++++++++++++++-------- source/blender/makesrna/intern/rna_object.c | 65 --------- 9 files changed, 183 insertions(+), 206 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 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 persistent_id = b_dup.persistent_id(); + BL::Array 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. */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 1cd907aeb91..4b88cace319 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -210,7 +210,8 @@ extern StructRNA RNA_CurveMapping; extern StructRNA RNA_CurveModifier; extern StructRNA RNA_CurvePoint; extern StructRNA RNA_Depsgraph; -extern StructRNA RNA_DepsgraphIter; +extern StructRNA RNA_DepsgraphObjectInstance; +extern StructRNA RNA_DepsgraphUpdate; extern StructRNA RNA_DampedTrackConstraint; extern StructRNA RNA_DataTransferModifier; extern StructRNA RNA_DecimateModifier; @@ -225,7 +226,6 @@ extern StructRNA RNA_DopeSheet; extern StructRNA RNA_Driver; extern StructRNA RNA_DriverTarget; extern StructRNA RNA_DriverVariable; -extern StructRNA RNA_DupliObject; extern StructRNA RNA_DynamicPaintBrushSettings; extern StructRNA RNA_DynamicPaintCanvasSettings; extern StructRNA RNA_DynamicPaintModifier; diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 3f0ee5f2a35..5b69f202bb4 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -797,31 +797,6 @@ static PointerRNA rna_IDPreview_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_ImagePreview, prv_img); } -static int rna_ID_is_updated_get(PointerRNA *ptr) -{ - ID *id = (ID *)ptr->data; - /* TODO(sergey): Do we need to limit some of flags here? */ - return ((id->recalc & ID_RECALC_ALL) != 0); -} - -static int rna_ID_is_updated_data_get(PointerRNA *ptr) -{ - /* TODO: replace with more generic granular recalc flags. */ - ID *id = (ID *)ptr->data; - if (GS(id->name) != ID_OB) { - return false; - } - if (id->recalc & ID_RECALC_GEOMETRY) { - return true; - } - Object *object = (Object *)id; - ID *data = object->data; - if (data == NULL) { - return 0; - } - return ((data->recalc & ID_RECALC_ALL) != 0); -} - static IDProperty *rna_IDPropertyWrapPtr_idprops(PointerRNA *ptr, bool UNUSED(create)) { if (ptr == NULL) { @@ -1174,16 +1149,6 @@ static void rna_def_ID(BlenderRNA *brna) "Tools can use this to tag data for their own purposes " "(initial state is undefined)"); - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_ID_is_updated_get", NULL); - RNA_def_property_ui_text(prop, "Is Updated", "Data-block is tagged for recalculation"); - - prop = RNA_def_property(srna, "is_updated_data", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_ID_is_updated_data_get", NULL); - RNA_def_property_ui_text(prop, "Is Updated Data", "Data-block data is tagged for recalculation"); - prop = RNA_def_property(srna, "is_library_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "tag", LIB_TAG_INDIRECT); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c index 64dfd70d990..8bfa8b7d551 100644 --- a/source/blender/makesrna/intern/rna_depsgraph.c +++ b/source/blender/makesrna/intern/rna_depsgraph.c @@ -50,15 +50,15 @@ #include "MEM_guardedalloc.h" -/* **************** Depsgraph **************** */ +/* **************** Object Instance **************** */ -static PointerRNA rna_DepsgraphIter_object_get(PointerRNA *ptr) +static PointerRNA rna_DepsgraphObjectInstance_object_get(PointerRNA *ptr) { BLI_Iterator *iterator = ptr->data; return rna_pointer_inherit_refine(ptr, &RNA_Object, iterator->current); } -static PointerRNA rna_DepsgraphIter_instance_object_get(PointerRNA *ptr) +static PointerRNA rna_DepsgraphObjectInstance_instance_object_get(PointerRNA *ptr) { BLI_Iterator *iterator = ptr->data; DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; @@ -69,7 +69,7 @@ static PointerRNA rna_DepsgraphIter_instance_object_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_Object, instance_object); } -static PointerRNA rna_DepsgraphIter_parent_get(PointerRNA *ptr) +static PointerRNA rna_DepsgraphObjectInstance_parent_get(PointerRNA *ptr) { BLI_Iterator *iterator = ptr->data; DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; @@ -80,7 +80,7 @@ static PointerRNA rna_DepsgraphIter_parent_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_Object, dupli_parent); } -static PointerRNA rna_DepsgraphIter_particle_system_get(PointerRNA *ptr) +static PointerRNA rna_DepsgraphObjectInstance_particle_system_get(PointerRNA *ptr) { BLI_Iterator *iterator = ptr->data; DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; @@ -88,7 +88,7 @@ static PointerRNA rna_DepsgraphIter_particle_system_get(PointerRNA *ptr) deg_iter->dupli_object_current->particle_system); } -static void rna_DepsgraphIter_persistent_id_get(PointerRNA *ptr, int *persistent_id) +static void rna_DepsgraphObjectInstance_persistent_id_get(PointerRNA *ptr, int *persistent_id) { BLI_Iterator *iterator = ptr->data; DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; @@ -96,7 +96,7 @@ static void rna_DepsgraphIter_persistent_id_get(PointerRNA *ptr, int *persistent sizeof(deg_iter->dupli_object_current->persistent_id)); } -static void rna_DepsgraphIter_orco_get(PointerRNA *ptr, float *orco) +static void rna_DepsgraphObjectInstance_orco_get(PointerRNA *ptr, float *orco) { BLI_Iterator *iterator = ptr->data; DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; @@ -104,14 +104,14 @@ static void rna_DepsgraphIter_orco_get(PointerRNA *ptr, float *orco) sizeof(deg_iter->dupli_object_current->orco)); } -static unsigned int rna_DepsgraphIter_random_id_get(PointerRNA *ptr) +static unsigned int rna_DepsgraphObjectInstance_random_id_get(PointerRNA *ptr) { BLI_Iterator *iterator = ptr->data; DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; return deg_iter->dupli_object_current->random_id; } -static void rna_DepsgraphIter_uv_get(PointerRNA *ptr, float *uv) +static void rna_DepsgraphObjectInstance_uv_get(PointerRNA *ptr, float *uv) { BLI_Iterator *iterator = ptr->data; DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; @@ -119,13 +119,43 @@ static void rna_DepsgraphIter_uv_get(PointerRNA *ptr, float *uv) sizeof(deg_iter->dupli_object_current->uv)); } -static int rna_DepsgraphIter_is_instance_get(PointerRNA *ptr) +static int rna_DepsgraphObjectInstance_is_instance_get(PointerRNA *ptr) { BLI_Iterator *iterator = ptr->data; DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; return (deg_iter->dupli_object_current != NULL); } +/* ******************** Updates ***************** */ + +static PointerRNA rna_DepsgraphUpdate_id_get(PointerRNA *ptr) +{ + return rna_pointer_inherit_refine(ptr, &RNA_ID, ptr->data); +} + +static int rna_DepsgraphUpdate_updated_transform_get(PointerRNA *ptr) +{ + ID *id = ptr->data; + return ((id->recalc & ID_RECALC_TRANSFORM) != 0); +} + +static int rna_DepsgraphUpdate_updated_geometry_get(PointerRNA *ptr) +{ + ID *id = ptr->data; + if (id->recalc & ID_RECALC_GEOMETRY) { + return true; + } + if (GS(id->name) != ID_OB) { + return false; + } + Object *object = (Object *)id; + ID *data = object->data; + if (data == NULL) { + return 0; + } + return ((data->recalc & ID_RECALC_ALL) != 0); +} + /* **************** Depsgraph **************** */ static void rna_Depsgraph_debug_relations_graphviz(Depsgraph *depsgraph, @@ -207,7 +237,7 @@ static PointerRNA rna_Depsgraph_objects_get(CollectionPropertyIterator *iter) * Contains extra information about duplicator and persistent ID. */ -static void rna_Depsgraph_duplis_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_Depsgraph_object_instances_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__); DEGObjectIterData *data = MEM_callocN(sizeof(DEGObjectIterData), __func__); @@ -224,23 +254,23 @@ static void rna_Depsgraph_duplis_begin(CollectionPropertyIterator *iter, Pointer iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; } -static void rna_Depsgraph_duplis_next(CollectionPropertyIterator *iter) +static void rna_Depsgraph_object_instances_next(CollectionPropertyIterator *iter) { DEG_iterator_objects_next(iter->internal.custom); iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; } -static void rna_Depsgraph_duplis_end(CollectionPropertyIterator *iter) +static void rna_Depsgraph_object_instances_end(CollectionPropertyIterator *iter) { DEG_iterator_objects_end(iter->internal.custom); MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data); MEM_freeN(iter->internal.custom); } -static PointerRNA rna_Depsgraph_duplis_get(CollectionPropertyIterator *iter) +static PointerRNA rna_Depsgraph_object_instances_get(CollectionPropertyIterator *iter) { BLI_Iterator *iterator = (BLI_Iterator *)iter->internal.custom; - return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphIter, iterator); + return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphObjectInstance, iterator); } /* Iteration over evaluated IDs */ @@ -257,19 +287,6 @@ static void rna_Depsgraph_ids_begin(CollectionPropertyIterator *iter, PointerRNA iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; } -static void rna_Depsgraph_ids_updated_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__); - DEGIDIterData *data = MEM_callocN(sizeof(DEGIDIterData), __func__); - - data->graph = (Depsgraph *)ptr->data; - data->only_updated = true; - - ((BLI_Iterator *)iter->internal.custom)->valid = true; - DEG_iterator_ids_begin(iter->internal.custom, data); - iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; -} - static void rna_Depsgraph_ids_next(CollectionPropertyIterator *iter) { DEG_iterator_ids_next(iter->internal.custom); @@ -289,6 +306,25 @@ static PointerRNA rna_Depsgraph_ids_get(CollectionPropertyIterator *iter) return rna_pointer_inherit_refine(&iter->parent, &RNA_ID, id); } +static void rna_Depsgraph_updates_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__); + DEGIDIterData *data = MEM_callocN(sizeof(DEGIDIterData), __func__); + + data->graph = (Depsgraph *)ptr->data; + data->only_updated = true; + + ((BLI_Iterator *)iter->internal.custom)->valid = true; + DEG_iterator_ids_begin(iter->internal.custom, data); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; +} + +static PointerRNA rna_Depsgraph_updates_get(CollectionPropertyIterator *iter) +{ + ID *id = ((BLI_Iterator *)iter->internal.custom)->current; + return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphUpdate, id); +} + static ID *rna_Depsgraph_id_eval_get(Depsgraph *depsgraph, ID *id_orig) { return DEG_get_evaluated_id(depsgraph, id_orig); @@ -329,45 +365,45 @@ static PointerRNA rna_Depsgraph_view_layer_eval_get(PointerRNA *ptr) #else -static void rna_def_depsgraph_iter(BlenderRNA *brna) +static void rna_def_depsgraph_instance(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "DepsgraphIter", NULL); - RNA_def_struct_ui_text(srna, "Dependency Graph Iterator", + srna = RNA_def_struct(brna, "DepsgraphObjectInstance", NULL); + RNA_def_struct_ui_text(srna, "Dependency Graph Object Instance", "Extended information about dependency graph object iterator"); prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Object", "Object the iterator points to"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_pointer_funcs(prop, "rna_DepsgraphIter_object_get", NULL, NULL, NULL); + RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_object_get", NULL, NULL, NULL); prop = RNA_def_property(srna, "instance_object", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Instance Object", "Object which is being instanced by this iterator"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_pointer_funcs(prop, "rna_DepsgraphIter_instance_object_get", NULL, NULL, NULL); + RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_instance_object_get", NULL, NULL, NULL); prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Parent", "Parent of the duplication list"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_pointer_funcs(prop, "rna_DepsgraphIter_parent_get", NULL, NULL, NULL); + RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_parent_get", NULL, NULL, NULL); prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ParticleSystem"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); RNA_def_property_ui_text(prop, "Particle System", "Particle system that this object was instanced from"); - RNA_def_property_pointer_funcs(prop, "rna_DepsgraphIter_particle_system_get", NULL, NULL, NULL); + RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_particle_system_get", NULL, NULL, NULL); prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE); RNA_def_property_ui_text(prop, "Persistent ID", "Persistent identifier for inter-frame matching of objects with motion blur"); RNA_def_property_array(prop, 2 * MAX_DUPLI_RECUR); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_int_funcs(prop, "rna_DepsgraphIter_persistent_id_get", NULL, NULL); + RNA_def_property_int_funcs(prop, "rna_DepsgraphObjectInstance_persistent_id_get", NULL, NULL); prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); @@ -376,23 +412,49 @@ static void rna_def_depsgraph_iter(BlenderRNA *brna) */ RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Generated Coordinates", "Generated coordinates in parent object space"); - RNA_def_property_float_funcs(prop, "rna_DepsgraphIter_orco_get", NULL, NULL); + RNA_def_property_float_funcs(prop, "rna_DepsgraphObjectInstance_orco_get", NULL, NULL); prop = RNA_def_property(srna, "random_id", PROP_INT, PROP_UNSIGNED); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); RNA_def_property_ui_text(prop, "Dupli random id", "Random id for this dupli object"); - RNA_def_property_int_funcs(prop, "rna_DepsgraphIter_random_id_get", NULL, NULL); + RNA_def_property_int_funcs(prop, "rna_DepsgraphObjectInstance_random_id_get", NULL, NULL); prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space"); RNA_def_property_array(prop, 2); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_float_funcs(prop, "rna_DepsgraphIter_uv_get", NULL, NULL); + RNA_def_property_float_funcs(prop, "rna_DepsgraphObjectInstance_uv_get", NULL, NULL); prop = RNA_def_property(srna, "is_instance", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Is Instance", "Denotes whether the object is ocming from dupli-list"); - RNA_def_property_boolean_funcs(prop, "rna_DepsgraphIter_is_instance_get", NULL); + RNA_def_property_ui_text(prop, "Is Instance", "Denotes whether the object is coming from dupli-list"); + RNA_def_property_boolean_funcs(prop, "rna_DepsgraphObjectInstance_is_instance_get", NULL); +} + +static void rna_def_depsgraph_update(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "DepsgraphUpdate", NULL); + RNA_def_struct_ui_text(srna, "Dependency Graph Update", + "Information about ID that was updated"); + + prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ID"); + RNA_def_property_ui_text(prop, "ID", "Updated datablock"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, "rna_DepsgraphUpdate_id_get", NULL, NULL, NULL); + + prop = RNA_def_property(srna, "updated_transform", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Transform", "Object transformation was updated"); + RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_updated_transform_get", NULL); + + prop = RNA_def_property(srna, "updated_geometry", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Geometry", "Object geometry was updated"); + RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_updated_geometry_get", NULL); } static void rna_def_depsgraph(BlenderRNA *brna) @@ -471,6 +533,16 @@ static void rna_def_depsgraph(BlenderRNA *brna) /* Iterators. */ + prop = RNA_def_property(srna, "ids", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "ID"); + RNA_def_property_collection_funcs(prop, + "rna_Depsgraph_ids_begin", + "rna_Depsgraph_ids_next", + "rna_Depsgraph_ids_end", + "rna_Depsgraph_ids_get", + NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "IDs", "All evaluated datablocks"); + prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_collection_funcs(prop, @@ -479,39 +551,33 @@ static void rna_def_depsgraph(BlenderRNA *brna) "rna_Depsgraph_objects_end", "rna_Depsgraph_objects_get", NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Objects", "Evaluated objects in the dependency graph"); - /* TODO(sergey): Find a better name. */ - prop = RNA_def_property(srna, "duplis", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "DepsgraphIter"); - RNA_def_property_collection_funcs(prop, - "rna_Depsgraph_duplis_begin", - "rna_Depsgraph_duplis_next", - "rna_Depsgraph_duplis_end", - "rna_Depsgraph_duplis_get", - NULL, NULL, NULL, NULL); - - prop = RNA_def_property(srna, "ids", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "ID"); + prop = RNA_def_property(srna, "object_instances", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "DepsgraphObjectInstance"); RNA_def_property_collection_funcs(prop, - "rna_Depsgraph_ids_begin", - "rna_Depsgraph_ids_next", - "rna_Depsgraph_ids_end", - "rna_Depsgraph_ids_get", + "rna_Depsgraph_object_instances_begin", + "rna_Depsgraph_object_instances_next", + "rna_Depsgraph_object_instances_end", + "rna_Depsgraph_object_instances_get", NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Object Instances", "All object instances to display or render"); - prop = RNA_def_property(srna, "ids_updated", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "ID"); + prop = RNA_def_property(srna, "updates", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "DepsgraphUpdate"); RNA_def_property_collection_funcs(prop, - "rna_Depsgraph_ids_updated_begin", + "rna_Depsgraph_updates_begin", "rna_Depsgraph_ids_next", "rna_Depsgraph_ids_end", - "rna_Depsgraph_ids_get", + "rna_Depsgraph_updates_get", NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Updates", "Updates to datablocks"); } void RNA_def_depsgraph(BlenderRNA *brna) { - rna_def_depsgraph_iter(brna); + rna_def_depsgraph_instance(brna); + rna_def_depsgraph_update(brna); rna_def_depsgraph(brna); } diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index f00bf51a3aa..16aceca026c 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1432,12 +1432,6 @@ int rna_Lamp_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) return ((Object *)value.id.data)->type == OB_LAMP; } -int rna_DupliObject_index_get(PointerRNA *ptr) -{ - DupliObject *dob = (DupliObject *)ptr->data; - return dob->persistent_id[0]; -} - int rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr) { SculptSession *ss = ((Object *)ptr->id.data)->sculpt; @@ -2520,64 +2514,6 @@ static void rna_def_object(BlenderRNA *brna) RNA_api_object(srna); } -static void rna_def_dupli_object(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "DupliObject", NULL); - RNA_def_struct_sdna(srna, "DupliObject"); - RNA_def_struct_ui_text(srna, "Object Duplicate", "An object duplicate"); - /* RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); */ - - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "ob"); - /* RNA_def_property_pointer_funcs(prop, "rna_DupliObject_object_get", NULL, NULL, NULL); */ - RNA_def_property_ui_text(prop, "Object", "Object being duplicated"); - - prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); - RNA_def_property_float_sdna(prop, NULL, "mat"); - RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Object Duplicate Matrix", "Object duplicate transformation matrix"); - - prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "no_draw", 0); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Hide", "Don't show dupli object in viewport or render"); - - prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE); - RNA_def_property_int_funcs(prop, "rna_DupliObject_index_get", NULL, NULL); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Index", "Index in the lowest-level dupli list"); - - prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Persistent ID", "Persistent identifier for inter-frame matching of objects with motion blur"); - - prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Particle System", "Particle system that this dupli object was instanced from"); - - prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Generated Coordinates", "Generated coordinates in parent object space"); - - prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE); - RNA_def_property_array(prop, 2); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space"); - - prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, dupli_items); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Dupli Type", "Duplicator type that generated this dupli object"); - - prop = RNA_def_property(srna, "random_id", PROP_INT, PROP_UNSIGNED); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Dupli random id", "Random id for this dupli object"); -} - void RNA_def_object(BlenderRNA *brna) { rna_def_object(brna); @@ -2586,7 +2522,6 @@ void RNA_def_object(BlenderRNA *brna) rna_def_vertex_group(brna); rna_def_face_map(brna); rna_def_material_slot(brna); - rna_def_dupli_object(brna); rna_def_object_display(brna); RNA_define_animate_sdna(true); } -- cgit v1.2.3