diff options
Diffstat (limited to 'source/blender/depsgraph')
-rw-r--r-- | source/blender/depsgraph/CMakeLists.txt | 4 | ||||
-rw-r--r-- | source/blender/depsgraph/DEG_depsgraph.h | 10 | ||||
-rw-r--r-- | source/blender/depsgraph/SConscript | 3 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph.cc | 31 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_build.h | 2 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_build_nodes.cc | 6 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_build_relations.cc | 15 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_debug.cc | 27 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_eval.cc | 5 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_types.h | 2 |
10 files changed, 92 insertions, 13 deletions
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index dcdb14d0ba0..f3ff709e98b 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -115,4 +115,8 @@ if(WITH_BOOST) add_definitions(-DHAVE_BOOST_FUNCTION_BINDINGS) endif() +if(WITH_OPENSUBDIV) + add_definitions(-DWITH_OPENSUBDIV) +endif() + blender_add_lib(bf_depsgraph "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h index b91f99ecd20..f37ba71ab65 100644 --- a/source/blender/depsgraph/DEG_depsgraph.h +++ b/source/blender/depsgraph/DEG_depsgraph.h @@ -193,6 +193,8 @@ void DEG_evaluate_on_refresh(struct EvaluationContext *eval_ctx, Depsgraph *graph, struct Scene *scene); +bool DEG_needs_eval(Depsgraph *graph); + /* Editors Integration -------------------------- */ /* Mechanism to allow editors to be informed of depsgraph updates, @@ -203,10 +205,16 @@ typedef void (*DEG_EditorUpdateIDCb)(struct Main *bmain, struct ID *id); typedef void (*DEG_EditorUpdateSceneCb)(struct Main *bmain, struct Scene *scene, int updated); +typedef void (*DEG_EditorUpdateScenePreCb)(struct Main *bmain, + struct Scene *scene, + bool time); /* Set callbacks which are being called when depsgraph changes. */ void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func, - DEG_EditorUpdateSceneCb scene_func); + DEG_EditorUpdateSceneCb scene_func, + DEG_EditorUpdateScenePreCb scene_pre_func); + +void DEG_editors_update_pre(struct Main *bmain, struct Scene *scene, bool time); #ifdef __cplusplus } /* extern "C" */ diff --git a/source/blender/depsgraph/SConscript b/source/blender/depsgraph/SConscript index dd0552e19a2..7f49e8f4643 100644 --- a/source/blender/depsgraph/SConscript +++ b/source/blender/depsgraph/SConscript @@ -69,6 +69,9 @@ else: if env['WITH_BF_LEGACY_DEPSGRAPH']: defs.append('WITH_LEGACY_DEPSGRAPH') +if env['WITH_BF_OPENSUBDIV']: + defs.append('WITH_OPENSUBDIV') + env.BlenderLib(libname='bf_depsgraph', sources=sources, includes=incs, defines=defs, libtype=['core', 'player'], priority=[200, 40]) diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index e9b2a06cf7b..dedb6e322ba 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -44,6 +44,8 @@ extern "C" { #include "DNA_object_types.h" #include "DNA_sequence_types.h" +#include "BKE_depsgraph.h" + #include "RNA_access.h" } @@ -56,11 +58,12 @@ extern "C" { static DEG_EditorUpdateIDCb deg_editor_update_id_cb = NULL; static DEG_EditorUpdateSceneCb deg_editor_update_scene_cb = NULL; +static DEG_EditorUpdateScenePreCb deg_editor_update_scene_pre_cb = NULL; Depsgraph::Depsgraph() : root_node(NULL), need_update(false), - layers((1 << 20) - 1) + layers(0) { BLI_spin_init(&lock); } @@ -351,6 +354,21 @@ DepsRelation *Depsgraph::add_new_relation(OperationDepsNode *from, { /* Create new relation, and add it to the graph. */ DepsRelation *rel = OBJECT_GUARDED_NEW(DepsRelation, from, to, type, description); + /* TODO(sergey): Find a better place for this. */ +#ifdef WITH_OPENSUBDIV + ComponentDepsNode *comp_node = from->owner; + if (comp_node->type == DEPSNODE_TYPE_GEOMETRY) { + IDDepsNode *id_to = to->owner->owner; + IDDepsNode *id_from = from->owner->owner; + Object *object_to = (Object *)id_to->id; + if (id_to != id_from && (object_to->recalc & OB_RECALC_ALL)) { + if ((id_from->eval_flags & DAG_EVAL_NEED_CPU) == 0) { + id_from->tag_update(this); + id_from->eval_flags |= DAG_EVAL_NEED_CPU; + } + } + } +#endif return rel; } @@ -452,10 +470,19 @@ void DEG_graph_free(Depsgraph *graph) /* Set callbacks which are being called when depsgraph changes. */ void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func, - DEG_EditorUpdateSceneCb scene_func) + DEG_EditorUpdateSceneCb scene_func, + DEG_EditorUpdateScenePreCb scene_pre_func) { deg_editor_update_id_cb = id_func; deg_editor_update_scene_cb = scene_func; + deg_editor_update_scene_pre_cb = scene_pre_func; +} + +void DEG_editors_update_pre(Main *bmain, Scene *scene, bool time) +{ + if (deg_editor_update_scene_pre_cb != NULL) { + deg_editor_update_scene_pre_cb(bmain, scene, time); + } } void deg_editors_id_update(Main *bmain, ID *id) diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h index 4088a3289ef..c5b04ec299c 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.h +++ b/source/blender/depsgraph/intern/depsgraph_build.h @@ -108,7 +108,7 @@ struct DepsgraphNodeBuilder { void build_object_constraints(Scene *scene, Object *ob); void build_pose_constraints(Object *ob, bPoseChannel *pchan); void build_rigidbody(Scene *scene); - void build_particles(Object *ob); + void build_particles(Scene *scene, Object *ob); void build_animdata(ID *id); OperationDepsNode *build_driver(ID *id, FCurve *fcurve); void build_ik_pose(Scene *scene, Object *ob, bPoseChannel *pchan, bConstraint *con); diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cc b/source/blender/depsgraph/intern/depsgraph_build_nodes.cc index 31e32ac3e75..4463df61f91 100644 --- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cc +++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cc @@ -448,7 +448,7 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Base *base, Object *ob) /* particle systems */ if (ob->particlesystem.first) { - build_particles(ob); + build_particles(scene, ob); } /* grease pencil */ @@ -676,7 +676,7 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene) } } -void DepsgraphNodeBuilder::build_particles(Object *ob) +void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob) { /** * Particle Systems Nodes @@ -707,7 +707,7 @@ void DepsgraphNodeBuilder::build_particles(Object *ob) /* this particle system */ // TODO: for now, this will just be a placeholder "ubereval" node add_operation_node(psys_comp, - DEPSOP_TYPE_EXEC, function_bind(BKE_particle_system_eval, _1, ob, psys), + DEPSOP_TYPE_EXEC, function_bind(BKE_particle_system_eval, _1, scene, ob, psys), DEG_OPCODE_PSYS_EVAL, psys->name); } diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cc b/source/blender/depsgraph/intern/depsgraph_build_relations.cc index 9bd448aa51c..c348adaaf53 100644 --- a/source/blender/depsgraph/intern/depsgraph_build_relations.cc +++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cc @@ -812,6 +812,10 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu) ComponentKey geometry_key(shape_key->from, DEPSNODE_TYPE_GEOMETRY); add_relation(driver_key, geometry_key, DEPSREL_TYPE_DRIVER, "[Driver -> ShapeKey Geom]"); } + else if (strstr(fcu->rna_path, "key_blocks[")) { + ComponentKey geometry_key(id, DEPSNODE_TYPE_GEOMETRY); + add_relation(driver_key, geometry_key, DEPSREL_TYPE_DRIVER, "[Driver -> ShapeKey Geom]"); + } else { if (GS(id->name) == ID_OB) { /* assume that driver affects a transform... */ @@ -1576,6 +1580,17 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje if (BKE_object_modifier_use_time(ob, md)) { TimeSourceKey time_src_key; add_relation(time_src_key, mod_key, DEPSREL_TYPE_TIME, "Time Source"); + + /* Hacky fix for T45633 (Animated modifiers aren't updated) + * + * This check works because BKE_object_modifier_use_time() tests + * for either the modifier needing time, or that it is animated. + */ + /* XXX: Remove this hack when these links are added as part of build_animdata() instead */ + if (modifier_dependsOnTime(md) == false) { + ComponentKey animation_key(&ob->id, DEPSNODE_TYPE_ANIMATION); + add_relation(animation_key, mod_key, DEPSREL_TYPE_OPERATION, "Modifier Animation"); + } } prev_mod_key = mod_key; diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc index 59351495df0..7f3f328502f 100644 --- a/source/blender/depsgraph/intern/depsgraph_debug.cc +++ b/source/blender/depsgraph/intern/depsgraph_debug.cc @@ -59,8 +59,6 @@ extern "C" { /* ****************** */ /* Graphviz Debugging */ -static SpinLock lock; - #define NL "\r\n" /* Only one should be enabled, defines whether graphviz nodes @@ -345,9 +343,11 @@ static void deg_debug_graphviz_node_fillcolor(const DebugContext &ctx, #endif static void deg_debug_graphviz_relation_color(const DebugContext &ctx, - const DepsRelation *UNUSED(rel)) + const DepsRelation *rel) { - const char *defaultcolor = "black"; + const char *color_default = "black"; + const char *color_error = "red4"; + const char *color = color_default; #if 0 /* disabled for now, edge colors are hardly distinguishable */ int color = deg_debug_relation_type_color_index(rel->type); if (color < 0) { @@ -357,7 +357,10 @@ static void deg_debug_graphviz_relation_color(const DebugContext &ctx, deg_debug_fprintf(ctx, "\"%s\"", deg_debug_colors_dark[color % deg_debug_max_colors]); } #else - deg_debug_fprintf(ctx, "%s", defaultcolor); + if (rel->flag & DEPSREL_FLAG_CYCLIC) + color = color_error; + + deg_debug_fprintf(ctx, "%s", color); #endif } @@ -439,6 +442,7 @@ static void deg_debug_graphviz_node_cluster_begin(const DebugContext &ctx, deg_debug_fprintf(ctx, "label=<%s>;" NL, name.c_str()); deg_debug_fprintf(ctx, "fontname=\"%s\";" NL, deg_debug_graphviz_fontname); deg_debug_fprintf(ctx, "fontsize=%f;" NL, deg_debug_graphviz_node_label_size); + deg_debug_fprintf(ctx, "margin=\"%d\";" NL, 16); deg_debug_fprintf(ctx, "style="); deg_debug_graphviz_node_style(ctx, node); deg_debug_fprintf(ctx, ";" NL); deg_debug_fprintf(ctx, "color="); deg_debug_graphviz_node_color(ctx, node); deg_debug_fprintf(ctx, ";" NL); deg_debug_fprintf(ctx, "fillcolor="); deg_debug_graphviz_node_fillcolor(ctx, node); deg_debug_fprintf(ctx, ";" NL); @@ -592,6 +596,8 @@ static void deg_debug_graphviz_node_relations(const DebugContext &ctx, { DEPSNODE_RELATIONS_ITER_BEGIN(node->inlinks, rel) { + float penwidth = 2.0f; + const DepsNode *tail = rel->to; /* same as node */ const DepsNode *head = rel->from; deg_debug_fprintf(ctx, "// %s -> %s\n", @@ -602,9 +608,20 @@ static void deg_debug_graphviz_node_relations(const DebugContext &ctx, deg_debug_fprintf(ctx, "\"node_%p\"", tail); deg_debug_fprintf(ctx, "["); + /* XXX labels on relations are not very helpful: + * - they tend to appear too far away to be associated with the edge lines + * - names are mostly redundant, reflecting simply their from/to nodes + * - no behavior or typing of relations themselves to justify labels + */ +#if 0 deg_debug_fprintf(ctx, "label=\"%s\"", rel->name); deg_debug_fprintf(ctx, ",fontname=\"%s\"", deg_debug_graphviz_fontname); +#else + /* Note: without label an id seem necessary to avoid bugs in graphviz/dot */ + deg_debug_fprintf(ctx, "id=\"%s\"", rel->name); +#endif deg_debug_fprintf(ctx, ",color="); deg_debug_graphviz_relation_color(ctx, rel); + deg_debug_fprintf(ctx, ",penwidth=\"%f\"", penwidth); /* NOTE: edge from node to own cluster is not possible and gives graphviz * warning, avoid this here by just linking directly to the invisible * placeholder node diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc index 0a1563e7704..e8065766332 100644 --- a/source/blender/depsgraph/intern/depsgraph_eval.cc +++ b/source/blender/depsgraph/intern/depsgraph_eval.cc @@ -392,3 +392,8 @@ void DEG_evaluate_on_framechange(EvaluationContext *eval_ctx, /* Perform recalculation updates. */ DEG_evaluate_on_refresh_ex(eval_ctx, graph, layers); } + +bool DEG_needs_eval(Depsgraph *graph) +{ + return graph->entry_tags.size() != 0; +} diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h index 3616fe85496..f5fbf0bcc76 100644 --- a/source/blender/depsgraph/intern/depsgraph_types.h +++ b/source/blender/depsgraph/intern/depsgraph_types.h @@ -127,7 +127,7 @@ typedef enum eDepsOperation_Type { * data-level checks... */ typedef enum eDepsRelation_Type { - /* reationship type unknown/irrelevant */ + /* relationship type unknown/irrelevant */ DEPSREL_TYPE_STANDARD = 0, /* root -> active scene or entity (screen, image, etc.) */ |