diff options
Diffstat (limited to 'source/blender/nodes')
30 files changed, 71 insertions, 121 deletions
diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh index 6b6e8a89240..f15f5abcb4e 100644 --- a/source/blender/nodes/NOD_geometry_exec.hh +++ b/source/blender/nodes/NOD_geometry_exec.hh @@ -118,6 +118,8 @@ class GeoNodeExecParamsProvider { virtual bool output_is_required(StringRef identifier) const = 0; virtual bool lazy_require_input(StringRef identifier) = 0; virtual bool lazy_output_is_required(StringRef identifier) const = 0; + + virtual void set_default_remaining_outputs() = 0; }; class GeoNodeExecParams { @@ -357,6 +359,8 @@ class GeoNodeExecParams { std::string attribute_producer_name() const; + void set_default_remaining_outputs(); + private: /* Utilities for detecting common errors at when using this class. */ void check_input_access(StringRef identifier, const CPPType *requested_type = nullptr) const; diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_convert.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_convert.cc index 1f241e1f20e..d364ef0bb1d 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_convert.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_convert.cc @@ -141,7 +141,7 @@ static void node_geo_exec(GeoNodeExecParams params) const AttributeDomain domain = static_cast<AttributeDomain>(node_storage.domain); if (result_name.empty()) { - params.set_output("Geometry", geometry_set); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_randomize.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_randomize.cc index 8fb05d031a6..99adb079f91 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_randomize.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_randomize.cc @@ -287,7 +287,7 @@ static void node_geo_exec(GeoNodeExecParams params) GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); const std::string attribute_name = params.get_input<std::string>("Attribute"); if (attribute_name.empty()) { - params.set_output("Geometry", geometry_set); + params.set_default_remaining_outputs(); return; } const int seed = params.get_input<int>("Seed"); diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_transfer.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_transfer.cc index afdadee97c7..faea8751687 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_transfer.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_transfer.cc @@ -483,7 +483,7 @@ static void node_geo_exec(GeoNodeExecParams params) const std::string dst_attribute_name = params.extract_input<std::string>("Destination"); if (src_attribute_name.empty() || dst_attribute_name.empty()) { - params.set_output("Geometry", dst_geometry_set); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_endpoints.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_endpoints.cc index 184f39ba094..b0b53e8136c 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_endpoints.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_endpoints.cc @@ -152,8 +152,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set = bke::geometry_set_realize_instances(geometry_set); if (!geometry_set.has_curve()) { - params.set_output("Start Points", GeometrySet()); - params.set_output("End Points", GeometrySet()); + params.set_default_remaining_outputs(); return; } @@ -168,8 +167,7 @@ static void node_geo_exec(GeoNodeExecParams params) const int total_size = offsets.size(); if (total_size == 0) { - params.set_output("Start Points", GeometrySet()); - params.set_output("End Points", GeometrySet()); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_mesh_to_curve.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_mesh_to_curve.cc index e384124d3e1..8fd7d612021 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_mesh_to_curve.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_mesh_to_curve.cc @@ -34,7 +34,7 @@ static void node_geo_exec(GeoNodeExecParams params) geometry_set = bke::geometry_set_realize_instances(geometry_set); if (!geometry_set.has_mesh()) { - params.set_output("Curve", GeometrySet()); + params.set_default_remaining_outputs(); return; } @@ -55,7 +55,7 @@ static void node_geo_exec(GeoNodeExecParams params) } if (selected_edge_indices.size() == 0) { - params.set_output("Curve", GeometrySet()); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_distribute.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_distribute.cc index d62f3536680..2451a7447ec 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_distribute.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_distribute.cc @@ -552,14 +552,14 @@ static void node_geo_exec(GeoNodeExecParams params) "Density Attribute"); if (density <= 0.0f) { - params.set_output("Geometry", GeometrySet()); + params.set_default_remaining_outputs(); return; } Vector<GeometryInstanceGroup> set_groups; geometry_set_gather_instances(geometry_set, set_groups); if (set_groups.is_empty()) { - params.set_output("Geometry", GeometrySet()); + params.set_default_remaining_outputs(); return; } @@ -573,7 +573,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (set_groups.is_empty()) { params.error_message_add(NodeWarningType::Error, TIP_("Input geometry must contain a mesh")); - params.set_output("Geometry", GeometrySet()); + params.set_default_remaining_outputs(); return; } @@ -623,7 +623,7 @@ static void node_geo_exec(GeoNodeExecParams params) } if (final_points_len == 0) { - params.set_output("Geometry", GeometrySet()); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc index c84031f4c6b..4d7ab97bf0e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc @@ -144,29 +144,6 @@ static float median_of_sorted_span(const Span<float> data) } return median; } -static void set_empty(CustomDataType data_type, GeoNodeExecParams ¶ms) -{ - if (data_type == CD_PROP_FLOAT) { - params.set_output("Mean", 0.0f); - params.set_output("Median", 0.0f); - params.set_output("Sum", 0.0f); - params.set_output("Min", 0.0f); - params.set_output("Max", 0.0f); - params.set_output("Range", 0.0f); - params.set_output("Standard Deviation", 0.0f); - params.set_output("Variance", 0.0f); - } - else if (data_type == CD_PROP_FLOAT3) { - params.set_output("Mean_001", float3{0.0f, 0.0f, 0.0f}); - params.set_output("Median_001", float3{0.0f, 0.0f, 0.0f}); - params.set_output("Sum_001", float3{0.0f, 0.0f, 0.0f}); - params.set_output("Min_001", float3{0.0f, 0.0f, 0.0f}); - params.set_output("Max_001", float3{0.0f, 0.0f, 0.0f}); - params.set_output("Range_001", float3{0.0f, 0.0f, 0.0f}); - params.set_output("Standard Deviation_001", float3{0.0f, 0.0f, 0.0f}); - params.set_output("Variance_001", float3{0.0f, 0.0f, 0.0f}); - } -} static void node_geo_exec(GeoNodeExecParams params) { @@ -185,7 +162,7 @@ static void node_geo_exec(GeoNodeExecParams params) } } if (total_size == 0) { - set_empty(data_type, params); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc index 1cd5f396ee5..d44b42f9e0a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc @@ -65,10 +65,8 @@ static void node_geo_exec(GeoNodeExecParams params) { Collection *collection = params.get_input<Collection *>("Collection"); - GeometrySet geometry_set_out; - if (collection == nullptr) { - params.set_output("Geometry", geometry_set_out); + params.set_default_remaining_outputs(); return; } const Object *self_object = params.self_object(); @@ -76,7 +74,7 @@ static void node_geo_exec(GeoNodeExecParams params) (Object *)self_object); if (is_recursive) { params.error_message_add(NodeWarningType::Error, "Collection contains current object"); - params.set_output("Geometry", geometry_set_out); + params.set_default_remaining_outputs(); return; } @@ -85,6 +83,7 @@ static void node_geo_exec(GeoNodeExecParams params) const bool use_relative_transform = (node_storage->transform_space == GEO_NODE_TRANSFORM_SPACE_RELATIVE); + GeometrySet geometry_set_out; InstancesComponent &instances = geometry_set_out.get_component_for_write<InstancesComponent>(); const bool separate_children = params.get_input<bool>("Separate Children"); diff --git a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc index 5222e2055b1..56c1e95bd70 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc @@ -312,7 +312,7 @@ static void node_geo_exec(GeoNodeExecParams params) #else params.error_message_add(NodeWarningType::Error, TIP_("Disabled, Blender was compiled without Bullet")); - params.set_output("Convex Hull", geometry_set); + params.set_default_remaining_outputs(); #endif /* WITH_BULLET */ } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc index 33e9b11ec0c..73ad8a8cf65 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc @@ -29,7 +29,7 @@ static void node_geo_exec(GeoNodeExecParams params) { GeometrySet curve_set = params.extract_input<GeometrySet>("Curve"); if (!curve_set.has_curve()) { - params.set_output("Length", 0.0f); + params.set_default_remaining_outputs(); return; } const CurveEval &curve = *curve_set.get_curve_for_read(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc index f56571241f9..b33247403f8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc @@ -220,7 +220,7 @@ static void node_geo_exec(GeoNodeExecParams params) params.set_output("Curve", GeometrySet::create_with_curve(curve.release())); } else { - params.set_output("Curve", GeometrySet()); + params.set_default_remaining_outputs(); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc index 53e301ecad7..dda01ef6887 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc @@ -244,7 +244,7 @@ static void node_geo_exec(GeoNodeExecParams params) params.extract_input<float3>("Point 4")); break; default: - params.set_output("Curve", GeometrySet()); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc index 3be119a073f..d5ae3551904 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc @@ -85,7 +85,7 @@ static void node_geo_exec(GeoNodeExecParams params) { const float rotations = std::max(params.extract_input<float>("Rotations"), 0.0f); if (rotations == 0.0f) { - params.set_output("Curve", GeometrySet()); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc index dec72eb61bb..594ffcffb39 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -269,7 +269,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (mode == GEO_NODE_CURVE_RESAMPLE_COUNT) { Field<int> count = params.extract_input<Field<int>>("Count"); if (count < 1) { - params.set_output("Curve", GeometrySet()); + params.set_default_remaining_outputs(); return; } mode_param.count.emplace(count); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc index b81860ca9b3..1de826957b5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc @@ -233,30 +233,28 @@ static void node_geo_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input<GeometrySet>("Curve"); - auto return_default = [&]() { - params.set_output("Position", fn::make_constant_field<float3>({0.0f, 0.0f, 0.0f})); - params.set_output("Tangent", fn::make_constant_field<float3>({0.0f, 0.0f, 0.0f})); - params.set_output("Normal", fn::make_constant_field<float3>({0.0f, 0.0f, 0.0f})); - }; - const CurveComponent *component = geometry_set.get_component_for_read<CurveComponent>(); if (component == nullptr) { - return return_default(); + params.set_default_remaining_outputs(); + return; } const CurveEval *curve = component->get_for_read(); if (curve == nullptr) { - return return_default(); + params.set_default_remaining_outputs(); + return; } if (curve->splines().is_empty()) { - return return_default(); + params.set_default_remaining_outputs(); + return; } Array<float> spline_lengths = curve->accumulated_spline_lengths(); const float total_length = spline_lengths.last(); if (total_length == 0.0f) { - return return_default(); + params.set_default_remaining_outputs(); + return; } Field<float> length_field = get_length_input_field(params, total_length); diff --git a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc index c56d920fac5..99ec7654492 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc @@ -372,14 +372,10 @@ class ImageFieldsFunction : public fn::MultiFunction { static void node_geo_exec(GeoNodeExecParams params) { - auto return_default = [&]() { - params.set_output("Color", ColorGeometry4f(0.0f, 0.0f, 0.0f, 1.0f)); - params.set_output("Alpha", 1.0f); - }; - Image *image = params.get_input<Image *>("Image"); if (image == nullptr) { - return return_default(); + params.set_default_remaining_outputs(); + return; } const bNode &node = params.node(); @@ -398,7 +394,8 @@ static void node_geo_exec(GeoNodeExecParams params) data->interpolation, data->extension, *image, image_user); } catch (const std::runtime_error &) { - return return_default(); + params.set_default_remaining_outputs(); + return; } Field<float3> vector_field = params.extract_input<Field<float3>>("Vector"); diff --git a/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc index 71e4a69911c..30aa745ddff 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc @@ -100,7 +100,7 @@ static void node_geo_exec(GeoNodeExecParams params) params.set_output("Points", std::move(geometry_set)); } else { - params.set_output("Points", GeometrySet()); + params.set_default_remaining_outputs(); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc index ec06bdc0455..e1350b14af7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc @@ -209,7 +209,7 @@ static void node_geo_exec(GeoNodeExecParams params) const int verts_num = params.extract_input<int>("Vertices"); if (verts_num < 3) { params.error_message_add(NodeWarningType::Info, TIP_("Vertices must be at least 3")); - params.set_output("Mesh", GeometrySet()); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc index d2739e7e3ad..73046a19143 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc @@ -803,30 +803,26 @@ static void node_geo_exec(GeoNodeExecParams params) const GeometryNodeMeshCircleFillType fill_type = (const GeometryNodeMeshCircleFillType) storage.fill_type; - auto return_default = [&]() { - params.set_output("Top", fn::make_constant_field<bool>(false)); - params.set_output("Bottom", fn::make_constant_field<bool>(false)); - params.set_output("Side", fn::make_constant_field<bool>(false)); - params.set_output("Mesh", GeometrySet()); - }; - const int circle_segments = params.extract_input<int>("Vertices"); if (circle_segments < 3) { params.error_message_add(NodeWarningType::Info, TIP_("Vertices must be at least 3")); - return return_default(); + params.set_default_remaining_outputs(); + return; } const int side_segments = params.extract_input<int>("Side Segments"); if (side_segments < 1) { params.error_message_add(NodeWarningType::Info, TIP_("Side Segments must be at least 1")); - return return_default(); + params.set_default_remaining_outputs(); + return; } const bool no_fill = fill_type == GEO_NODE_MESH_CIRCLE_FILL_NONE; const int fill_segments = no_fill ? 1 : params.extract_input<int>("Fill Segments"); if (fill_segments < 1) { params.error_message_add(NodeWarningType::Info, TIP_("Fill Segments must be at least 1")); - return return_default(); + params.set_default_remaining_outputs(); + return; } const float radius_top = params.extract_input<float>("Radius Top"); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc index 682efcc81bd..46325101e6c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc @@ -496,7 +496,7 @@ static void node_geo_exec(GeoNodeExecParams params) const int verts_z = params.extract_input<int>("Vertices Z"); if (verts_x < 1 || verts_y < 1 || verts_z < 1) { params.error_message_add(NodeWarningType::Info, TIP_("Vertices must be at least 1")); - params.set_output("Mesh", GeometrySet()); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc index f5ef277de03..8ac105fb95c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc @@ -98,32 +98,28 @@ static void node_geo_exec(GeoNodeExecParams params) const GeometryNodeMeshCircleFillType fill_type = (const GeometryNodeMeshCircleFillType) storage.fill_type; - auto return_default = [&]() { - params.set_output("Top", fn::make_constant_field<bool>(false)); - params.set_output("Bottom", fn::make_constant_field<bool>(false)); - params.set_output("Side", fn::make_constant_field<bool>(false)); - params.set_output("Mesh", GeometrySet()); - }; - const float radius = params.extract_input<float>("Radius"); const float depth = params.extract_input<float>("Depth"); const int circle_segments = params.extract_input<int>("Vertices"); if (circle_segments < 3) { params.error_message_add(NodeWarningType::Info, TIP_("Vertices must be at least 3")); - return return_default(); + params.set_default_remaining_outputs(); + return; } const int side_segments = params.extract_input<int>("Side Segments"); if (side_segments < 1) { params.error_message_add(NodeWarningType::Info, TIP_("Side Segments must be at least 1")); - return return_default(); + params.set_default_remaining_outputs(); + return; } const bool no_fill = fill_type == GEO_NODE_MESH_CIRCLE_FILL_NONE; const int fill_segments = no_fill ? 1 : params.extract_input<int>("Fill Segments"); if (fill_segments < 1) { params.error_message_add(NodeWarningType::Info, TIP_("Fill Segments must be at least 1")); - return return_default(); + params.set_default_remaining_outputs(); + return; } ConeAttributeOutputs attribute_outputs; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc index c761380645d..77634a03af6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc @@ -180,7 +180,7 @@ static void node_geo_exec(GeoNodeExecParams params) const int verts_x = params.extract_input<int>("Vertices X"); const int verts_y = params.extract_input<int>("Vertices Y"); if (verts_x < 1 || verts_y < 1) { - params.set_output("Mesh", GeometrySet()); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc index c109596c1c6..ce2e0923a30 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc @@ -303,7 +303,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (rings_num < 3) { params.error_message_add(NodeWarningType::Info, TIP_("Rings must be at least 3")); } - params.set_output("Mesh", GeometrySet()); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc index 6206b51b6a8..1ec9808044f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc @@ -79,7 +79,7 @@ static void node_geo_exec(GeoNodeExecParams params) #ifndef WITH_OPENSUBDIV params.error_message_add(NodeWarningType::Error, TIP_("Disabled, Blender was compiled without OpenSubdiv")); - params.set_output("Mesh", std::move(geometry_set)); + params.set_default_remaining_outputs(); return; #endif diff --git a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc index ff71bf973b2..6f0d93694ba 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc @@ -47,19 +47,11 @@ static void node_geo_exec(GeoNodeExecParams params) const bool transform_space_relative = (node_storage->transform_space == GEO_NODE_TRANSFORM_SPACE_RELATIVE); - auto default_transform = [&]() { - params.set_output("Location", float3(0)); - params.set_output("Rotation", float3(0)); - params.set_output("Scale", float3(0)); - }; - auto default_geometry = [&]() { params.set_output("Geometry", GeometrySet()); }; - Object *object = params.get_input<Object *>("Object"); const Object *self_object = params.self_object(); if (object == nullptr) { - default_transform(); - default_geometry(); + params.set_default_remaining_outputs(); return; } @@ -81,7 +73,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (object == self_object) { params.error_message_add(NodeWarningType::Error, TIP_("Geometry cannot be retrieved from the modifier object")); - default_geometry(); + params.set_default_remaining_outputs(); return; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc index a064dca3a3f..0a7d2aa198c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc @@ -246,7 +246,7 @@ static void node_geo_exec(GeoNodeExecParams params) #else params.error_message_add(NodeWarningType::Error, TIP_("Disabled, Blender was compiled without OpenVDB")); - params.set_output("Volume", GeometrySet()); + params.set_default_remaining_outputs(); #endif } diff --git a/source/blender/nodes/geometry/nodes/node_geo_proximity.cc b/source/blender/nodes/geometry/nodes/node_geo_proximity.cc index 4431ccd5459..a3e459d30c4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_proximity.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_proximity.cc @@ -211,13 +211,9 @@ static void node_geo_exec(GeoNodeExecParams params) GeometrySet geometry_set_target = params.extract_input<GeometrySet>("Target"); geometry_set_target.ensure_owns_direct_data(); - auto return_default = [&]() { - params.set_output("Position", fn::make_constant_field<float3>({0.0f, 0.0f, 0.0f})); - params.set_output("Distance", fn::make_constant_field<float>(0.0f)); - }; - if (!geometry_set_target.has_mesh() && !geometry_set_target.has_pointcloud()) { - return return_default(); + params.set_default_remaining_outputs(); + return; } const NodeGeometryProximity &storage = *(const NodeGeometryProximity *)params.node().storage; diff --git a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc index c1f5b0c6706..6ba424a58ac 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc @@ -382,28 +382,20 @@ static void node_geo_exec(GeoNodeExecParams params) const GeometryNodeRaycastMapMode mapping = static_cast<GeometryNodeRaycastMapMode>(data.mapping); const CustomDataType data_type = static_cast<CustomDataType>(data.data_type); - auto return_default = [&]() { - params.set_output("Is Hit", fn::make_constant_field<bool>(false)); - params.set_output("Hit Position", fn::make_constant_field<float3>({0.0f, 0.0f, 0.0f})); - params.set_output("Hit Normal", fn::make_constant_field<float3>({0.0f, 0.0f, 0.0f})); - params.set_output("Hit Distance", fn::make_constant_field<float>(0.0f)); - attribute_math::convert_to_static_type(data_type, [&](auto dummy) { - using T = decltype(dummy); - output_attribute_field(params, fn::make_constant_field<T>(T())); - }); - }; - if (target.is_empty()) { - return return_default(); + params.set_default_remaining_outputs(); + return; } if (!target.has_mesh()) { - return return_default(); + params.set_default_remaining_outputs(); + return; } if (target.get_mesh_for_read()->totpoly == 0) { params.error_message_add(NodeWarningType::Error, TIP_("The target mesh must have faces")); - return return_default(); + params.set_default_remaining_outputs(); + return; } GField field = get_input_attribute_field(params, data_type); diff --git a/source/blender/nodes/intern/node_geometry_exec.cc b/source/blender/nodes/intern/node_geometry_exec.cc index f54ef25d4d6..ce87b40fec7 100644 --- a/source/blender/nodes/intern/node_geometry_exec.cc +++ b/source/blender/nodes/intern/node_geometry_exec.cc @@ -254,6 +254,11 @@ std::string GeoNodeExecParams::attribute_producer_name() const return provider_->dnode->label_or_name() + TIP_(" node"); } +void GeoNodeExecParams::set_default_remaining_outputs() +{ + provider_->set_default_remaining_outputs(); +} + void GeoNodeExecParams::check_input_access(StringRef identifier, const CPPType *requested_type) const { |