Geometry Node: Make Capture Attributes more lazy #105264

Closed
Iliya Katushenock wants to merge 4 commits from mod_moder/blender:more_lazynes_capture_attribute_node into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 14 additions and 5 deletions

View File

@ -127,8 +127,6 @@ static StringRefNull identifier_suffix(eCustomDataType data_type)
static void node_geo_exec(GeoNodeExecParams params)
{
GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
if (!params.output_is_required("Geometry")) {
params.error_message_add(
NodeWarningType::Info,
@ -141,17 +139,27 @@ static void node_geo_exec(GeoNodeExecParams params)
const eCustomDataType data_type = eCustomDataType(storage.data_type);
const eAttrDomain domain = eAttrDomain(storage.domain);
const std::string input_identifier = "Value" + identifier_suffix(data_type);
const std::string output_identifier = "Attribute" + identifier_suffix(data_type);
AutoAnonymousAttributeID attribute_id = params.get_output_anonymous_attribute_id_if_needed(
output_identifier);
if (!attribute_id) {
if (!attribute_id || !params.output_is_required(output_identifier)) {
params.set_input_unused(input_identifier);
if (params.lazy_require_input("Geometry")) {
return;
}
GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
params.set_output("Geometry", geometry_set);
params.set_default_remaining_outputs();
return;
}
const std::string input_identifier = "Value" + identifier_suffix(data_type);
if (params.lazy_require_input(input_identifier) | params.lazy_require_input("Geometry")) {
Review

Use || instead of |

Use `||` instead of `|`

A frequently used pattern to get both functions fired in one execution pass, and not just the first one with a true return

A frequently used pattern to get both functions fired in one execution pass, and not just the first one with a true return
Review

Ah, not sure I've noticed that before. Seems a bit hidden at first, but it makes sense. We'll see what Jacques thinks.

Ah, not sure I've noticed that before. Seems a bit hidden at first, but it makes sense. We'll see what Jacques thinks.

This seems to be used everywhere, for asking for multiple lazy inputs (in switch node for example).

This seems to be used everywhere, for asking for multiple lazy inputs (in switch node for example).
return;
}
GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
GField field;
switch (data_type) {
@ -249,5 +257,6 @@ void register_node_type_geo_attribute_capture()
ntype.geometry_node_execute = file_ns::node_geo_exec;
ntype.draw_buttons = file_ns::node_layout;
ntype.gather_link_search_ops = file_ns::node_gather_link_searches;
ntype.geometry_node_execute_supports_laziness = true;
nodeRegisterType(&ntype);
}