Blender  V2.59
BKE_depsgraph.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BKE_depsgraph.h 37466 2011-06-14 04:05:58Z campbellbarton $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2004 Blender Foundation.
00021  * All rights reserved.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00028 #ifndef DEPSGRAPH_API
00029 #define DEPSGRAPH_API
00030 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 /*
00040 #define DEPS_DEBUG
00041 */
00042 
00043 struct ID;
00044 struct Main;
00045 struct Scene;
00046 struct DagNodeQueue;
00047 struct DagForest;
00048 struct DagNode;
00049 struct GHash;
00050 
00051 /* **** DAG relation types *** */
00052 
00053         /* scene link to object */
00054 #define DAG_RL_SCENE            (1<<0)
00055         /* object link to data */
00056 #define DAG_RL_DATA                     (1<<1)
00057 
00058         /* object changes object (parent, track, constraints) */
00059 #define DAG_RL_OB_OB            (1<<2)
00060         /* object changes obdata (hooks, constraints) */
00061 #define DAG_RL_OB_DATA          (1<<3)
00062         /* data changes object (vertex parent) */
00063 #define DAG_RL_DATA_OB          (1<<4)
00064         /* data changes data (deformers) */
00065 #define DAG_RL_DATA_DATA        (1<<5)
00066 
00067 #define DAG_NO_RELATION         (1<<6)
00068 
00069 #define DAG_RL_ALL_BUT_DATA (DAG_RL_SCENE|DAG_RL_OB_OB|DAG_RL_OB_DATA|DAG_RL_DATA_OB|DAG_RL_DATA_DATA)
00070 #define DAG_RL_ALL                      (DAG_RL_ALL_BUT_DATA|DAG_RL_DATA)
00071 
00072 
00073 typedef void (*graph_action_func)(void * ob, void **data);
00074 
00075 // queues are returned by all BFS & DFS queries
00076 // opaque type
00077 void    *pop_ob_queue(struct DagNodeQueue *queue);
00078 int             queue_count(struct DagNodeQueue *queue);
00079 void    queue_delete(struct DagNodeQueue *queue);
00080 
00081 // queries
00082 struct DagForest        *build_dag(struct Main *bmain, struct Scene *sce, short mask);
00083 void                            free_forest(struct DagForest *Dag);
00084 
00085 // note :
00086 // the meanings of the 2 returning values is a bit different :
00087 // BFS return 1 for cross-edges and back-edges. the latter are considered harmfull, not the former
00088 // DFS return 1 only for back-edges
00089 int pre_and_post_BFS(struct DagForest *dag, short mask, graph_action_func pre_func, graph_action_func post_func, void **data);
00090 int pre_and_post_DFS(struct DagForest *dag, short mask, graph_action_func pre_func, graph_action_func post_func, void **data);
00091 
00092 int pre_and_post_source_BFS(struct DagForest *dag, short mask, struct DagNode *source, graph_action_func pre_func, graph_action_func post_func, void **data);
00093 int pre_and_post_source_DFS(struct DagForest *dag, short mask, struct DagNode *source, graph_action_func pre_func, graph_action_func post_func, void **data);
00094 
00095 struct DagNodeQueue *get_obparents(struct DagForest     *dag, void *ob); 
00096 struct DagNodeQueue *get_first_ancestors(struct DagForest       *dag, void *ob); 
00097 struct DagNodeQueue *get_all_childs(struct DagForest    *dag, void *ob); //
00098 short           are_obs_related(struct DagForest        *dag, void *ob1, void *ob2);
00099 int                                     is_acyclic(struct DagForest     *dag); //
00100 //int                                   get_cycles(struct DagForest     *dag, struct DagNodeQueue **queues, int *count); //
00101 
00102 void    boundbox_deps(void);
00103 void    draw_all_deps(void);
00104 
00105 /* ********** API *************** */
00106 /* Note that the DAG never executes changes in Objects, only sets flags in Objects */
00107 
00108                 /* (re)-create dependency graph for scene */
00109 void    DAG_scene_sort(struct Main *bmain, struct Scene *sce);
00110 
00111                 /* flag all objects that need recalc because they're animated */
00112 void    DAG_scene_update_flags(struct Main *bmain, struct Scene *sce, unsigned int lay, const short do_time);
00113                 /* flushes all recalc flags in objects down the dependency tree */
00114 void    DAG_scene_flush_update(struct Main *bmain, struct Scene *sce, unsigned int lay, const short do_time);
00115                 /* tag objects for update on file load */
00116 void    DAG_on_visible_update(struct Main *bmain, const short do_time);
00117 
00118                 /* when setting manual RECALC flags, call this afterwards */
00119 void    DAG_ids_flush_update(struct Main *bmain, int time);
00120 
00121                 /* tag datablock to get updated for the next redraw */
00122 void    DAG_id_tag_update(struct ID *id, short flag);
00123                 /* flush all tagged updates */
00124 void    DAG_ids_flush_tagged(struct Main *bmain);
00125 
00126                 /* (re)-create dependency graph for armature pose */
00127 void    DAG_pose_sort(struct Object *ob);
00128 
00129                 /* callback for editors module to do updates */
00130 void    DAG_editors_update_cb(void (*func)(struct Main *bmain, struct ID *id));
00131 
00132 #ifdef __cplusplus
00133 }
00134 #endif
00135                 
00136 #endif