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:
authorJacques Lucke <jacques@blender.org>2022-05-30 16:31:13 +0300
committerJacques Lucke <jacques@blender.org>2022-05-30 16:32:16 +0300
commit6a59cf053091dc45e0f94b829bee6c34cf940534 (patch)
tree92a8cc37cfe3e367846910623c1e82c3d9e4430f /source/blender/blenkernel/BKE_node_runtime.hh
parent1f858772638d61a20add3d4c9cdbb6e20e24ff15 (diff)
Nodes: add separately allocated runtime data for nodes and sockets
This is a follow up to rBbb0fc675822f313c5546a2498a162472c2571ecb. Now the same kind of run-time data is added to nodes and sockets. Differential Revision: https://developer.blender.org/D15060
Diffstat (limited to 'source/blender/blenkernel/BKE_node_runtime.hh')
-rw-r--r--source/blender/blenkernel/BKE_node_runtime.hh51
1 files changed, 50 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_node_runtime.hh b/source/blender/blenkernel/BKE_node_runtime.hh
index c9c4577a2d4..c835279061c 100644
--- a/source/blender/blenkernel/BKE_node_runtime.hh
+++ b/source/blender/blenkernel/BKE_node_runtime.hh
@@ -9,7 +9,8 @@
namespace blender::nodes {
struct FieldInferencingInterface;
-}
+struct NodeDeclaration;
+} // namespace blender::nodes
namespace blender::bke {
@@ -37,4 +38,52 @@ class bNodeTreeRuntime : NonCopyable, NonMovable {
std::unique_ptr<nodes::FieldInferencingInterface> field_inferencing_interface;
};
+/**
+ * Run-time data for every socket. This should only contain data that is somewhat persistent (i.e.
+ * data that lives longer than a single depsgraph evaluation + redraw). Data that's only used in
+ * smaller scopes should generally be stored in separate arrays and/or maps.
+ */
+class bNodeSocketRuntime : NonCopyable, NonMovable {
+ public:
+ /**
+ * References a socket declaration that is owned by `node->declaration`. This is only runtime
+ * data. It has to be updated when the node declaration changes.
+ */
+ const SocketDeclarationHandle *declaration = nullptr;
+
+ /** #eNodeTreeChangedFlag. */
+ uint32_t changed_flag = 0;
+};
+
+/**
+ * Run-time data for every node. This should only contain data that is somewhat persistent (i.e.
+ * data that lives longer than a single depsgraph evaluation + redraw). Data that's only used in
+ * smaller scopes should generally be stored in separate arrays and/or maps.
+ */
+class bNodeRuntime : NonCopyable, NonMovable {
+ public:
+ /**
+ * Describes the desired interface of the node. This is run-time data only.
+ * The actual interface of the node may deviate from the declaration temporarily.
+ * It's possible to sync the actual state of the node to the desired state. Currently, this is
+ * only done when a node is created or loaded.
+ *
+ * In the future, we may want to keep more data only in the declaration, so that it does not have
+ * to be synced to other places that are stored in files. That especially applies to data that
+ * can't be edited by users directly (e.g. min/max values of sockets, tooltips, ...).
+ *
+ * The declaration of a node can be recreated at any time when it is used. Caching it here is
+ * just a bit more efficient when it is used a lot. To make sure that the cache is up-to-date,
+ * call #nodeDeclarationEnsure before using it.
+ *
+ * Currently, the declaration is the same for every node of the same type. Going forward, that is
+ * intended to change though. Especially when nodes become more dynamic with respect to how many
+ * sockets they have.
+ */
+ NodeDeclarationHandle *declaration = nullptr;
+
+ /** #eNodeTreeChangedFlag. */
+ uint32_t changed_flag = 0;
+};
+
} // namespace blender::bke