GPv3: Named Layer Selection node

This node supports either a Layer or a Layer Group name as input,
and outputs a selection field for it.

Known limitations to be addressed separately:

* We are not warning/keeping track of the named layers.
* There is no lookup for layers (groups) yet.

Ref !113908.

Pull Request: https://projects.blender.org/blender/blender/pulls/113908
This commit is contained in:
Dalai Felinto
2023-10-20 11:04:15 +02:00
committed by Gitea
parent 6b7d0fe425
commit e42281084b
5 changed files with 55 additions and 0 deletions

View File

@@ -286,6 +286,8 @@ class NODE_MT_geometry_node_GEO_INPUT_SCENE(Menu):
node_add_menu.add_node_type(layout, "GeometryNodeCollectionInfo")
node_add_menu.add_node_type(layout, "GeometryNodeImageInfo")
node_add_menu.add_node_type(layout, "GeometryNodeIsViewport")
if context.preferences.experimental.use_grease_pencil_version3:
node_add_menu.add_node_type(layout, "GeometryNodeInputNamedLayerSelection")
node_add_menu.add_node_type(layout, "GeometryNodeObjectInfo")
node_add_menu.add_node_type(layout, "GeometryNodeInputSceneTime")
node_add_menu.add_node_type(layout, "GeometryNodeSelfObject")

View File

@@ -1315,6 +1315,7 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i
#define GEO_NODE_POINTS_TO_CURVES 2114
#define GEO_NODE_INPUT_EDGE_SMOOTH 2115
#define GEO_NODE_SPLIT_TO_INSTANCES 2116
#define GEO_NODE_INPUT_NAMED_LAYER_SELECTION 2117
/** \} */

View File

@@ -353,6 +353,7 @@ DefNode(GeometryNode, GEO_NODE_INPUT_MESH_FACE_NEIGHBORS, 0, "MESH_FACE_NEIGHBOR
DefNode(GeometryNode, GEO_NODE_INPUT_MESH_ISLAND, 0, "MESH_ISLAND", InputMeshIsland, "Mesh Island", "Retrieve information about separate connected regions in a mesh")
DefNode(GeometryNode, GEO_NODE_INPUT_MESH_VERTEX_NEIGHBORS, 0, "MESH_VERTEX_NEIGHBORS", InputMeshVertexNeighbors, "Vertex Neighbors", "Retrieve topology information relating to each vertex of a mesh")
DefNode(GeometryNode, GEO_NODE_INPUT_NAMED_ATTRIBUTE, 0, "INPUT_ATTRIBUTE", InputNamedAttribute, "Named Attribute", "Retrieve the data of a specified attribute")
DefNode(GeometryNode, GEO_NODE_INPUT_NAMED_LAYER_SELECTION, 0, "INPUT_NAMED_LAYER_SELECTION", InputNamedLayerSelection, "Named Layer Selection", "Output a selection of a grease pencil layer");
DefNode(GeometryNode, GEO_NODE_INPUT_NORMAL, 0, "INPUT_NORMAL", InputNormal, "Normal", "Retrieve a unit length vector indicating the direction pointing away from the geometry at each element")
DefNode(GeometryNode, GEO_NODE_INPUT_POSITION, 0, "POSITION", InputPosition, "Position", "Retrieve a vector indicating the location of each element")
DefNode(GeometryNode, GEO_NODE_INPUT_RADIUS, 0, "INPUT_RADIUS", InputRadius, "Radius", "Retrieve the radius at each point on curve or point cloud geometry")

View File

@@ -101,6 +101,7 @@ set(SRC
nodes/node_geo_input_mesh_island.cc
nodes/node_geo_input_mesh_vertex_neighbors.cc
nodes/node_geo_input_named_attribute.cc
nodes/node_geo_input_named_layer_selection.cc
nodes/node_geo_input_normal.cc
nodes/node_geo_input_position.cc
nodes/node_geo_input_radius.cc

View File

@@ -0,0 +1,50 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BKE_geometry_fields.hh"
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_input_named_layer_selection__cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::String>("Name");
b.add_output<decl::Bool>("Selection").field_source_reference_all();
}
static void node_geo_exec(GeoNodeExecParams params)
{
std::string name = params.extract_input<std::string>("Name");
if (name.empty()) {
params.set_default_remaining_outputs();
return;
}
Field<bool> selection_field{
std::make_shared<bke::NamedLayerSelectionFieldInput>(std::move(name))};
params.set_output("Selection", std::move(selection_field));
}
static void search_link_ops(GatherLinkSearchOpParams &params)
{
if (U.experimental.use_grease_pencil_version3) {
nodes::search_link_ops_for_basic_node(params);
}
}
static void node_register()
{
static bNodeType ntype;
geo_node_type_base(
&ntype, GEO_NODE_INPUT_NAMED_LAYER_SELECTION, "Named Layer Selection", NODE_CLASS_INPUT);
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
ntype.gather_link_search_ops = search_link_ops;
nodeRegisterType(&ntype);
}
NOD_REGISTER_NODE(node_register)
} // namespace blender::nodes::node_geo_input_named_layer_selection__cc