Blender  V2.93
node_geometry_util.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #include "node_geometry_util.hh"
18 #include "node_util.h"
19 
20 #include "DNA_mesh_types.h"
21 #include "DNA_meshdata_types.h"
22 
23 #include "BKE_mesh.h"
24 #include "BKE_mesh_runtime.h"
25 #include "BKE_pointcloud.h"
26 
27 namespace blender::nodes {
28 
29 using bke::GeometryInstanceGroup;
30 
39  const StringRef name,
41  const bool name_is_available)
42 {
44  LISTBASE_FOREACH (bNodeSocket *, socket, &node.inputs) {
45  if (name == socket->name) {
46  const bool socket_is_available =
47  name_is_available &&
48  ((socket->type == SOCK_STRING && mode_ == GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE) ||
49  (socket->type == SOCK_FLOAT && mode_ == GEO_NODE_ATTRIBUTE_INPUT_FLOAT) ||
50  (socket->type == SOCK_VECTOR && mode_ == GEO_NODE_ATTRIBUTE_INPUT_VECTOR) ||
51  (socket->type == SOCK_RGBA && mode_ == GEO_NODE_ATTRIBUTE_INPUT_COLOR));
53  }
54  }
55 }
56 
57 } // namespace blender::nodes
58 
61  const char **r_disabled_hint)
62 {
63  if (!STREQ(ntree->idname, "GeometryNodeTree")) {
64  *r_disabled_hint = "Not a geometry node tree";
65  return false;
66  }
67  return true;
68 }
69 
70 void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
71 {
72  node_type_base(ntype, type, name, nclass, flag);
73  ntype->poll = geo_node_poll_default;
76 }
void nodeSetSocketAvailability(struct bNodeSocket *sock, bool is_available)
Definition: node.cc:3726
void node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag)
Definition: node.cc:4443
General operations for point-clouds.
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
#define UNUSED(x)
#define STREQ(a, b)
@ SOCK_VECTOR
@ SOCK_FLOAT
@ SOCK_STRING
@ SOCK_RGBA
GeometryNodeAttributeInputMode
@ GEO_NODE_ATTRIBUTE_INPUT_COLOR
@ GEO_NODE_ATTRIBUTE_INPUT_VECTOR
@ GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE
@ GEO_NODE_ATTRIBUTE_INPUT_FLOAT
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
OperationNode * node
bNodeTree * ntree
void update_attribute_input_socket_availabilities(bNode &node, const StringRef name, const GeometryNodeAttributeInputMode mode, const bool name_is_available)
bool geo_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree, const char **r_disabled_hint)
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
static bool socket_is_available(bNodeTree *UNUSED(ntree), bNodeSocket *sock, const bool allow_used)
void node_insert_link_default(bNodeTree *ntree, bNode *node, bNodeLink *link)
Definition: node_util.c:305
void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
Definition: node_util.c:503
char idname[64]
Defines a node type.
Definition: BKE_node.h:221
bool(* poll)(struct bNodeType *ntype, struct bNodeTree *nodetree, const char **r_disabled_hint)
Definition: BKE_node.h:301
void(* update_internal_links)(struct bNodeTree *, struct bNode *node)
Definition: BKE_node.h:312
void(* insert_link)(struct bNodeTree *ntree, struct bNode *node, struct bNodeLink *link)
Definition: BKE_node.h:310