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:
authorHans Goudey <h.goudey@me.com>2021-02-24 02:15:03 +0300
committerHans Goudey <h.goudey@me.com>2021-02-24 02:15:03 +0300
commitb2c7ea6d82c453cfa35bf754e07dbbf08ae0a018 (patch)
tree7ff8fdb445087a30e130850a3ba197a035980620
parentdde7d4417a850222c2e05bd6fc8f6c354f2515e9 (diff)
Geometry Nodes: Move node UI storage function to BKE
This function will be used in another file with attribute search, so it makes sense to share from the UI storage header.
-rw-r--r--source/blender/blenkernel/BKE_node_ui_storage.hh5
-rw-r--r--source/blender/blenkernel/intern/node_ui_storage.cc26
-rw-r--r--source/blender/editors/space_node/node_draw.cc28
3 files changed, 32 insertions, 27 deletions
diff --git a/source/blender/blenkernel/BKE_node_ui_storage.hh b/source/blender/blenkernel/BKE_node_ui_storage.hh
index 2084382aac5..951c3bdc62d 100644
--- a/source/blender/blenkernel/BKE_node_ui_storage.hh
+++ b/source/blender/blenkernel/BKE_node_ui_storage.hh
@@ -28,6 +28,7 @@ struct ModifierData;
struct Object;
struct bNode;
struct bNodeTree;
+struct bContext;
/**
* Contains the context necessary to determine when to display settings for a certain node tree
@@ -81,6 +82,10 @@ struct NodeTreeUIStorage {
blender::Map<NodeTreeEvaluationContext, blender::Map<std::string, NodeUIStorage>> context_map;
};
+const NodeUIStorage *BKE_node_tree_ui_storage_get_from_context(const bContext *C,
+ const bNodeTree &ntree,
+ const bNode &node);
+
void BKE_nodetree_ui_storage_free_for_context(bNodeTree &ntree,
const NodeTreeEvaluationContext &context);
diff --git a/source/blender/blenkernel/intern/node_ui_storage.cc b/source/blender/blenkernel/intern/node_ui_storage.cc
index 7bf8895262d..e03617a6505 100644
--- a/source/blender/blenkernel/intern/node_ui_storage.cc
+++ b/source/blender/blenkernel/intern/node_ui_storage.cc
@@ -23,7 +23,9 @@
#include "DNA_node_types.h"
#include "DNA_object_types.h"
+#include "BKE_context.h"
#include "BKE_node_ui_storage.hh"
+#include "BKE_object.h"
static CLG_LogRef LOG = {"bke.node_ui_storage"};
@@ -38,6 +40,30 @@ static void ui_storage_ensure(bNodeTree &ntree)
}
}
+const NodeUIStorage *BKE_node_tree_ui_storage_get_from_context(const bContext *C,
+ const bNodeTree &ntree,
+ const bNode &node)
+{
+ const NodeTreeUIStorage *ui_storage = ntree.ui_storage;
+ if (ui_storage == nullptr) {
+ return nullptr;
+ }
+
+ const Object *active_object = CTX_data_active_object(C);
+ const ModifierData *active_modifier = BKE_object_active_modifier(active_object);
+ if (active_object == nullptr || active_modifier == nullptr) {
+ return nullptr;
+ }
+
+ const NodeTreeEvaluationContext context(*active_object, *active_modifier);
+ const Map<std::string, NodeUIStorage> *storage = ui_storage->context_map.lookup_ptr(context);
+ if (storage == nullptr) {
+ return nullptr;
+ }
+
+ return storage->lookup_ptr_as(StringRef(node.name));
+}
+
/**
* Removes only the UI data associated with a particular evaluation context. The same node tree
* can be used for execution in multiple places, but the entire UI storage can't be removed when
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index d0b62463ad9..40d62b0b10f 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -81,9 +81,7 @@
# include "COM_compositor.h"
#endif
-using blender::Map;
using blender::Span;
-using blender::StringRef;
using blender::Vector;
extern "C" {
@@ -1254,34 +1252,10 @@ static char *node_errors_tooltip_fn(bContext *UNUSED(C), void *argN, const char
#define NODE_HEADER_ICON_SIZE (0.8f * U.widget_unit)
-static const NodeUIStorage *node_ui_storage_get_from_context(const bContext *C,
- const bNodeTree &ntree,
- const bNode &node)
-{
- const NodeTreeUIStorage *ui_storage = ntree.ui_storage;
- if (ui_storage == nullptr) {
- return nullptr;
- }
-
- const Object *active_object = CTX_data_active_object(C);
- const ModifierData *active_modifier = BKE_object_active_modifier(active_object);
- if (active_object == nullptr || active_modifier == nullptr) {
- return nullptr;
- }
-
- const NodeTreeEvaluationContext context(*active_object, *active_modifier);
- const Map<std::string, NodeUIStorage> *storage = ui_storage->context_map.lookup_ptr(context);
- if (storage == nullptr) {
- return nullptr;
- }
-
- return storage->lookup_ptr_as(StringRef(node.name));
-}
-
static void node_add_error_message_button(
const bContext *C, bNodeTree &ntree, bNode &node, const rctf &rect, float &icon_offset)
{
- const NodeUIStorage *node_ui_storage = node_ui_storage_get_from_context(C, ntree, node);
+ const NodeUIStorage *node_ui_storage = BKE_node_tree_ui_storage_get_from_context(C, ntree, node);
if (node_ui_storage == nullptr || node_ui_storage->warnings.is_empty()) {
return;
}