Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_interpolate_domain.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "BKE_attribute.hh" | |||||
| #include "BKE_attribute_math.hh" | #include "BKE_attribute_math.hh" | ||||
| #include "BLI_task.hh" | #include "BLI_task.hh" | ||||
| #include "NOD_socket_search_link.hh" | #include "NOD_socket_search_link.hh" | ||||
| namespace blender::nodes::node_geo_interpolate_domain_cc { | namespace blender::nodes::node_geo_interpolate_domain_cc { | ||||
| ▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | public: | ||||
| std::optional<eAttrDomain> preferred_domain( | std::optional<eAttrDomain> preferred_domain( | ||||
| const GeometryComponent & /*component*/) const override | const GeometryComponent & /*component*/) const override | ||||
| { | { | ||||
| return src_domain_; | return src_domain_; | ||||
| } | } | ||||
| }; | }; | ||||
| static StringRefNull identifier_suffix(eCustomDataType data_type) | |||||
| { | |||||
| switch (data_type) { | |||||
| case CD_PROP_BOOL: | |||||
| return "Bool"; | |||||
| case CD_PROP_FLOAT: | |||||
| return "Float"; | |||||
| case CD_PROP_INT32: | |||||
| return "Int"; | |||||
| case CD_PROP_COLOR: | |||||
| return "Color"; | |||||
| case CD_PROP_FLOAT3: | |||||
| return "Vector"; | |||||
| default: | |||||
| BLI_assert_unreachable(); | |||||
| return ""; | |||||
| } | |||||
| } | |||||
| static void node_geo_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| const bNode &node = params.node(); | const bNode &node = params.node(); | ||||
| const eAttrDomain domain = eAttrDomain(node.custom1); | const eAttrDomain domain = eAttrDomain(node.custom1); | ||||
| const eCustomDataType data_type = eCustomDataType(node.custom2); | const eCustomDataType data_type = eCustomDataType(node.custom2); | ||||
| attribute_math::convert_to_static_type(data_type, [&](auto dummy) { | attribute_math::convert_to_static_type(data_type, [&](auto dummy) { | ||||
| using T = decltype(dummy); | using T = decltype(dummy); | ||||
| static const std::string identifier = "Value_" + identifier_suffix(data_type); | static const std::string identifier = "Value_" + bke::type_name_identifier<T>(); | ||||
| Field<T> src_field = params.extract_input<Field<T>>(identifier); | Field<T> src_field = params.extract_input<Field<T>>(identifier); | ||||
| Field<T> dst_field{std::make_shared<InterpolateDomain>(std::move(src_field), domain)}; | Field<T> dst_field{std::make_shared<InterpolateDomain>(std::move(src_field), domain)}; | ||||
| params.set_output(identifier, std::move(dst_field)); | params.set_output(identifier, std::move(dst_field)); | ||||
| }); | }); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_geo_interpolate_domain_cc | } // namespace blender::nodes::node_geo_interpolate_domain_cc | ||||
| Show All 16 Lines | |||||