Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc
| Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | static void try_capture_field_on_geometry(GeometryComponent &component, | ||||
| fn::FieldEvaluator evaluator{field_context, &mask}; | fn::FieldEvaluator evaluator{field_context, &mask}; | ||||
| evaluator.add_with_destination(field, output_attribute.varray()); | evaluator.add_with_destination(field, output_attribute.varray()); | ||||
| evaluator.evaluate(); | evaluator.evaluate(); | ||||
| output_attribute.save(); | output_attribute.save(); | ||||
| } | } | ||||
| static StringRefNull identifier_suffix(CustomDataType data_type) | |||||
JacquesLucke: Since you added this now, it should also be used for the other inputs and outputs. (define a… | |||||
| { | |||||
| switch (data_type) { | |||||
| case CD_PROP_FLOAT: | |||||
| return "_001"; | |||||
| case CD_PROP_INT32: | |||||
| return "_004"; | |||||
| case CD_PROP_COLOR: | |||||
| return "_002"; | |||||
| case CD_PROP_BOOL: | |||||
| return "_003"; | |||||
| case CD_PROP_FLOAT3: | |||||
| return ""; | |||||
| default: | |||||
| BLI_assert_unreachable(); | |||||
| return ""; | |||||
| } | |||||
| } | |||||
| static void node_geo_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| if (!params.output_is_required("Geometry")) { | |||||
| params.error_message_add( | |||||
| NodeWarningType::Info, | |||||
| TIP_("The attribute output can not be used without the geometry output")); | |||||
| params.set_default_remaining_outputs(); | |||||
| return; | |||||
| } | |||||
| const NodeGeometryAttributeCapture &storage = node_storage(params.node()); | const NodeGeometryAttributeCapture &storage = node_storage(params.node()); | ||||
| const CustomDataType data_type = static_cast<CustomDataType>(storage.data_type); | const CustomDataType data_type = static_cast<CustomDataType>(storage.data_type); | ||||
| const AttributeDomain domain = static_cast<AttributeDomain>(storage.domain); | const AttributeDomain domain = static_cast<AttributeDomain>(storage.domain); | ||||
| const std::string output_identifier = "Attribute" + identifier_suffix(data_type); | |||||
Done Inline ActionsThis has to be a std::string, otherwise it's a memory error, same below. JacquesLucke: This has to be a `std::string`, otherwise it's a memory error, same below.
That's because a… | |||||
Done Inline ActionsAn info like The attribute output can not be used without the geometry output would probably be more useful. JacquesLucke: An info like `The attribute output can not be used without the geometry output` would probably… | |||||
| if (!params.output_is_required(output_identifier)) { | |||||
| params.set_output("Geometry", geometry_set); | |||||
| return; | |||||
| } | |||||
| const std::string input_identifier = "Value" + identifier_suffix(data_type); | |||||
Done Inline ActionsThis does not require an info message. JacquesLucke: This does not require an info message. | |||||
| GField field; | GField field; | ||||
| switch (data_type) { | switch (data_type) { | ||||
| case CD_PROP_FLOAT: | case CD_PROP_FLOAT: | ||||
| field = params.get_input<Field<float>>("Value_001"); | field = params.get_input<Field<float>>(input_identifier); | ||||
| break; | break; | ||||
| case CD_PROP_FLOAT3: | case CD_PROP_FLOAT3: | ||||
| field = params.get_input<Field<float3>>("Value"); | field = params.get_input<Field<float3>>(input_identifier); | ||||
| break; | break; | ||||
| case CD_PROP_COLOR: | case CD_PROP_COLOR: | ||||
| field = params.get_input<Field<ColorGeometry4f>>("Value_002"); | field = params.get_input<Field<ColorGeometry4f>>(input_identifier); | ||||
| break; | break; | ||||
| case CD_PROP_BOOL: | case CD_PROP_BOOL: | ||||
| field = params.get_input<Field<bool>>("Value_003"); | field = params.get_input<Field<bool>>(input_identifier); | ||||
| break; | break; | ||||
| case CD_PROP_INT32: | case CD_PROP_INT32: | ||||
| field = params.get_input<Field<int>>("Value_004"); | field = params.get_input<Field<int>>(input_identifier); | ||||
| break; | break; | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| WeakAnonymousAttributeID anonymous_id{"Attribute"}; | WeakAnonymousAttributeID anonymous_id{"Attribute"}; | ||||
| const CPPType &type = field.cpp_type(); | const CPPType &type = field.cpp_type(); | ||||
| Show All 19 Lines | else { | ||||
| }); | }); | ||||
| } | } | ||||
| GField output_field{std::make_shared<bke::AnonymousAttributeFieldInput>( | GField output_field{std::make_shared<bke::AnonymousAttributeFieldInput>( | ||||
| std::move(anonymous_id), type, params.attribute_producer_name())}; | std::move(anonymous_id), type, params.attribute_producer_name())}; | ||||
| switch (data_type) { | switch (data_type) { | ||||
| case CD_PROP_FLOAT: { | case CD_PROP_FLOAT: { | ||||
| params.set_output("Attribute_001", Field<float>(output_field)); | params.set_output(output_identifier, Field<float>(output_field)); | ||||
| break; | break; | ||||
| } | } | ||||
| case CD_PROP_FLOAT3: { | case CD_PROP_FLOAT3: { | ||||
| params.set_output("Attribute", Field<float3>(output_field)); | params.set_output(output_identifier, Field<float3>(output_field)); | ||||
| break; | break; | ||||
| } | } | ||||
| case CD_PROP_COLOR: { | case CD_PROP_COLOR: { | ||||
| params.set_output("Attribute_002", Field<ColorGeometry4f>(output_field)); | params.set_output(output_identifier, Field<ColorGeometry4f>(output_field)); | ||||
| break; | break; | ||||
| } | } | ||||
| case CD_PROP_BOOL: { | case CD_PROP_BOOL: { | ||||
| params.set_output("Attribute_003", Field<bool>(output_field)); | params.set_output(output_identifier, Field<bool>(output_field)); | ||||
| break; | break; | ||||
| } | } | ||||
| case CD_PROP_INT32: { | case CD_PROP_INT32: { | ||||
| params.set_output("Attribute_004", Field<int>(output_field)); | params.set_output(output_identifier, Field<int>(output_field)); | ||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| params.set_output("Geometry", geometry_set); | params.set_output("Geometry", geometry_set); | ||||
| } | } | ||||
| Show All 23 Lines | |||||
Since you added this now, it should also be used for the other inputs and outputs. (define a input_identifier and output_identifier variable outside of the switch statements)