Blender V2.61 - r43446

depsgraph_private.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 
00030 #ifndef DEPSGRAPH_PRIVATE
00031 #define DEPSGRAPH_PRIVATE
00032 
00033 #include "BKE_depsgraph.h"
00034 #include "DNA_constraint_types.h"
00035 #include "BKE_constraint.h"
00036 
00037 
00038 #define DEPSX   5.0f
00039 #define DEPSY   1.8f
00040 
00041 #define DAGQUEUEALLOC 50
00042 
00043 enum {
00044     DAG_WHITE = 0,
00045     DAG_GRAY = 1,
00046     DAG_BLACK = 2
00047 };
00048 
00049 
00050 
00051 typedef struct DagAdjList
00052 {
00053     struct DagNode *node;
00054     short type;
00055     int count;          // number of identical arcs
00056     unsigned int lay;   // for flushing redraw/rebuild events
00057     const char *name;
00058     struct DagAdjList *next;
00059 } DagAdjList;
00060 
00061 
00062 typedef struct DagNode 
00063 {
00064     int color;
00065     short type;
00066     float x, y, k;  
00067     void * ob;
00068     void * first_ancestor;
00069     int ancestor_count;
00070     unsigned int lay;               // accumulated layers of its relations + itself
00071     unsigned int scelay;            // layers due to being in scene
00072     uint64_t customdata_mask;   // customdata mask
00073     int lasttime;       // if lasttime != DagForest->time, this node was not evaluated yet for flushing
00074     int BFS_dist;       // BFS distance
00075     int DFS_dist;       // DFS distance
00076     int DFS_dvtm;       // DFS discovery time
00077     int DFS_fntm;       // DFS Finishing time
00078     struct DagAdjList *child;
00079     struct DagAdjList *parent;
00080     struct DagNode *next;
00081 } DagNode;
00082 
00083 typedef struct DagNodeQueueElem {
00084     struct DagNode *node;
00085     struct DagNodeQueueElem *next;
00086 } DagNodeQueueElem;
00087 
00088 typedef struct DagNodeQueue
00089 {
00090     DagNodeQueueElem *first;
00091     DagNodeQueueElem *last;
00092     int count;
00093     int maxlevel;
00094     struct DagNodeQueue *freenodes;
00095 } DagNodeQueue;
00096 
00097 // forest as we may have more than one DAG unnconected
00098 typedef struct DagForest 
00099 {
00100     ListBase DagNode;
00101     struct GHash *nodeHash;
00102     int numNodes;
00103     int is_acyclic;
00104     int time;       // for flushing/tagging, compare with node->lasttime
00105 } DagForest;
00106 
00107 
00108 // queue operations
00109 DagNodeQueue * queue_create (int slots);
00110 void queue_raz(DagNodeQueue *queue);
00111 void push_queue(DagNodeQueue *queue, DagNode *node);
00112 void push_stack(DagNodeQueue *queue, DagNode *node);
00113 DagNode * pop_queue(DagNodeQueue *queue);
00114 DagNode * get_top_node_queue(DagNodeQueue *queue);
00115 
00116 // Dag management
00117 DagForest *getMainDag(void);
00118 void setMainDag(DagForest *dag);
00119 DagForest * dag_init(void);
00120 DagNode * dag_find_node (DagForest *forest,void * fob);
00121 DagNode * dag_add_node (DagForest *forest,void * fob);
00122 DagNode * dag_get_node (DagForest *forest,void * fob);
00123 DagNode * dag_get_sub_node (DagForest *forest,void * fob);
00124 void dag_add_relation(DagForest *forest, DagNode *fob1, DagNode *fob2, short rel, const char *name);
00125 
00126 void graph_bfs(void);
00127 
00128 DagNodeQueue * graph_dfs(void);
00129 
00130 void set_node_xy(DagNode *node, float x, float y);
00131 void graph_print_queue(DagNodeQueue *nqueue);
00132 void graph_print_queue_dist(DagNodeQueue *nqueue);
00133 void graph_print_adj_list(void);
00134 
00135 int build_deps(short mask);
00136 
00137 #endif