Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
| Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | static void attribute_math_calc(GeometryComponent &component, const GeoNodeExecParams ¶ms) | ||||
| /* The result type of this node is always float. */ | /* The result type of this node is always float. */ | ||||
| const CustomDataType result_type = CD_PROP_FLOAT; | const CustomDataType result_type = CD_PROP_FLOAT; | ||||
| /* The result domain is always point for now. */ | /* The result domain is always point for now. */ | ||||
| const AttributeDomain result_domain = ATTR_DOMAIN_POINT; | const AttributeDomain result_domain = ATTR_DOMAIN_POINT; | ||||
| /* Get result attribute first, in case it has to overwrite one of the existing attributes. */ | /* Get result attribute first, in case it has to overwrite one of the existing attributes. */ | ||||
| const std::string result_name = params.get_input<std::string>("Result"); | const std::string result_name = params.get_input<std::string>("Result"); | ||||
| WriteAttributePtr attribute_result = component.attribute_try_ensure_for_write( | OutputAttributePtr attribute_result = component.attribute_try_get_for_output( | ||||
| result_name, result_domain, result_type); | result_name, result_domain, result_type); | ||||
| if (!attribute_result) { | if (!attribute_result) { | ||||
| return; | return; | ||||
| } | } | ||||
| ReadAttributePtr attribute_a = params.get_input_attribute( | ReadAttributePtr attribute_a = params.get_input_attribute( | ||||
| "A", component, result_domain, result_type, nullptr); | "A", component, result_domain, result_type, nullptr); | ||||
| ReadAttributePtr attribute_b = params.get_input_attribute( | ReadAttributePtr attribute_b = params.get_input_attribute( | ||||
| "B", component, result_domain, result_type, nullptr); | "B", component, result_domain, result_type, nullptr); | ||||
| if (!attribute_a || !attribute_b) { | if (!attribute_a || !attribute_b) { | ||||
| /* Attribute wasn't found. */ | /* Attribute wasn't found. */ | ||||
| return; | return; | ||||
| } | } | ||||
| do_math_operation(*attribute_a, *attribute_b, *attribute_result, operation); | do_math_operation(*attribute_a, *attribute_b, *attribute_result, operation); | ||||
| attribute_result.save(); | |||||
| } | } | ||||
| static void geo_node_attribute_math_exec(GeoNodeExecParams params) | static void geo_node_attribute_math_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| if (geometry_set.has<MeshComponent>()) { | if (geometry_set.has<MeshComponent>()) { | ||||
| attribute_math_calc(geometry_set.get_component_for_write<MeshComponent>(), params); | attribute_math_calc(geometry_set.get_component_for_write<MeshComponent>(), params); | ||||
| Show All 23 Lines | |||||