Blender  V2.93
node_geo_edge_split.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 "DNA_modifier_types.h"
18 
19 #include "node_geometry_util.hh"
20 
21 extern "C" {
23 }
24 
26  {SOCK_GEOMETRY, N_("Geometry")},
27  {SOCK_BOOLEAN, N_("Edge Angle"), true},
28  {SOCK_FLOAT,
29  N_("Angle"),
30  DEG2RADF(30.0f),
31  0.0f,
32  0.0f,
33  0.0f,
34  0.0f,
35  DEG2RADF(180.0f),
36  PROP_ANGLE},
37  {SOCK_BOOLEAN, N_("Sharp Edges")},
38  {-1, ""},
39 };
40 
42  {SOCK_GEOMETRY, N_("Geometry")},
43  {-1, ""},
44 };
45 
46 namespace blender::nodes {
48 {
49  GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
50 
51  geometry_set = geometry_set_realize_instances(geometry_set);
52 
53  if (!geometry_set.has_mesh()) {
54  params.set_output("Geometry", std::move(geometry_set));
55  return;
56  }
57 
58  const bool use_sharp_flag = params.extract_input<bool>("Sharp Edges");
59  const bool use_edge_angle = params.extract_input<bool>("Edge Angle");
60 
61  if (!use_edge_angle && !use_sharp_flag) {
62  params.set_output("Geometry", std::move(geometry_set));
63  return;
64  }
65 
66  const float split_angle = params.extract_input<float>("Angle");
67  const Mesh *mesh_in = geometry_set.get_mesh_for_read();
68 
69  /* Use modifier struct to pass arguments to the modifier code. */
71  memset(&emd, 0, sizeof(EdgeSplitModifierData));
72  emd.split_angle = split_angle;
73  if (use_edge_angle) {
75  }
76  if (use_sharp_flag) {
78  }
79 
80  Mesh *mesh_out = doEdgeSplit(mesh_in, &emd);
81  geometry_set.replace_mesh(mesh_out);
82 
83  params.set_output("Geometry", std::move(geometry_set));
84 }
85 } // namespace blender::nodes
86 
88 {
89  static bNodeType ntype;
90 
94  nodeRegisterType(&ntype);
95 }
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
Definition: node.cc:4527
#define NODE_CLASS_GEOMETRY
Definition: BKE_node.h:359
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1298
#define DEG2RADF(_deg)
#define N_(msgid)
@ MOD_EDGESPLIT_FROMANGLE
@ MOD_EDGESPLIT_FROMFLAG
@ SOCK_BOOLEAN
@ SOCK_FLOAT
@ SOCK_GEOMETRY
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky Noise Wave Voronoi Brick Texture Vector Combine Vertex Separate Vector White RGB Map Separate Set Z Dilate Combine Combine Color Channel Split ID Combine Luminance Directional Alpha Distance Hue Movie Ellipse Bokeh View Corner Anti Mix RGB Hue Separate TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC Boolean Random GEO_NODE_EDGE_SPLIT
@ PROP_ANGLE
Definition: RNA_types.h:132
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
GeometrySet geometry_set_realize_instances(const GeometrySet &geometry_set)
static void geo_node_edge_split_exec(GeoNodeExecParams params)
static bNodeSocketTemplate geo_node_edge_split_out[]
void register_node_type_geo_edge_split()
static bNodeSocketTemplate geo_node_edge_split_in[]
Mesh * doEdgeSplit(const Mesh *mesh, EdgeSplitModifierData *emd)
Definition: MOD_edgesplit.c:59
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
const Mesh * get_mesh_for_read() const
bool has_mesh() const
Compact definition of a node socket.
Definition: BKE_node.h:95
Defines a node type.
Definition: BKE_node.h:221
NodeGeometryExecFunction geometry_node_execute
Definition: BKE_node.h:327