Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_triangulate.cc
| Show All 23 Lines | Mesh *triangulate_mesh(Mesh *mesh, | ||||
| const int quad_method, | const int quad_method, | ||||
| const int ngon_method, | const int ngon_method, | ||||
| const int min_vertices, | const int min_vertices, | ||||
| const int flag); | const int flag); | ||||
| } | } | ||||
| namespace blender::nodes::node_geo_triangulate_cc { | namespace blender::nodes::node_geo_triangulate_cc { | ||||
| static void geo_node_triangulate_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>(N_("Mesh")).supported_type(GEO_COMPONENT_TYPE_MESH); | b.add_input<decl::Geometry>(N_("Mesh")).supported_type(GEO_COMPONENT_TYPE_MESH); | ||||
| b.add_input<decl::Int>(N_("Minimum Vertices")).default_value(4).min(4).max(10000); | b.add_input<decl::Int>(N_("Minimum Vertices")).default_value(4).min(4).max(10000); | ||||
| b.add_output<decl::Geometry>(N_("Mesh")); | b.add_output<decl::Geometry>(N_("Mesh")); | ||||
| } | } | ||||
| static void geo_node_triangulate_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | ||||
| { | { | ||||
| uiItemR(layout, ptr, "quad_method", 0, "", ICON_NONE); | uiItemR(layout, ptr, "quad_method", 0, "", ICON_NONE); | ||||
| uiItemR(layout, ptr, "ngon_method", 0, "", ICON_NONE); | uiItemR(layout, ptr, "ngon_method", 0, "", ICON_NONE); | ||||
| } | } | ||||
| static void geo_triangulate_init(bNodeTree *UNUSED(ntree), bNode *node) | static void geo_triangulate_init(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| node->custom1 = GEO_NODE_TRIANGULATE_QUAD_SHORTEDGE; | node->custom1 = GEO_NODE_TRIANGULATE_QUAD_SHORTEDGE; | ||||
| node->custom2 = GEO_NODE_TRIANGULATE_NGON_BEAUTY; | node->custom2 = GEO_NODE_TRIANGULATE_NGON_BEAUTY; | ||||
| } | } | ||||
| static void geo_node_triangulate_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Mesh"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Mesh"); | ||||
| const int min_vertices = std::max(params.extract_input<int>("Minimum Vertices"), 4); | const int min_vertices = std::max(params.extract_input<int>("Minimum Vertices"), 4); | ||||
| GeometryNodeTriangulateQuads quad_method = static_cast<GeometryNodeTriangulateQuads>( | GeometryNodeTriangulateQuads quad_method = static_cast<GeometryNodeTriangulateQuads>( | ||||
| params.node().custom1); | params.node().custom1); | ||||
| GeometryNodeTriangulateNGons ngon_method = static_cast<GeometryNodeTriangulateNGons>( | GeometryNodeTriangulateNGons ngon_method = static_cast<GeometryNodeTriangulateNGons>( | ||||
| params.node().custom2); | params.node().custom2); | ||||
| Show All 13 Lines | |||||
| void register_node_type_geo_triangulate() | void register_node_type_geo_triangulate() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_triangulate_cc; | namespace file_ns = blender::nodes::node_geo_triangulate_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base(&ntype, GEO_NODE_TRIANGULATE, "Triangulate", NODE_CLASS_GEOMETRY, 0); | geo_node_type_base(&ntype, GEO_NODE_TRIANGULATE, "Triangulate", NODE_CLASS_GEOMETRY, 0); | ||||
| ntype.declare = file_ns::geo_node_triangulate_declare; | ntype.declare = file_ns::node_declare; | ||||
| node_type_init(&ntype, file_ns::geo_triangulate_init); | node_type_init(&ntype, file_ns::geo_triangulate_init); | ||||
| ntype.geometry_node_execute = file_ns::geo_node_triangulate_exec; | ntype.geometry_node_execute = file_ns::node_geo_exec; | ||||
| ntype.draw_buttons = file_ns::geo_node_triangulate_layout; | ntype.draw_buttons = file_ns::node_layout; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||