Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc
| Show All 22 Lines | |||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| using blender::Array; | using blender::Array; | ||||
| namespace blender::nodes::node_geo_mesh_to_points_cc { | namespace blender::nodes::node_geo_mesh_to_points_cc { | ||||
| static void geo_node_mesh_to_points_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::Bool>(N_("Selection")).default_value(true).supports_field().hide_value(); | b.add_input<decl::Bool>(N_("Selection")).default_value(true).supports_field().hide_value(); | ||||
| b.add_input<decl::Vector>(N_("Position")).implicit_field(); | b.add_input<decl::Vector>(N_("Position")).implicit_field(); | ||||
| b.add_input<decl::Float>(N_("Radius")) | b.add_input<decl::Float>(N_("Radius")) | ||||
| .default_value(0.05f) | .default_value(0.05f) | ||||
| .min(0.0f) | .min(0.0f) | ||||
| .subtype(PROP_DISTANCE) | .subtype(PROP_DISTANCE) | ||||
| .supports_field(); | .supports_field(); | ||||
| b.add_output<decl::Geometry>(N_("Points")); | b.add_output<decl::Geometry>(N_("Points")); | ||||
| } | } | ||||
| static void geo_node_mesh_to_points_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | ||||
| { | { | ||||
| uiItemR(layout, ptr, "mode", 0, "", ICON_NONE); | uiItemR(layout, ptr, "mode", 0, "", ICON_NONE); | ||||
| } | } | ||||
| static void geo_node_mesh_to_points_init(bNodeTree *UNUSED(tree), bNode *node) | static void node_init(bNodeTree *UNUSED(tree), bNode *node) | ||||
| { | { | ||||
| NodeGeometryMeshToPoints *data = (NodeGeometryMeshToPoints *)MEM_callocN( | NodeGeometryMeshToPoints *data = (NodeGeometryMeshToPoints *)MEM_callocN( | ||||
| sizeof(NodeGeometryMeshToPoints), __func__); | sizeof(NodeGeometryMeshToPoints), __func__); | ||||
| data->mode = GEO_NODE_MESH_TO_POINTS_VERTICES; | data->mode = GEO_NODE_MESH_TO_POINTS_VERTICES; | ||||
| node->storage = data; | node->storage = data; | ||||
| } | } | ||||
| template<typename T> | template<typename T> | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | if (dst && src) { | ||||
| }); | }); | ||||
| dst.save(); | dst.save(); | ||||
| } | } | ||||
| } | } | ||||
| geometry_set.keep_only({GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_INSTANCES}); | geometry_set.keep_only({GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_INSTANCES}); | ||||
| } | } | ||||
| static void geo_node_mesh_to_points_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"); | ||||
| Field<float3> position = params.extract_input<Field<float3>>("Position"); | Field<float3> position = params.extract_input<Field<float3>>("Position"); | ||||
| Field<float> radius = params.extract_input<Field<float>>("Radius"); | Field<float> radius = params.extract_input<Field<float>>("Radius"); | ||||
| Field<bool> selection = params.extract_input<Field<bool>>("Selection"); | Field<bool> selection = params.extract_input<Field<bool>>("Selection"); | ||||
| /* Use another multi-function operation to make sure the input radius is greater than zero. | /* Use another multi-function operation to make sure the input radius is greater than zero. | ||||
| * TODO: Use mutable multi-function once that is supported. */ | * TODO: Use mutable multi-function once that is supported. */ | ||||
| Show All 35 Lines | |||||
| void register_node_type_geo_mesh_to_points() | void register_node_type_geo_mesh_to_points() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_mesh_to_points_cc; | namespace file_ns = blender::nodes::node_geo_mesh_to_points_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base(&ntype, GEO_NODE_MESH_TO_POINTS, "Mesh to Points", NODE_CLASS_GEOMETRY, 0); | geo_node_type_base(&ntype, GEO_NODE_MESH_TO_POINTS, "Mesh to Points", NODE_CLASS_GEOMETRY, 0); | ||||
| ntype.declare = file_ns::geo_node_mesh_to_points_declare; | ntype.declare = file_ns::node_declare; | ||||
| ntype.geometry_node_execute = file_ns::geo_node_mesh_to_points_exec; | ntype.geometry_node_execute = file_ns::node_geo_exec; | ||||
| node_type_init(&ntype, file_ns::geo_node_mesh_to_points_init); | node_type_init(&ntype, file_ns::node_init); | ||||
| ntype.draw_buttons = file_ns::geo_node_mesh_to_points_layout; | ntype.draw_buttons = file_ns::node_layout; | ||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeGeometryMeshToPoints", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeGeometryMeshToPoints", node_free_standard_storage, node_copy_standard_storage); | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||