BKE_depsgraph.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * The Original Code is Copyright (C) 2004 Blender Foundation.
  19. * All rights reserved.
  20. *
  21. * Contributor(s): none yet.
  22. *
  23. * ***** END GPL LICENSE BLOCK *****
  24. */
  25. #ifndef __BKE_DEPSGRAPH_H__
  26. #define __BKE_DEPSGRAPH_H__
  27. /** \file BKE_depsgraph.h
  28. * \ingroup bke
  29. */
  30. /* Dependency Graph
  31. *
  32. * The dependency graph tracks relations between datablocks, and is used to
  33. * determine which datablocks need to be update based on dependencies and
  34. * visibility.
  35. *
  36. * It does not itself execute changes in objects, but rather sorts the objects
  37. * in the appropriate order and sets flags indicating they should be updated.
  38. */
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. struct ID;
  43. struct Main;
  44. struct Object;
  45. struct Scene;
  46. /* Dependency graph evaluation context
  47. *
  48. * This structure stores all the local dependency graph data,
  49. * which is needed for it's evaluation,
  50. */
  51. typedef struct EvaluationContext {
  52. int mode; /* evaluation mode */
  53. float ctime; /* evaluation time */
  54. } EvaluationContext;
  55. typedef enum eEvaluationMode {
  56. DAG_EVAL_VIEWPORT = 0, /* evaluate for OpenGL viewport */
  57. DAG_EVAL_PREVIEW = 1, /* evaluate for render with preview settings */
  58. DAG_EVAL_RENDER = 2, /* evaluate for render purposes */
  59. } eEvaluationMode;
  60. /* DagNode->eval_flags */
  61. enum {
  62. /* Regardless to curve->path animation flag path is to be evaluated anyway,
  63. * to meet dependencies with such a things as curve modifier and other guys
  64. * who're using curve deform, where_on_path and so.
  65. */
  66. DAG_EVAL_NEED_CURVE_PATH = 1,
  67. /* Scene evaluation would need to have object's data on CPU,
  68. * meaning no GPU shortcuts is allowed.
  69. */
  70. DAG_EVAL_NEED_CPU = 2,
  71. };
  72. /* Global initialization/deinitialization */
  73. void DAG_init(void);
  74. void DAG_exit(void);
  75. /* Build and Update
  76. *
  77. * DAG_scene_relations_update will rebuild the dependency graph for a given
  78. * scene if needed, and sort objects in the scene.
  79. *
  80. * DAG_relations_tag_update will clear all dependency graphs and mark them to
  81. * be rebuilt later. The graph is not rebuilt immediately to avoid slowdowns
  82. * when this function is call multiple times from different operators.
  83. *
  84. * DAG_scene_relations_rebuild forces an immediaterebuild of the dependency
  85. * graph, this is only needed in rare cases
  86. */
  87. void DAG_scene_relations_update(struct Main *bmain, struct Scene *sce);
  88. void DAG_scene_relations_validate(struct Main *bmain, struct Scene *sce);
  89. void DAG_relations_tag_update(struct Main *bmain);
  90. void DAG_scene_relations_rebuild(struct Main *bmain, struct Scene *scene);
  91. void DAG_scene_free(struct Scene *sce);
  92. /* Update Tagging
  93. *
  94. * DAG_scene_update_flags will mark all objects that depend on time (animation,
  95. * physics, ..) to be recalculated, used when changing the current frame.
  96. *
  97. * DAG_on_visible_update will mark all objects that are visible for the first
  98. * time to be updated, for example on file load or changing layer visibility.
  99. *
  100. * DAG_id_tag_update will mark a given datablock to be updated. The flag indicates
  101. * a specific subset to be update (only object transform and data for now).
  102. *
  103. * DAG_id_type_tag marks a particular datablock type as having changing. This does
  104. * not cause any updates but is used by external render engines to detect if for
  105. * example a datablock was removed. */
  106. void DAG_scene_update_flags(struct Main *bmain, struct Scene *sce, unsigned int lay, const bool do_time, const bool do_invisible_flush);
  107. void DAG_on_visible_update(struct Main *bmain, const bool do_time);
  108. void DAG_id_tag_update(struct ID *id, short flag);
  109. void DAG_id_tag_update_ex(struct Main *bmain, struct ID *id, short flag);
  110. void DAG_id_type_tag(struct Main *bmain, short idtype);
  111. int DAG_id_type_tagged(struct Main *bmain, short idtype);
  112. /* Flushing Tags
  113. *
  114. * DAG_scene_flush_update flushes object recalculation flags immediately to other
  115. * dependencies. Do not use outside of depsgraph.c, this will be removed.
  116. *
  117. * DAG_ids_flush_tagged will flush datablock update flags flags to dependencies,
  118. * use this right before updating to mark all the needed datablocks for update.
  119. *
  120. * DAG_ids_check_recalc and DAG_ids_clear_recalc are used for external render
  121. * engines to detect changes. */
  122. void DAG_scene_flush_update(struct Main *bmain, struct Scene *sce, unsigned int lay, const short do_time);
  123. void DAG_ids_flush_tagged(struct Main *bmain);
  124. void DAG_ids_check_recalc(struct Main *bmain, struct Scene *scene, bool time);
  125. void DAG_ids_clear_recalc(struct Main *bmain);
  126. /* Armature: sorts the bones according to dependencies between them */
  127. void DAG_pose_sort(struct Object *ob);
  128. /* Editors: callbacks to notify editors of datablock changes */
  129. void DAG_editors_update_cb(void (*id_func)(struct Main *bmain, struct ID *id),
  130. void (*scene_func)(struct Main *bmain, struct Scene *scene, int updated),
  131. void (*scene_pre_func)(struct Main *bmain, struct Scene *scene, bool time));
  132. void DAG_editors_update_pre(struct Main *bmain, struct Scene *scene, bool time);
  133. /* ** Threaded update ** */
  134. /* Initialize the DAG for threaded update. */
  135. void DAG_threaded_update_begin(struct Scene *scene,
  136. void (*func)(void *node, void *user_data),
  137. void *user_data);
  138. void DAG_threaded_update_handle_node_updated(void *node_v,
  139. void (*func)(void *node, void *user_data),
  140. void *user_data);
  141. /* Debugging: print dependency graph for scene or armature object to console */
  142. void DAG_print_dependencies(struct Main *bmain, struct Scene *scene, struct Object *ob);
  143. /* ************************ DAG querying ********************* */
  144. struct Object *DAG_get_node_object(void *node_v);
  145. const char *DAG_get_node_name(struct Scene *scene, void *node_v);
  146. short DAG_get_eval_flags_for_object(struct Scene *scene, void *object);
  147. bool DAG_is_acyclic(struct Scene *scene);
  148. #ifdef __cplusplus
  149. }
  150. #endif
  151. #endif