[Bf-blender-cvs] [dddcf1e9bbf] temp-compact-node-prototype: Merge branch 'master' into temp-compact-node-prototype
Jacques Lucke
noreply at git.blender.org
Mon Jun 14 12:44:21 CEST 2021
Commit: dddcf1e9bbf4a6d1f4ff03eaf0cb7e9228b18ec5
Author: Jacques Lucke
Date: Mon Jun 14 12:44:13 2021 +0200
Branches: temp-compact-node-prototype
https://developer.blender.org/rBdddcf1e9bbf4a6d1f4ff03eaf0cb7e9228b18ec5
Merge branch 'master' into temp-compact-node-prototype
===================================================================
===================================================================
diff --cc release/scripts/startup/bl_operators/node.py
index 52484f8ffc8,6150789ea10..17e17273432
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@@ -302,28 -305,65 +305,86 @@@ class NODE_OT_tree_path_parent(Operator
return {'FINISHED'}
-
+class NODE_OT_expose_input_socket(Operator):
+ '''Expose socket'''
+ bl_idname = "node.expose_input_socket"
+ bl_label = "Expose Input Socket"
+
+ tree_name: StringProperty()
+ node_name: StringProperty()
+ # Might reference multiple sockets intentionally.
+ socket_name: StringProperty()
+
+ expose: BoolProperty(default=True)
+
+ def execute(self, context):
+ tree = bpy.data.node_groups[self.tree_name]
+ node = tree.nodes[self.node_name]
+ for socket in node.inputs:
+ if socket.name == self.socket_name:
+ socket.hide = not self.expose
+ return {'FINISHED'}
+
+ class NODE_OT_active_preview_toggle(Operator):
+ '''Toggle active preview state of node'''
+ bl_idname = "node.active_preview_toggle"
+ bl_label = "Toggle Active Preview"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ @classmethod
+ def poll(cls, context):
+ space = context.space_data
+ if space is None:
+ return False
+ if space.type != 'NODE_EDITOR':
+ return False
+ if space.edit_tree is None:
+ return False
+ if space.edit_tree.nodes.active is None:
+ return False
+ return True
+
+ def execute(self, context):
+ node_editor = context.space_data
+ ntree = node_editor.edit_tree
+ active_node = ntree.nodes.active
+
+ if active_node.active_preview:
+ self.disable_preview(context, ntree, active_node)
+ else:
+ self.enable_preview(context, node_editor, ntree, active_node)
+
+ return {'FINISHED'}
+
+ def enable_preview(self, context, node_editor, ntree, active_node):
+ spreadsheets = self.find_unpinned_spreadsheets(context)
+
+ for spreadsheet in spreadsheets:
+ spreadsheet.set_geometry_node_context(node_editor, active_node)
+
+ for node in ntree.nodes:
+ node.active_preview = False
+ active_node.active_preview = True
+
+ def disable_preview(self, context, ntree, active_node):
+ spreadsheets = self.find_unpinned_spreadsheets(context)
+ for spreadsheet in spreadsheets:
+ spreadsheet.context_path.clear()
+
+ active_node.active_preview = False
+
+ def find_unpinned_spreadsheets(self, context):
+ spreadsheets = []
+ for window in context.window_manager.windows:
+ for area in window.screen.areas:
+ space = area.spaces.active
+ if space.type == 'SPREADSHEET' and not space.is_pinned:
+ spreadsheets.append(space)
+ return spreadsheets
+
+
++
classes = (
NodeSetting,
@@@ -332,5 -372,5 +393,6 @@@
NODE_OT_add_search,
NODE_OT_collapse_hide_unused_toggle,
NODE_OT_tree_path_parent,
+ NODE_OT_expose_input_socket,
+ NODE_OT_active_preview_toggle,
)
diff --cc source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
index cbe44c54fb4,389abe3b2aa..51fd65f65fd
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
@@@ -14,19 -14,11 +14,24 @@@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "node_geometry_util.hh"
+
+#include "BLI_heap_value.hh"
+#include "BLI_rand.hh"
+
+#include "DNA_mesh_types.h"
+#include "DNA_pointcloud_types.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "WM_types.h"
+
+ #include "UI_interface.h"
+ #include "UI_resources.h"
+
+ #include "node_geometry_util.hh"
+
static bNodeSocketTemplate geo_node_attribute_fill_in[] = {
{SOCK_GEOMETRY, N_("Geometry")},
{SOCK_STRING, N_("Attribute")},
@@@ -74,127 -68,12 +79,126 @@@ static void geo_node_attribute_fill_upd
namespace blender::nodes {
+struct SocketMenuInfo {
+ bNodeTree *ntree;
+ bNode *node;
+ bNodeSocket *socket;
+ std::string enum_name;
+
+ uint64_t hash() const
+ {
+ return get_default_hash_3(ntree, node, socket);
+ }
+
+ friend bool operator==(const SocketMenuInfo &a, const SocketMenuInfo &b)
+ {
+ return a.ntree == b.ntree && a.node == b.node && a.socket == b.socket;
+ }
+};
+
+static Set<HeapValue<SocketMenuInfo>> &get_socket_menu_info_set()
+{
+ static Set<HeapValue<SocketMenuInfo>> set;
+ return set;
+}
+
+static void draw_socket_menu(bContext *UNUSED(C), uiLayout *layout, void *arg)
+{
+ SocketMenuInfo *socket_info = (SocketMenuInfo *)arg;
+
+ PointerRNA node_ptr;
+ RNA_pointer_create(&socket_info->ntree->id, &RNA_Node, socket_info->node, &node_ptr);
+ PointerRNA socket_ptr;
+ RNA_pointer_create(&socket_info->ntree->id, &RNA_NodeSocket, socket_info->socket, &socket_ptr);
+
+ if (socket_info->socket->flag & SOCK_HIDDEN) {
+ PointerRNA expose_props;
+ uiItemFullO(layout,
+ "node.expose_input_socket",
+ "Expose",
+ ICON_TRACKING_BACKWARDS_SINGLE,
+ nullptr,
+ WM_OP_EXEC_DEFAULT,
+ 0,
+ &expose_props);
+ RNA_string_set(&expose_props, "tree_name", socket_info->ntree->id.name + 2);
+ RNA_string_set(&expose_props, "node_name", socket_info->node->name);
+ RNA_string_set(&expose_props, "socket_name", socket_info->socket->name);
+ RNA_boolean_set(&expose_props, "expose", true);
+ }
+ else {
+ uiLayout *col = uiLayoutColumn(layout, false);
+ uiLayoutSetEnabled(col, (socket_info->socket->flag & SOCK_IN_USE) == 0);
+ PointerRNA expose_props;
+ uiItemFullO(col,
+ "node.expose_input_socket",
+ "Unexpose",
+ ICON_TRACKING_CLEAR_BACKWARDS,
+ nullptr,
+ WM_OP_EXEC_DEFAULT,
+ 0,
+ &expose_props);
+ RNA_string_set(&expose_props, "tree_name", socket_info->ntree->id.name + 2);
+ RNA_string_set(&expose_props, "node_name", socket_info->node->name);
+ RNA_string_set(&expose_props, "socket_name", socket_info->socket->name);
+ RNA_boolean_set(&expose_props, "expose", false);
+ }
+
+ if (!socket_info->enum_name.empty()) {
+ uiItemsEnumR(layout, &node_ptr, socket_info->enum_name.c_str());
+ }
+}
+
+void draw_input_socket(bContext *C,
+ uiLayout *layout,
+ PointerRNA *node_ptr,
+ StringRef socket_name,
+ StringRef additional_enum_prop)
+{
+ bNodeTree *ntree = (bNodeTree *)node_ptr->owner_id;
+ bNode *node = (bNode *)node_ptr->data;
+
+ bNodeSocket *socket_to_draw = nullptr;
+ LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
+ if ((socket->flag & SOCK_UNAVAIL) == 0 && socket->name == socket_name) {
+ socket_to_draw = socket;
+ break;
+ }
+ }
+ if (socket_to_draw == nullptr) {
+ return;
+ }
+ PointerRNA socket_ptr;
+ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, socket_to_draw, &socket_ptr);
+
+ SocketMenuInfo info;
+ info.ntree = ntree;
+ info.node = node;
+ info.socket = socket_to_draw;
+ info.enum_name = additional_enum_prop;
+
+ Set<HeapValue<SocketMenuInfo>> &set = get_socket_menu_info_set();
+ const SocketMenuInfo *stored_info = set.lookup_key_or_add_as(info).get();
+ uiLayout *row = uiLayoutRow(layout, false);
+ uiLayout *sub_row = uiLayoutRow(row, false);
+ uiLayoutSetActive(sub_row, (socket_to_draw->flag & SOCK_HIDDEN) != 0);
+ socket_to_draw->typeinfo->draw(C, sub_row, &socket_ptr, node_ptr, socket_to_draw->name);
+ uiItemMenuF(row, "", ICON_DOWNARROW_HLT, draw_socket_menu, (void *)stored_info);
+}
+
+static void geo_node_attribute_fill_layout(uiLayout *layout, bContext *C, PointerRNA *node_ptr)
+{
+ uiItemR(layout, node_ptr, "domain", 0, IFACE_("Domain"), ICON_NONE);
+ draw_input_socket(C, layout, node_ptr, "Attribute");
+ draw_input_socket(C, layout, node_ptr, "Value", "data_type");
+}
+
- static AttributeDomain get_result_domain(const GeometryComponent &component,
- StringRef attribute_name)
+ static AttributeDomain get_result_domain(const GeometryComponent &component, const StringRef name)
{
/* Use the domain of the result attribute if it already exists. */
- ReadAttributePtr result_attribute = component.attribute_try_get_for_read(attribute_name);
- if (result_attribute) {
- return result_attribute->domain();
+ std::optional<AttributeMetaData> result_info = component.attribute_get_meta_data(name);
+ if (result_info) {
+ return result_info->domain;
}
return ATTR_DOMAIN_POINT;
}
diff --cc source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
index ee2fd763ead,b04e04d1cb7..5a5fc099779
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
@@@ -66,10 -59,34 +59,13 @@@ static bool operation_use_input_b(cons
static bool operation_use_input_c(const NodeVectorMathOperation operation)
{
- return ELEM(
- operation, NODE_VECTOR_MATH_WRAP, NODE_VECTOR_MATH_REFRACT, NODE_VECTOR_MATH_FACEFORWARD);
+ return ELEM(operation,
+ NODE_VECTOR_MATH_WRAP,
+ NODE_VECTOR_MATH_REFRACT,
+ NODE_VECTOR_MATH_FACEFORWARD,
+ NODE_VECTOR_MATH_MULTIPLY_ADD);
}
-static void geo_node_attribute_vector_math_layout(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
-{
- bNode *node = (bNode *)ptr->data;
- const NodeAttributeVectorMath &node_storage = *(NodeAttributeVectorMath *)node->storage;
- const NodeVectorMathOperation operation = (const NodeVectorMathOperation
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list