2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #include "NOD_node_tree_dependencies.hh"
19 #include "DNA_node_types.h"
23 namespace blender::nodes {
25 static void add_dependencies_of_node_tree(bNodeTree &ntree, NodeTreeDependencies &r_dependencies)
27 /* TODO: Do a bit more sophisticated parsing to see which dependencies are really required. */
28 LISTBASE_FOREACH (bNode *, node, &ntree.nodes) {
29 LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
30 if (socket->type == SOCK_OBJECT) {
31 Object *object = reinterpret_cast<bNodeSocketValueObject *>(socket->default_value)->value;
32 if (object != nullptr) {
33 r_dependencies.add_transform_dependency(object);
34 if (object->type == OB_MESH) {
35 r_dependencies.add_geometry_dependency(object);
41 if (node->type == NODE_GROUP) {
42 bNodeTree *group = reinterpret_cast<bNodeTree *>(node->id);
43 if (group != nullptr) {
44 add_dependencies_of_node_tree(*group, r_dependencies);
50 NodeTreeDependencies find_node_tree_dependencies(bNodeTree &ntree)
52 NodeTreeDependencies dependencies;
53 add_dependencies_of_node_tree(ntree, dependencies);
57 } // namespace blender::nodes