Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
| Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | static void fill_attribute(GeometryComponent &component, const GeoNodeExecParams ¶ms) | ||||
| const bNode &node = params.node(); | const bNode &node = params.node(); | ||||
| const CustomDataType data_type = static_cast<CustomDataType>(node.custom1); | const CustomDataType data_type = static_cast<CustomDataType>(node.custom1); | ||||
| const AttributeDomain domain = static_cast<AttributeDomain>(node.custom2); | const AttributeDomain domain = static_cast<AttributeDomain>(node.custom2); | ||||
| const std::string attribute_name = params.get_input<std::string>("Attribute"); | const std::string attribute_name = params.get_input<std::string>("Attribute"); | ||||
| if (attribute_name.empty()) { | if (attribute_name.empty()) { | ||||
| return; | return; | ||||
| } | } | ||||
| WriteAttributePtr attribute = component.attribute_try_ensure_for_write( | OutputAttributePtr attribute = component.attribute_try_get_for_output( | ||||
| attribute_name, domain, data_type); | attribute_name, domain, data_type); | ||||
| if (!attribute) { | if (!attribute) { | ||||
| return; | return; | ||||
| } | } | ||||
| switch (data_type) { | switch (data_type) { | ||||
| case CD_PROP_FLOAT: { | case CD_PROP_FLOAT: { | ||||
| const float value = params.get_input<float>("Value_001"); | const float value = params.get_input<float>("Value_001"); | ||||
| MutableSpan<float> attribute_span = attribute->get_span_for_write_only<float>(); | MutableSpan<float> attribute_span = attribute->get_span_for_write_only<float>(); | ||||
| attribute_span.fill(value); | attribute_span.fill(value); | ||||
| attribute->apply_span(); | |||||
| break; | break; | ||||
| } | } | ||||
| case CD_PROP_FLOAT3: { | case CD_PROP_FLOAT3: { | ||||
| const float3 value = params.get_input<float3>("Value"); | const float3 value = params.get_input<float3>("Value"); | ||||
| MutableSpan<float3> attribute_span = attribute->get_span_for_write_only<float3>(); | MutableSpan<float3> attribute_span = attribute->get_span_for_write_only<float3>(); | ||||
| attribute_span.fill(value); | attribute_span.fill(value); | ||||
| attribute->apply_span(); | |||||
| break; | break; | ||||
| } | } | ||||
| case CD_PROP_COLOR: { | case CD_PROP_COLOR: { | ||||
| const Color4f value = params.get_input<Color4f>("Value_002"); | const Color4f value = params.get_input<Color4f>("Value_002"); | ||||
| MutableSpan<Color4f> attribute_span = attribute->get_span_for_write_only<Color4f>(); | MutableSpan<Color4f> attribute_span = attribute->get_span_for_write_only<Color4f>(); | ||||
| attribute_span.fill(value); | attribute_span.fill(value); | ||||
| attribute->apply_span(); | |||||
| break; | break; | ||||
| } | } | ||||
| case CD_PROP_BOOL: { | case CD_PROP_BOOL: { | ||||
| const bool value = params.get_input<bool>("Value_003"); | const bool value = params.get_input<bool>("Value_003"); | ||||
| MutableSpan<bool> attribute_span = attribute->get_span_for_write_only<bool>(); | MutableSpan<bool> attribute_span = attribute->get_span_for_write_only<bool>(); | ||||
| attribute_span.fill(value); | attribute_span.fill(value); | ||||
| attribute->apply_span(); | |||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| attribute.apply_span_and_save(); | |||||
| } | } | ||||
| static void geo_node_attribute_fill_exec(GeoNodeExecParams params) | static void geo_node_attribute_fill_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>()) { | ||||
| fill_attribute(geometry_set.get_component_for_write<MeshComponent>(), params); | fill_attribute(geometry_set.get_component_for_write<MeshComponent>(), params); | ||||
| Show All 21 Lines | |||||