diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-11-04 17:17:35 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-11-04 17:17:35 +0400 |
commit | 21d188a70f48ef156f8543b5d9191196a95d7966 (patch) | |
tree | f6d7a56d772da1f7403078f9ebc78c40d10980ca | |
parent | 90acd1d0fc7716d6b8db1ae58304b930a84a701f (diff) |
Depsgraph: add "Dependency Relations" operator to print the dependency graph to
the console, useful for debugging and understanding the relations.
-rw-r--r-- | source/blender/blenkernel/BKE_depsgraph.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/depsgraph.c | 25 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 23 |
3 files changed, 49 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index 0b0637fb42a..e0b8e40d731 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -133,6 +133,9 @@ void DAG_pose_sort(struct Object *ob); /* callback for editors module to do updates */ void DAG_editors_update_cb(void (*func)(struct Main *bmain, struct ID *id)); + /* debugging */ +void DAG_print_dependencies(struct Main *bmain, struct Scene *scene, struct Object *ob); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 286854f345c..51edee9ea71 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -799,6 +799,7 @@ DagNode * dag_find_node (DagForest *forest,void * fob) } static int ugly_hack_sorry= 1; // prevent type check +static int dag_print_dependencies= 0; // debugging /* no checking of existence, use dag_find_node first or dag_get_node */ DagNode * dag_add_node (DagForest *forest, void * fob) @@ -926,7 +927,6 @@ static const char *dag_node_name(DagNode *node) return ((bPoseChannel*)(node->ob))->name; } -#if 0 static void dag_node_print_dependencies(DagNode *node) { DagAdjList *itA; @@ -937,7 +937,6 @@ static void dag_node_print_dependencies(DagNode *node) printf(" %s through %s\n", dag_node_name(itA->node), itA->name); printf("\n"); } -#endif static int dag_node_print_dependency_recurs(DagNode *node, DagNode *endnode) { @@ -998,6 +997,11 @@ static void dag_check_cycle(DagForest *dag) DagNode *node; DagAdjList *itA; + /* debugging print */ + if(dag_print_dependencies) + for(node = dag->DagNode.first; node; node= node->next) + dag_node_print_dependencies(node); + /* tag nodes unchecked */ for(node = dag->DagNode.first; node; node= node->next) node->color= DAG_WHITE; @@ -2834,5 +2838,22 @@ void DAG_pose_sort(Object *ob) ugly_hack_sorry= 1; } +/* ************************ DAG DEBUGGING ********************* */ +void DAG_print_dependencies(Main *bmain, Scene *scene, Object *ob) +{ + /* utility for debugging dependencies */ + dag_print_dependencies= 1; + + if(ob && (ob->mode & OB_MODE_POSE)) { + printf("\nDEPENDENCY RELATIONS for %s\n\n", ob->id.name+2); + DAG_pose_sort(ob); + } + else { + printf("\nDEPENDENCY RELATIONS for %s\n\n", scene->id.name+2); + DAG_scene_sort(bmain, scene); + } + + dag_print_dependencies= 0; +} diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index acd5df79982..933066513e2 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3450,6 +3450,28 @@ static void WM_OT_memory_statistics(wmOperatorType *ot) ot->exec= memory_statistics_exec; } +/* ************************** memory statistics for testing ***************** */ + +static int dependency_relations_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_active_object(C); + + DAG_print_dependencies(bmain, scene, ob); + + return OPERATOR_FINISHED; +} + +static void WM_OT_dependency_relations(wmOperatorType *ot) +{ + ot->name= "Dependency Relations"; + ot->idname= "WM_OT_dependency_relations"; + ot->description= "Print dependency graph relations to the console"; + + ot->exec= dependency_relations_exec; +} + /* ******************************************************* */ static int wm_ndof_sensitivity_exec(bContext *UNUSED(C), wmOperator *op) @@ -3532,6 +3554,7 @@ void wm_operatortype_init(void) WM_operatortype_append(WM_OT_save_mainfile); WM_operatortype_append(WM_OT_redraw_timer); WM_operatortype_append(WM_OT_memory_statistics); + WM_operatortype_append(WM_OT_dependency_relations); WM_operatortype_append(WM_OT_debug_menu); WM_operatortype_append(WM_OT_splash); WM_operatortype_append(WM_OT_search_menu); |