Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
| Show All 23 Lines | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_subdivision_surface_cc { | namespace blender::nodes::node_geo_subdivision_surface_cc { | ||||
| static void geo_node_subdivision_surface_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_("Level")).default_value(1).min(0).max(6); | b.add_input<decl::Int>(N_("Level")).default_value(1).min(0).max(6); | ||||
| b.add_input<decl::Float>(N_("Crease")) | b.add_input<decl::Float>(N_("Crease")) | ||||
| .default_value(0.0f) | .default_value(0.0f) | ||||
| .min(0.0f) | .min(0.0f) | ||||
| .max(1.0f) | .max(1.0f) | ||||
| .supports_field() | .supports_field() | ||||
| .subtype(PROP_FACTOR); | .subtype(PROP_FACTOR); | ||||
| b.add_output<decl::Geometry>(N_("Mesh")); | b.add_output<decl::Geometry>(N_("Mesh")); | ||||
| } | } | ||||
| static void geo_node_subdivision_surface_layout(uiLayout *layout, | static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | ||||
| bContext *UNUSED(C), | |||||
| PointerRNA *ptr) | |||||
| { | { | ||||
| uiItemR(layout, ptr, "uv_smooth", 0, "", ICON_NONE); | uiItemR(layout, ptr, "uv_smooth", 0, "", ICON_NONE); | ||||
| uiItemR(layout, ptr, "boundary_smooth", 0, "", ICON_NONE); | uiItemR(layout, ptr, "boundary_smooth", 0, "", ICON_NONE); | ||||
| } | } | ||||
| static void geo_node_subdivision_surface_init(bNodeTree *UNUSED(ntree), bNode *node) | static void node_init(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| NodeGeometrySubdivisionSurface *data = (NodeGeometrySubdivisionSurface *)MEM_callocN( | NodeGeometrySubdivisionSurface *data = (NodeGeometrySubdivisionSurface *)MEM_callocN( | ||||
| sizeof(NodeGeometrySubdivisionSurface), __func__); | sizeof(NodeGeometrySubdivisionSurface), __func__); | ||||
| data->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES; | data->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES; | ||||
| data->boundary_smooth = SUBSURF_BOUNDARY_SMOOTH_ALL; | data->boundary_smooth = SUBSURF_BOUNDARY_SMOOTH_ALL; | ||||
| node->storage = data; | node->storage = data; | ||||
| } | } | ||||
| static void geo_node_subdivision_surface_exec(GeoNodeExecParams params) | static void node_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Mesh"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Mesh"); | ||||
| #ifndef WITH_OPENSUBDIV | #ifndef WITH_OPENSUBDIV | ||||
| params.error_message_add(NodeWarningType::Error, | params.error_message_add(NodeWarningType::Error, | ||||
| TIP_("Disabled, Blender was compiled without OpenSubdiv")); | TIP_("Disabled, Blender was compiled without OpenSubdiv")); | ||||
| #else | #else | ||||
| Field<float> crease_field = params.extract_input<Field<float>>("Crease"); | Field<float> crease_field = params.extract_input<Field<float>>("Crease"); | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | |||||
| void register_node_type_geo_subdivision_surface() | void register_node_type_geo_subdivision_surface() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_subdivision_surface_cc; | namespace file_ns = blender::nodes::node_geo_subdivision_surface_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base( | geo_node_type_base( | ||||
| &ntype, GEO_NODE_SUBDIVISION_SURFACE, "Subdivision Surface", NODE_CLASS_GEOMETRY, 0); | &ntype, GEO_NODE_SUBDIVISION_SURFACE, "Subdivision Surface", NODE_CLASS_GEOMETRY, 0); | ||||
| ntype.declare = file_ns::geo_node_subdivision_surface_declare; | ntype.declare = file_ns::node_declare; | ||||
| ntype.geometry_node_execute = file_ns::geo_node_subdivision_surface_exec; | ntype.geometry_node_execute = file_ns::node_exec; | ||||
| ntype.draw_buttons = file_ns::geo_node_subdivision_surface_layout; | ntype.draw_buttons = file_ns::node_layout; | ||||
| node_type_init(&ntype, file_ns::geo_node_subdivision_surface_init); | node_type_init(&ntype, file_ns::node_init); | ||||
| node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); | node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); | ||||
| node_type_storage(&ntype, | node_type_storage(&ntype, | ||||
| "NodeGeometrySubdivisionSurface", | "NodeGeometrySubdivisionSurface", | ||||
| node_free_standard_storage, | node_free_standard_storage, | ||||
| node_copy_standard_storage); | node_copy_standard_storage); | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||