Blender V2.61 - r43446

BKE_depsgraph.h

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