Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/node.cc34
-rw-r--r--source/blender/blenkernel/intern/node_tree_update.cc18
2 files changed, 31 insertions, 21 deletions
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 95a514ef474..cf50e8a3b43 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -95,6 +95,8 @@ using blender::Stack;
using blender::StringRef;
using blender::Vector;
using blender::VectorSet;
+using blender::bke::bNodeRuntime;
+using blender::bke::bNodeSocketRuntime;
using blender::bke::bNodeTreeRuntime;
using blender::nodes::FieldInferencingInterface;
using blender::nodes::InputSocketFieldType;
@@ -662,7 +664,7 @@ static void direct_link_node_socket(BlendDataReader *reader, bNodeSocket *sock)
BLO_read_data_address(reader, &sock->default_attribute_name);
sock->total_inputs = 0; /* Clear runtime data set before drawing. */
sock->cache = nullptr;
- sock->declaration = nullptr;
+ sock->runtime = MEM_new<bNodeSocketRuntime>(__func__);
}
void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
@@ -682,8 +684,8 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
BLO_read_list(reader, &ntree->nodes);
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
+ node->runtime = MEM_new<bNodeRuntime>(__func__);
node->typeinfo = nullptr;
- node->declaration = nullptr;
BLO_read_list(reader, &node->inputs);
BLO_read_list(reader, &node->outputs);
@@ -1514,6 +1516,7 @@ static bNodeSocket *make_socket(bNodeTree *ntree,
unique_identifier_check, lb, "socket", '_', auto_identifier, sizeof(auto_identifier));
bNodeSocket *sock = MEM_cnew<bNodeSocket>("sock");
+ sock->runtime = MEM_new<bNodeSocketRuntime>(__func__);
sock->in_out = in_out;
BLI_strncpy(sock->identifier, auto_identifier, NODE_MAXSTR);
@@ -1919,6 +1922,7 @@ static void node_socket_free(bNodeSocket *sock, const bool do_id_user)
}
MEM_freeN(sock->default_value);
}
+ MEM_delete(sock->runtime);
}
void nodeRemoveSocket(bNodeTree *ntree, bNode *node, bNodeSocket *sock)
@@ -2124,6 +2128,7 @@ void nodeUniqueName(bNodeTree *ntree, bNode *node)
bNode *nodeAddNode(const struct bContext *C, bNodeTree *ntree, const char *idname)
{
bNode *node = MEM_cnew<bNode>("new node");
+ node->runtime = MEM_new<bNodeRuntime>(__func__);
BLI_addtail(&ntree->nodes, node);
BLI_strncpy(node->idname, idname, sizeof(node->idname));
@@ -2161,6 +2166,7 @@ bNode *nodeAddStaticNode(const struct bContext *C, bNodeTree *ntree, int type)
static void node_socket_copy(bNodeSocket *sock_dst, const bNodeSocket *sock_src, const int flag)
{
+ sock_dst->runtime = MEM_new<bNodeSocketRuntime>(__func__);
if (sock_src->prop) {
sock_dst->prop = IDP_CopyProperty_ex(sock_src->prop, flag);
}
@@ -2193,6 +2199,8 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree,
bNode *node_dst = (bNode *)MEM_mallocN(sizeof(bNode), __func__);
*node_dst = node_src;
+ node_dst->runtime = MEM_new<bNodeRuntime>(__func__);
+
/* Can be called for nodes outside a node tree (e.g. clipboard). */
if (dst_tree) {
if (unique_name) {
@@ -2253,7 +2261,6 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree,
}
/* Reset the declaration of the new node. */
- node_dst->declaration = nullptr;
nodeDeclarationEnsure(dst_tree, node_dst);
return node_dst;
@@ -2972,9 +2979,10 @@ static void node_free_node(bNodeTree *ntree, bNode *node)
}
if (node->typeinfo->declaration_is_dynamic) {
- delete node->declaration;
+ delete node->runtime->declaration;
}
+ MEM_delete(node->runtime);
MEM_freeN(node);
if (ntree) {
@@ -3066,6 +3074,7 @@ static void node_socket_interface_free(bNodeTree *UNUSED(ntree),
}
MEM_freeN(sock->default_value);
}
+ MEM_delete(sock->runtime);
}
static void free_localized_node_groups(bNodeTree *ntree)
@@ -3292,6 +3301,7 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
}
bNodeSocket *sock = MEM_cnew<bNodeSocket>("socket template");
+ sock->runtime = MEM_new<bNodeSocketRuntime>(__func__);
BLI_strncpy(sock->idname, stype->idname, sizeof(sock->idname));
sock->in_out = in_out;
sock->type = SOCK_CUSTOM; /* int type undefined by default */
@@ -3679,34 +3689,34 @@ static void update_socket_declarations(ListBase *sockets,
int index;
LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, sockets, index) {
const SocketDeclaration &socket_decl = *declarations[index];
- socket->declaration = &socket_decl;
+ socket->runtime->declaration = &socket_decl;
}
}
void nodeSocketDeclarationsUpdate(bNode *node)
{
- BLI_assert(node->declaration != nullptr);
- update_socket_declarations(&node->inputs, node->declaration->inputs());
- update_socket_declarations(&node->outputs, node->declaration->outputs());
+ BLI_assert(node->runtime->declaration != nullptr);
+ update_socket_declarations(&node->inputs, node->runtime->declaration->inputs());
+ update_socket_declarations(&node->outputs, node->runtime->declaration->outputs());
}
bool nodeDeclarationEnsureOnOutdatedNode(bNodeTree *UNUSED(ntree), bNode *node)
{
- if (node->declaration != nullptr) {
+ if (node->runtime->declaration != nullptr) {
return false;
}
if (node->typeinfo->declare == nullptr) {
return false;
}
if (node->typeinfo->declaration_is_dynamic) {
- node->declaration = new blender::nodes::NodeDeclaration();
- blender::nodes::NodeDeclarationBuilder builder{*node->declaration};
+ node->runtime->declaration = new blender::nodes::NodeDeclaration();
+ blender::nodes::NodeDeclarationBuilder builder{*node->runtime->declaration};
node->typeinfo->declare(builder);
}
else {
/* Declaration should have been created in #nodeRegisterType. */
BLI_assert(node->typeinfo->fixed_declaration != nullptr);
- node->declaration = node->typeinfo->fixed_declaration;
+ node->runtime->declaration = node->typeinfo->fixed_declaration;
}
return true;
}
diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc
index d4b7f695ee1..019ab114b83 100644
--- a/source/blender/blenkernel/intern/node_tree_update.cc
+++ b/source/blender/blenkernel/intern/node_tree_update.cc
@@ -55,13 +55,13 @@ static void add_tree_tag(bNodeTree *ntree, const eNodeTreeChangedFlag flag)
static void add_node_tag(bNodeTree *ntree, bNode *node, const eNodeTreeChangedFlag flag)
{
add_tree_tag(ntree, flag);
- node->changed_flag |= flag;
+ node->runtime->changed_flag |= flag;
}
static void add_socket_tag(bNodeTree *ntree, bNodeSocket *socket, const eNodeTreeChangedFlag flag)
{
add_tree_tag(ntree, flag);
- socket->changed_flag |= flag;
+ socket->runtime->changed_flag |= flag;
}
namespace blender::bke {
@@ -1082,7 +1082,7 @@ class NodeTreeMainUpdater {
if (ntree.runtime->changed_flag & NTREE_CHANGED_ANY) {
return true;
}
- if (bnode.changed_flag & NTREE_CHANGED_NODE_PROPERTY) {
+ if (bnode.runtime->changed_flag & NTREE_CHANGED_NODE_PROPERTY) {
return true;
}
if (ntree.runtime->changed_flag & NTREE_CHANGED_LINK) {
@@ -1542,12 +1542,12 @@ class NodeTreeMainUpdater {
const NodeRef &node = in_out_socket.node();
const bNode &bnode = *node.bnode();
const bNodeSocket &bsocket = *in_out_socket.bsocket();
- if (bsocket.changed_flag != NTREE_CHANGED_NOTHING) {
+ if (bsocket.runtime->changed_flag != NTREE_CHANGED_NOTHING) {
return true;
}
- if (bnode.changed_flag != NTREE_CHANGED_NOTHING) {
+ if (bnode.runtime->changed_flag != NTREE_CHANGED_NOTHING) {
const bool only_unused_internal_link_changed = (bnode.flag & NODE_MUTED) == 0 &&
- bnode.changed_flag ==
+ bnode.runtime->changed_flag ==
NTREE_CHANGED_INTERNAL_LINK;
if (!only_unused_internal_link_changed) {
return true;
@@ -1595,13 +1595,13 @@ class NodeTreeMainUpdater {
{
ntree.runtime->changed_flag = NTREE_CHANGED_NOTHING;
LISTBASE_FOREACH (bNode *, node, &ntree.nodes) {
- node->changed_flag = NTREE_CHANGED_NOTHING;
+ node->runtime->changed_flag = NTREE_CHANGED_NOTHING;
node->update = 0;
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
- socket->changed_flag = NTREE_CHANGED_NOTHING;
+ socket->runtime->changed_flag = NTREE_CHANGED_NOTHING;
}
LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
- socket->changed_flag = NTREE_CHANGED_NOTHING;
+ socket->runtime->changed_flag = NTREE_CHANGED_NOTHING;
}
}
}