Merge remote-tracking branch 'origin/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 {
51 }
52
53 OperationDepsNode::~OperationDepsNode()
54 {
55 }
56
57 string OperationDepsNode::identifier() const
58 {
59         return string(operationCodeAsString(opcode)) + "(" + name + ")";
60 }
61
62 /* Full node identifier, including owner name.
63  * used for logging and debug prints.
64  */
65 string OperationDepsNode::full_identifier() const
66 {
67         string owner_str = "";
68         if (owner->type == DEG_NODE_TYPE_BONE) {
69                 owner_str = string(owner->owner->name) + "." + owner->name;
70         }
71         else {
72                 owner_str = owner->owner->name;
73         }
74         return owner_str + "." + identifier();
75 }
76
77 void OperationDepsNode::tag_update(Depsgraph *graph, eDepsTag_Source source)
78 {
79         if ((flag & DEPSOP_FLAG_NEEDS_UPDATE) == 0) {
80                 graph->add_entry_tag(this);
81         }
82         /* Tag for update, but also note that this was the source of an update. */
83         flag |= (DEPSOP_FLAG_NEEDS_UPDATE | DEPSOP_FLAG_DIRECTLY_MODIFIED);
84         switch (source) {
85                 case DEG_UPDATE_SOURCE_TIME:
86                 case DEG_UPDATE_SOURCE_RELATIONS:
87                 case DEG_UPDATE_SOURCE_VISIBILITY:
88                         /* Currently nothing. */
89                         break;
90                 case DEG_UPDATE_SOURCE_USER_EDIT:
91                         flag |= DEPSOP_FLAG_USER_MODIFIED;
92                         break;
93         }
94 }
95
96 void OperationDepsNode::set_as_entry()
97 {
98         BLI_assert(owner != NULL);
99         owner->set_entry_operation(this);
100 }
101
102 void OperationDepsNode::set_as_exit()
103 {
104         BLI_assert(owner != NULL);
105         owner->set_exit_operation(this);
106 }
107
108 DEG_DEPSNODE_DEFINE(OperationDepsNode, DEG_NODE_TYPE_OPERATION, "Operation");
109 static DepsNodeFactoryImpl<OperationDepsNode> DNTI_OPERATION;
110
111 void deg_register_operation_depsnodes()
112 {
113         deg_register_node_typeinfo(&DNTI_OPERATION);
114 }
115
116 }  // namespace DEG