Differential D15387 Diff 53368 source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "NOD_socket_search_link.hh" | #include "NOD_socket_search_link.hh" | ||||
| #include "BKE_attribute_math.hh" | |||||
| #include "BKE_type_conversions.hh" | #include "BKE_type_conversions.hh" | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_store_named_attribute_cc { | namespace blender::nodes::node_geo_store_named_attribute_cc { | ||||
| NODE_STORAGE_FUNCS(NodeGeometryStoreNamedAttribute) | NODE_STORAGE_FUNCS(NodeGeometryStoreNamedAttribute) | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | static void node_geo_exec(GeoNodeExecParams params) | ||||
| params.used_named_attribute(name, eNamedAttrUsage::Write); | params.used_named_attribute(name, eNamedAttrUsage::Write); | ||||
| const NodeGeometryStoreNamedAttribute &storage = node_storage(params.node()); | const NodeGeometryStoreNamedAttribute &storage = node_storage(params.node()); | ||||
| const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); | const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); | ||||
| const eAttrDomain domain = static_cast<eAttrDomain>(storage.domain); | const eAttrDomain domain = static_cast<eAttrDomain>(storage.domain); | ||||
| GField field; | GField field; | ||||
| switch (data_type) { | attribute_math::convert_to_static_type(data_type, [&](auto dummy) { | ||||
| case CD_PROP_FLOAT: | using T = decltype(dummy); | ||||
| field = params.get_input<Field<float>>("Value_Float"); | if constexpr (std::is_same_v<T, ColorGeometry4b>) { | ||||
| break; | field = params.extract_input<Field<ColorGeometry4f>>("Value_Color"); | ||||
| case CD_PROP_FLOAT3: | |||||
| field = params.get_input<Field<float3>>("Value_Vector"); | |||||
| break; | |||||
| case CD_PROP_COLOR: | |||||
| field = params.get_input<Field<ColorGeometry4f>>("Value_Color"); | |||||
| break; | |||||
| case CD_PROP_BYTE_COLOR: { | |||||
| field = params.get_input<Field<ColorGeometry4f>>("Value_Color"); | |||||
| field = bke::get_implicit_type_conversions().try_convert(field, | field = bke::get_implicit_type_conversions().try_convert(field, | ||||
| CPPType::get<ColorGeometry4b>()); | CPPType::get<ColorGeometry4b>()); | ||||
| break; | |||||
| } | } | ||||
| case CD_PROP_BOOL: | else { | ||||
| field = params.get_input<Field<bool>>("Value_Bool"); | const std::string socket_name = "Value_" + attribute_math::default_name<T>(); | ||||
| break; | field = params.extract_input<Field<T>>(socket_name); | ||||
| case CD_PROP_INT32: | |||||
| field = params.get_input<Field<int>>("Value_Int"); | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | } | ||||
| }); | |||||
| /* Run on the instances component separately to only affect the top level of instances. */ | /* Run on the instances component separately to only affect the top level of instances. */ | ||||
| if (domain == ATTR_DOMAIN_INSTANCE) { | if (domain == ATTR_DOMAIN_INSTANCE) { | ||||
| if (geometry_set.has_instances()) { | if (geometry_set.has_instances()) { | ||||
| GeometryComponent &component = geometry_set.get_component_for_write( | GeometryComponent &component = geometry_set.get_component_for_write( | ||||
| GEO_COMPONENT_TYPE_INSTANCES); | GEO_COMPONENT_TYPE_INSTANCES); | ||||
| try_capture_field_on_geometry(component, name, domain, field); | try_capture_field_on_geometry(component, name, domain, field); | ||||
| } | } | ||||
| Show All 38 Lines | |||||