diff options
author | Lukas Toenne <lukas.toenne@gmail.com> | 2018-07-15 14:18:38 +0300 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@gmail.com> | 2018-07-15 14:18:38 +0300 |
commit | a89bcac14b083ef723d8d4a464ca75942743ec89 (patch) | |
tree | cf9f51999d9bc51a6ae1fa0648108d23612bdbaa /source/blender/depsgraph | |
parent | ff8df843c31cb41621204c579dbc34e8ce185708 (diff) | |
parent | a9be42dfa284be0742de2719ea90671612240705 (diff) |
Merge branch 'hair_guides' into hair_guides_grooming
Diffstat (limited to 'source/blender/depsgraph')
11 files changed, 88 insertions, 28 deletions
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index 0673a3177b7..185a98f2a2b 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -28,6 +28,7 @@ set(INC ../blenkernel ../blenlib ../bmesh + ../draw ../makesdna ../makesrna ../modifiers diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h index 0174b002292..71376d94ca8 100644 --- a/source/blender/depsgraph/DEG_depsgraph.h +++ b/source/blender/depsgraph/DEG_depsgraph.h @@ -130,7 +130,7 @@ typedef enum eDepsgraph_Tag { DEG_TAG_GEOMETRY = (1 << 1), /* Time changed and animation is to be re-evaluated, OB_RECALC_TIME. */ DEG_TAG_TIME = (1 << 2), - /* Particle system changed. */ + /* Particle system changed; values are aligned with PSYS_RECALC_xxx. */ DEG_TAG_PSYS_REDO = (1 << 3), DEG_TAG_PSYS_RESET = (1 << 4), DEG_TAG_PSYS_TYPE = (1 << 5), diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index b6256e9ceb0..4cbc7700947 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -69,7 +69,10 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph) flag |= DEG_TAG_COPY_ON_WRITE; } if (flag != 0) { - DEG_id_tag_update_ex(bmain, id_node->id_orig, flag); + DEG_graph_id_tag_update(bmain, + (::Depsgraph *)graph, + id_node->id_orig, + flag); } } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index e3a82a84d98..a784fdc33c4 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -876,9 +876,7 @@ void DepsgraphNodeBuilder::build_world(World *world) /* world itself */ add_operation_node(&world->id, DEG_NODE_TYPE_SHADING, - function_bind(BKE_world_eval, - _1, - get_cow_datablock(world)), + NULL, DEG_OPCODE_WORLD_UPDATE); /* world's nodetree */ if (world->nodetree != NULL) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index aea81263f81..4a250292f83 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -682,7 +682,7 @@ void DepsgraphRelationBuilder::build_object_data_lamp(Object *object) build_lamp(lamp); ComponentKey object_parameters_key(&object->id, DEG_NODE_TYPE_PARAMETERS); ComponentKey lamp_parameters_key(&lamp->id, DEG_NODE_TYPE_PARAMETERS); - add_relation(lamp_parameters_key, object_parameters_key, "Lamp -> Object"); + add_relation(lamp_parameters_key, object_parameters_key, "Light -> Object"); } void DepsgraphRelationBuilder::build_object_data_lightprobe(Object *object) @@ -1983,7 +1983,7 @@ void DepsgraphRelationBuilder::build_lamp(Lamp *lamp) build_nodetree(lamp->nodetree); ComponentKey lamp_parameters_key(&lamp->id, DEG_NODE_TYPE_PARAMETERS); ComponentKey nodetree_key(&lamp->nodetree->id, DEG_NODE_TYPE_SHADING); - add_relation(nodetree_key, lamp_parameters_key, "NTree->Lamp Parameters"); + add_relation(nodetree_key, lamp_parameters_key, "NTree->Light Parameters"); build_nested_nodetree(&lamp->id, lamp->nodetree); } } @@ -2201,7 +2201,7 @@ void DepsgraphRelationBuilder::build_nested_shapekey(ID *owner, Key *key) void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node) { ID *id_orig = id_node->id_orig; - + const ID_Type id_type = GS(id_orig->name); TimeSourceKey time_source_key; OperationKey copy_on_write_key(id_orig, DEG_NODE_TYPE_COPY_ON_WRITE, @@ -2224,9 +2224,28 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node /* Component explicitly requests to not add relation. */ continue; } - int rel_flag = 0; - if (comp_node->type == DEG_NODE_TYPE_ANIMATION) { - rel_flag |= DEPSREL_FLAG_NO_FLUSH; + int rel_flag = DEPSREL_FLAG_NO_FLUSH; + if (id_type == ID_ME && comp_node->type == DEG_NODE_TYPE_GEOMETRY) { + rel_flag &= ~DEPSREL_FLAG_NO_FLUSH; + } + /* Notes on exceptions: + * - Parameters component is where drivers are living. Changing any + * of the (custom) properties in the original datablock (even the + * ones which do not imply other component update) need to make + * sure drivers are properly updated. + * This way, for example, changing ID property will properly poke + * all drivers to be updated. + * + * - View layers have cached array of bases in them, which is not + * copied by copy-on-write, and not preserved. PROBABLY it is better + * to preserve that cache in copy-on-write, but for the time being + * we allow flush to layer collections component which will ensure + * that cached array fo bases exists and is up-to-date. + */ + if (comp_node->type == DEG_NODE_TYPE_PARAMETERS || + comp_node->type == DEG_NODE_TYPE_LAYER_COLLECTIONS) + { + rel_flag &= ~DEPSREL_FLAG_NO_FLUSH; } /* All entry operations of each component should wait for a proper * copy of ID. diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index ddc6e44ee1b..2a24d72eb67 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -140,9 +140,9 @@ static bool pointer_to_component_node_criteria( bPoseChannel *pchan = (bPoseChannel *)ptr->data; if (prop != NULL && RNA_property_is_idprop(prop)) { *type = DEG_NODE_TYPE_PARAMETERS; - *subdata = ""; - *operation_code = DEG_OPCODE_PARAMETERS_EVAL; - *operation_name = pchan->name; + *operation_code = DEG_OPCODE_ID_PROPERTY; + *operation_name = RNA_property_identifier((PropertyRNA *)prop); + *operation_name_tag = -1; } else { /* Bone - generally, we just want the bone component. */ diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 8b5409a630c..d2c9f93ba50 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -300,6 +300,7 @@ void depsgraph_tag_component(Depsgraph *graph, * explicitly, but not all areas are aware of this yet. */ void deg_graph_id_tag_legacy_compat(Main *bmain, + Depsgraph *depsgraph, ID *id, eDepsgraph_Tag tag) { @@ -310,7 +311,7 @@ void deg_graph_id_tag_legacy_compat(Main *bmain, Object *object = (Object *)id; ID *data_id = (ID *)object->data; if (data_id != NULL) { - DEG_id_tag_update_ex(bmain, data_id, 0); + deg_graph_id_tag_update(bmain, depsgraph, data_id, 0); } break; } @@ -323,7 +324,7 @@ void deg_graph_id_tag_legacy_compat(Main *bmain, Mesh *mesh = (Mesh *)id; ID *key_id = &mesh->key->id; if (key_id != NULL) { - DEG_id_tag_update_ex(bmain, key_id, 0); + deg_graph_id_tag_update(bmain, depsgraph, key_id, 0); } break; } @@ -332,7 +333,7 @@ void deg_graph_id_tag_legacy_compat(Main *bmain, Lattice *lattice = (Lattice *)id; ID *key_id = &lattice->key->id; if (key_id != NULL) { - DEG_id_tag_update_ex(bmain, key_id, 0); + deg_graph_id_tag_update(bmain, depsgraph, key_id, 0); } break; } @@ -341,7 +342,7 @@ void deg_graph_id_tag_legacy_compat(Main *bmain, Curve *curve = (Curve *)id; ID *key_id = &curve->key->id; if (key_id != NULL) { - DEG_id_tag_update_ex(bmain, key_id, 0); + deg_graph_id_tag_update(bmain, depsgraph, key_id, 0); } break; } @@ -397,7 +398,7 @@ static void deg_graph_id_tag_update_single_flag(Main *bmain, /* TODO(sergey): Get rid of this once all areas are using proper data ID * for tagging. */ - deg_graph_id_tag_legacy_compat(bmain, id, tag); + deg_graph_id_tag_legacy_compat(bmain, graph, id, tag); } @@ -455,7 +456,7 @@ void deg_graph_node_tag_zero(Main *bmain, Depsgraph *graph, IDDepsNode *id_node) comp_node->tag_update(graph); } GHASH_FOREACH_END(); - deg_graph_id_tag_legacy_compat(bmain, id, (eDepsgraph_Tag)0); + deg_graph_id_tag_legacy_compat(bmain, graph, id, (eDepsgraph_Tag)0); } void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag) diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 10af3fef5b6..10df9ed05a4 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -71,6 +71,8 @@ extern "C" { #include "DNA_object_types.h" #include "DNA_particle_types.h" +#include "DRW_engine.h" + #ifdef NESTED_ID_NASTY_WORKAROUND # include "DNA_curve_types.h" # include "DNA_key_types.h" @@ -565,6 +567,13 @@ void update_special_pointers(const Depsgraph *depsgraph, update_particle_system_orig_pointers(object_orig, object_cow); break; } + case ID_SCE: + { + Scene *scene_cow = (Scene *)id_cow; + const Scene *scene_orig = (const Scene *)id_orig; + scene_cow->eevee.light_cache = scene_orig->eevee.light_cache; + break; + } default: break; } @@ -818,6 +827,8 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, */ ListBase gpumaterial_backup; ListBase *gpumaterial_ptr = NULL; + DrawDataList drawdata_backup; + DrawDataList *drawdata_ptr = NULL; ObjectRuntimeBackup object_runtime_backup = {NULL}; if (check_datablock_expanded(id_cow)) { switch (id_type) { @@ -853,9 +864,11 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, break; } case ID_OB: - deg_backup_object_runtime((Object *)id_cow, - &object_runtime_backup); + { + Object *ob = (Object *)id_cow; + deg_backup_object_runtime(ob, &object_runtime_backup); break; + } default: break; } @@ -863,6 +876,11 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, gpumaterial_backup = *gpumaterial_ptr; gpumaterial_ptr->first = gpumaterial_ptr->last = NULL; } + drawdata_ptr = DRW_drawdatalist_from_id(id_cow); + if (drawdata_ptr != NULL) { + drawdata_backup = *drawdata_ptr; + drawdata_ptr->first = drawdata_ptr->last = NULL; + } } deg_free_copy_on_write_datablock(id_cow); deg_expand_copy_on_write_datablock(depsgraph, id_node); @@ -870,6 +888,10 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, if (gpumaterial_ptr != NULL) { *gpumaterial_ptr = gpumaterial_backup; } + /* Restore DrawData. */ + if (drawdata_ptr != NULL) { + *drawdata_ptr = drawdata_backup; + } if (id_type == ID_OB) { deg_restore_object_runtime((Object *)id_cow, &object_runtime_backup); } @@ -929,6 +951,12 @@ void discard_groom_edit_mode_pointers(ID *id_cow) groom_cow->editgroom = NULL; } +void discard_scene_pointers(ID *id_cow) +{ + Scene *scene_cow = (Scene *)id_cow; + scene_cow->eevee.light_cache = NULL; +} + /* NULL-ify all edit mode pointers which points to data from * original object. */ @@ -954,6 +982,11 @@ void discard_edit_mode_pointers(ID *id_cow) case ID_LT: discard_lattice_edit_mode_pointers(id_cow); break; + case ID_SCE: + /* Not really edit mode but still needs to run before + * BKE_libblock_free_datablock() */ + discard_scene_pointers(id_cow); + break; default: break; } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h index 8fca90e9f5b..40b1f94c7bc 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h @@ -34,7 +34,7 @@ struct ID; -/* Unkomment this to have verbose log about original and CoW pointers +/* Uncomment this to have verbose log about original and CoW pointers * logged, with detailed information when they are allocated, expanded * and remapped. */ diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index e9f11f8e089..16cb1b394f6 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -46,6 +46,8 @@ extern "C" { #include "DNA_object_types.h" + +#include "DRW_engine.h" } /* extern "C" */ #include "DEG_depsgraph.h" @@ -140,6 +142,9 @@ BLI_INLINE void flush_schedule_entrypoints(Depsgraph *graph, FlushQueue *queue) { queue->push_back(op_node); op_node->scheduled = true; + DEG_DEBUG_PRINTF((::Depsgraph *)graph, + EVAL, "Operation is entry point for update: %s\n", + op_node->identifier().c_str()); } GSET_FOREACH_END(); } @@ -216,12 +221,12 @@ BLI_INLINE OperationDepsNode *flush_schedule_children( void flush_engine_data_update(ID *id) { - if (GS(id->name) != ID_OB) { + DrawDataList *drawdata = DRW_drawdatalist_from_id(id); + if (drawdata == NULL) { return; } - Object *object = (Object *)id; - LISTBASE_FOREACH(ObjectEngineData *, engine_data, &object->drawdata) { - engine_data->recalc |= id->recalc; + LISTBASE_FOREACH(DrawData *, dd, drawdata) { + dd->recalc |= id->recalc; } } diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h index 5e79dc1c685..e4a77f2e72b 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.h +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h @@ -189,7 +189,7 @@ DEG_COMPONENT_NODE_DECLARE_GENERIC(Particles); DEG_COMPONENT_NODE_DECLARE_GENERIC(Proxy); DEG_COMPONENT_NODE_DECLARE_GENERIC(Pose); DEG_COMPONENT_NODE_DECLARE_GENERIC(Sequencer); -DEG_COMPONENT_NODE_DECLARE_GENERIC(Shading); +DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(Shading); DEG_COMPONENT_NODE_DECLARE_GENERIC(ShadingParameters); DEG_COMPONENT_NODE_DECLARE_GENERIC(Transform); DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(ObjectFromLayer); |