diff options
Diffstat (limited to 'source/blender/depsgraph/intern/builder')
4 files changed, 73 insertions, 65 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index e8e3e241ebf..637fd5887a0 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -399,7 +399,10 @@ void DepsgraphNodeBuilder::end_build() if (op_node == NULL) { continue; } - op_node->tag_update(graph_); + /* Since the tag is coming from a saved copy of entry tags, this means + * that originally node was explicitly tagged for user update. + */ + op_node->tag_update(graph_, DEG_UPDATE_SOURCE_USER_EDIT); } } @@ -818,6 +821,22 @@ void DepsgraphNodeBuilder::build_object_constraints(Object *object) DEG_OPCODE_TRANSFORM_CONSTRAINTS); } +void DepsgraphNodeBuilder::build_object_pointcache(Object *object) +{ + if (!BKE_ptcache_object_has(scene_, object, 0)) { + return; + } + Scene *scene_cow = get_cow_datablock(scene_); + Object *object_cow = get_cow_datablock(object); + add_operation_node(&object->id, + DEG_NODE_TYPE_POINT_CACHE, + function_bind(BKE_object_eval_ptcache_reset, + _1, + scene_cow, + object_cow), + DEG_OPCODE_POINT_CACHE_RESET); +} + /** * Build graph nodes for AnimData block * \param id: ID-Block which hosts the AnimData @@ -1123,15 +1142,6 @@ void DepsgraphNodeBuilder::build_particles(Object *object, break; } } - - /* TODO(sergey): Do we need a point cache operations here? */ - add_operation_node(&object->id, - DEG_NODE_TYPE_CACHE, - function_bind(BKE_ptcache_object_reset, - scene_cow, - ob_cow, - PTCACHE_RESET_DEPSGRAPH), - DEG_OPCODE_POINT_CACHE_RESET); } void DepsgraphNodeBuilder::build_particle_settings(ParticleSettings *part) { @@ -1147,19 +1157,6 @@ void DepsgraphNodeBuilder::build_particle_settings(ParticleSettings *part) { DEG_OPCODE_PARTICLE_SETTINGS_EVAL); } -void DepsgraphNodeBuilder::build_cloth(Object *object) -{ - Scene *scene_cow = get_cow_datablock(scene_); - Object *object_cow = get_cow_datablock(object); - add_operation_node(&object->id, - DEG_NODE_TYPE_CACHE, - function_bind(BKE_object_eval_cloth, - _1, - scene_cow, - object_cow), - DEG_OPCODE_GEOMETRY_CLOTH_MODIFIER); -} - /* Shapekeys */ void DepsgraphNodeBuilder::build_shapekeys(Key *key) { @@ -1204,13 +1201,6 @@ void DepsgraphNodeBuilder::build_object_data_geometry( DEG_OPCODE_PLACEHOLDER, "Eval Init"); op_node->set_as_entry(); - // TODO: "Done" operation - /* Cloth modifier. */ - LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { - if (md->type == eModifierType_Cloth) { - build_cloth(object); - } - } /* Materials. */ if (object->totcol != 0) { if (object->type == OB_MESH) { @@ -1221,7 +1211,6 @@ void DepsgraphNodeBuilder::build_object_data_geometry( object_cow), DEG_OPCODE_SHADING); } - for (int a = 1; a <= object->totcol; a++) { Material *ma = give_current_material(object, a); if (ma != NULL) { @@ -1229,10 +1218,9 @@ void DepsgraphNodeBuilder::build_object_data_geometry( } } } - /* Geometry collision. */ - if (ELEM(object->type, OB_MESH, OB_CURVE, OB_LATTICE)) { - // add geometry collider relations - } + /* Point caches. */ + build_object_pointcache(object); + /* Geometry. */ build_object_data_geometry_datablock((ID *)object->data, is_object_visible); } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index b826a2979cc..3c0c5f749ca 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -183,6 +183,7 @@ struct DepsgraphNodeBuilder { void build_object_data_speaker(Object *object); void build_object_transform(Object *object); void build_object_constraints(Object *object); + void build_object_pointcache(Object *object); void build_pose_constraints(Object *object, bPoseChannel *pchan, int pchan_index, @@ -190,7 +191,6 @@ struct DepsgraphNodeBuilder { void build_rigidbody(Scene *scene); void build_particles(Object *object, bool is_object_visible); void build_particle_settings(ParticleSettings *part); - void build_cloth(Object *object); void build_animdata(ID *id); void build_animdata_nlastrip_targets(ListBase *strips); void build_action(bAction *action); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index d336bfb6188..e66c3a25e33 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -87,6 +87,7 @@ extern "C" { #include "BKE_node.h" #include "BKE_object.h" #include "BKE_particle.h" +#include "BKE_pointcache.h" #include "BKE_rigidbody.h" #include "BKE_shader_fx.h" #include "BKE_shrinkwrap.h" @@ -184,9 +185,13 @@ static bool check_id_has_anim_component(ID *id) (!BLI_listbase_is_empty(&adt->nla_tracks)); } -static eDepsOperation_Code bone_target_opcode(ID *target, const char *subtarget, ID *id, const char *component_subdata, RootPChanMap *root_map) +static eDepsOperation_Code bone_target_opcode(ID *target, + const char *subtarget, + ID *id, + const char *component_subdata, + RootPChanMap *root_map) { - /* same armature */ + /* Same armature. */ if (target == id) { /* Using "done" here breaks in-chain deps, while using * "ready" here breaks most production rigs instead. @@ -197,7 +202,6 @@ static eDepsOperation_Code bone_target_opcode(ID *target, const char *subtarget, return DEG_OPCODE_BONE_READY; } } - return DEG_OPCODE_BONE_DONE; } @@ -642,6 +646,8 @@ void DepsgraphRelationBuilder::build_object(Base *base, Object *object) if (object->dup_group != NULL) { build_collection(object, object->dup_group); } + /* Point caches. */ + build_object_pointcache(object); } void DepsgraphRelationBuilder::build_object_flags(Base *base, Object *object) @@ -846,11 +852,47 @@ void DepsgraphRelationBuilder::build_object_parent(Object *object) break; } } +} - /* exception case: parent is duplivert */ - if ((object->type == OB_MBALL) && (object->parent->transflag & OB_DUPLIVERTS)) { - //dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Duplivert"); +void DepsgraphRelationBuilder::build_object_pointcache(Object *object) +{ + ComponentKey point_cache_key(&object->id, DEG_NODE_TYPE_POINT_CACHE); + /* Different point caches are affecting different aspects of life of the + * object. We keep track of those aspects and avoid duplicate relations. */ + enum { + FLAG_TRANSFORM = (1 << 0), + FLAG_GEOMETRY = (1 << 1), + FLAG_ALL = (FLAG_TRANSFORM | FLAG_GEOMETRY), + }; + ListBase ptcache_id_list; + BKE_ptcache_ids_from_object(&ptcache_id_list, object, scene_, 0); + int handled_components = 0; + LISTBASE_FOREACH (PTCacheID *, ptcache_id, &ptcache_id_list) { + /* Check which components needs the point cache. */ + int flag; + if (ptcache_id->type == PTCACHE_TYPE_RIGIDBODY) { + flag = FLAG_TRANSFORM; + ComponentKey transform_key(&object->id, + DEG_NODE_TYPE_TRANSFORM); + add_relation(point_cache_key, + transform_key, + "Point Cache -> Rigid Body"); + } + else { + flag = FLAG_GEOMETRY; + ComponentKey geometry_key(&object->id, + DEG_NODE_TYPE_GEOMETRY); + add_relation(point_cache_key, + geometry_key, + "Point Cache -> Geometry"); + } + /* Tag that we did handle that component. */ + handled_components |= flag; + if (handled_components == FLAG_ALL) { + break; + } } + BLI_freelistN(&ptcache_id_list); } void DepsgraphRelationBuilder::build_constraints(ID *id, @@ -1744,12 +1786,6 @@ void DepsgraphRelationBuilder::build_particles(Object *object) */ ComponentKey transform_key(&object->id, DEG_NODE_TYPE_TRANSFORM); add_relation(transform_key, obdata_ubereval_key, "Partcile Eval"); - - OperationKey point_cache_reset_key(&object->id, - DEG_NODE_TYPE_CACHE, - DEG_OPCODE_POINT_CACHE_RESET); - add_relation(transform_key, point_cache_reset_key, "Object Transform -> Point Cache Reset"); - add_relation(point_cache_reset_key, obdata_ubereval_key, "Point Cache Reset -> UberEval"); } void DepsgraphRelationBuilder::build_particle_settings(ParticleSettings *part) @@ -1783,19 +1819,6 @@ void DepsgraphRelationBuilder::build_particles_visualization_object( } } -void DepsgraphRelationBuilder::build_cloth(Object *object, - ModifierData * /*md*/) -{ - OperationKey cache_key(&object->id, - DEG_NODE_TYPE_CACHE, - DEG_OPCODE_GEOMETRY_CLOTH_MODIFIER); - /* Cache component affects on modifier. */ - OperationKey modifier_key(&object->id, - DEG_NODE_TYPE_GEOMETRY, - DEG_OPCODE_GEOMETRY_UBEREVAL); - add_relation(cache_key, modifier_key, "Cloth Cache -> Cloth"); -} - /* Shapekeys */ void DepsgraphRelationBuilder::build_shapekeys(Key *key) { @@ -1869,9 +1892,6 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object) TimeSourceKey time_src_key; add_relation(time_src_key, obdata_ubereval_key, "Time Source"); } - if (md->type == eModifierType_Cloth) { - build_cloth(object, md); - } } } /* Grease Pencil Modifiers */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index e5854fa8d20..e86c6504693 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -217,6 +217,7 @@ struct DepsgraphRelationBuilder void build_object_data_lightprobe(Object *object); void build_object_data_speaker(Object *object); void build_object_parent(Object *object); + void build_object_pointcache(Object *object); void build_constraints(ID *id, eDepsNode_Type component_type, const char *component_subdata, @@ -244,7 +245,6 @@ struct DepsgraphRelationBuilder void build_particles_visualization_object(Object *object, ParticleSystem *psys, Object *draw_object); - void build_cloth(Object *object, ModifierData *md); void build_ik_pose(Object *object, bPoseChannel *pchan, bConstraint *con, |