Merge branch 'master' into blender2.8
[blender.git] / source / blender / depsgraph / intern / nodes / deg_node_operation.cc
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) 2013 Blender Foundation.
19  * All rights reserved.
20  *
21  * Original Author: Joshua Leung
22  * Contributor(s): None Yet
23  *
24  * ***** END GPL LICENSE BLOCK *****
25  */
26
27 /** \file blender/depsgraph/intern/nodes/deg_node_operation.cc
28  *  \ingroup depsgraph
29  */
30
31 #include "intern/nodes/deg_node_operation.h"
32
33 #include "MEM_guardedalloc.h"
34
35 #include "BLI_utildefines.h"
36 #include "BLI_ghash.h"
37
38 #include "intern/depsgraph.h"
39 #include "intern/depsgraph_intern.h"
40 #include "intern/nodes/deg_node_id.h"
41
42 namespace DEG {
43
44 /* *********** */
45 /* Inner Nodes */
46
47 OperationDepsNode::OperationDepsNode() :
48     name_tag(-1),
49     flag(0),
50     customdata_mask(0)
51 {
52 }
53
54 OperationDepsNode::~OperationDepsNode()
55 {
56 }
57
58 string OperationDepsNode::identifier() const
59 {
60         return string(operationCodeAsString(opcode)) + "(" + name + ")";
61 }
62
63 /* Full node identifier, including owner name.
64  * used for logging and debug prints.
65  */
66 string OperationDepsNode::full_identifier() const
67 {
68         string owner_str = "";
69         if (owner->type == DEG_NODE_TYPE_BONE) {
70                 owner_str = string(owner->owner->name) + "." + owner->name;
71         }
72         else {
73                 owner_str = owner->owner->name;
74         }
75         return owner_str + "." + identifier();
76 }
77
78 void OperationDepsNode::tag_update(Depsgraph *graph, eDepsTag_Source source)
79 {
80         if ((flag & DEPSOP_FLAG_NEEDS_UPDATE) == 0) {
81                 graph->add_entry_tag(this);
82         }
83         /* Tag for update, but also note that this was the source of an update. */
84         flag |= (DEPSOP_FLAG_NEEDS_UPDATE | DEPSOP_FLAG_DIRECTLY_MODIFIED);
85         switch (source) {
86                 case DEG_UPDATE_SOURCE_TIME:
87                 case DEG_UPDATE_SOURCE_RELATIONS:
88                 case DEG_UPDATE_SOURCE_VISIBILITY:
89                         /* Currently nothing. */
90                         break;
91                 case DEG_UPDATE_SOURCE_USER_EDIT:
92                         flag |= DEPSOP_FLAG_USER_MODIFIED;
93                         break;
94         }
95 }
96
97 void OperationDepsNode::set_as_entry()
98 {
99         BLI_assert(owner != NULL);
100         owner->set_entry_operation(this);
101 }
102
103 void OperationDepsNode::set_as_exit()
104 {
105         BLI_assert(owner != NULL);
106         owner->set_exit_operation(this);
107 }
108
109 DEG_DEPSNODE_DEFINE(OperationDepsNode, DEG_NODE_TYPE_OPERATION, "Operation");
110 static DepsNodeFactoryImpl<OperationDepsNode> DNTI_OPERATION;
111
112 void deg_register_operation_depsnodes()
113 {
114         deg_register_node_typeinfo(&DNTI_OPERATION);
115 }
116
117 }  // namespace DEG