Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
| Show First 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | static void attribute_mix_calc(GeometryComponent &component, const GeoNodeExecParams ¶ms) | ||||
| * chosen. */ | * chosen. */ | ||||
| AttributeDomain result_domain = ATTR_DOMAIN_POINT; | AttributeDomain result_domain = ATTR_DOMAIN_POINT; | ||||
| const std::string result_name = params.get_input<std::string>("Result"); | const std::string result_name = params.get_input<std::string>("Result"); | ||||
| const ReadAttributePtr result_attribute_read = component.attribute_try_get_for_read(result_name); | const ReadAttributePtr result_attribute_read = component.attribute_try_get_for_read(result_name); | ||||
| if (result_attribute_read) { | if (result_attribute_read) { | ||||
| result_domain = result_attribute_read->domain(); | result_domain = result_attribute_read->domain(); | ||||
| } | } | ||||
| 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; | ||||
| } | } | ||||
| FloatReadAttribute attribute_factor = params.get_input_attribute<float>( | FloatReadAttribute attribute_factor = params.get_input_attribute<float>( | ||||
| "Factor", component, result_domain, 0.5f); | "Factor", component, result_domain, 0.5f); | ||||
| 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); | ||||
| do_mix_operation(result_type, | do_mix_operation(result_type, | ||||
| node_storage->blend_type, | node_storage->blend_type, | ||||
| attribute_factor, | attribute_factor, | ||||
| *attribute_a, | *attribute_a, | ||||
| *attribute_b, | *attribute_b, | ||||
| *attribute_result); | *attribute_result); | ||||
| attribute_result.save(); | |||||
| } | } | ||||
| static void geo_node_attribute_mix_exec(GeoNodeExecParams params) | static void geo_node_attribute_mix_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_mix_calc(geometry_set.get_component_for_write<MeshComponent>(), params); | attribute_mix_calc(geometry_set.get_component_for_write<MeshComponent>(), params); | ||||
| ▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines | |||||