Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-04-20 12:17:27 +0300
committerJacques Lucke <jacques@blender.org>2021-04-20 12:17:35 +0300
commit2125ee4305c0f22c2c30795669b0f38404e4eb72 (patch)
treedcfd1fb26b17ee37c6620daaf3713256bd97f1de
parent27cfc1ea11461ca1257657afafb455be0da75cb1 (diff)
Geometry Nodes: skip attribute conversion if src and dst are the same
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc
index 577c4b3d3fb..19c3aaa9c85 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc
@@ -66,6 +66,28 @@ static AttributeDomain get_result_domain(const GeometryComponent &component,
return ATTR_DOMAIN_POINT;
}
+static bool conversion_can_be_skipped(const GeometryComponent &component,
+ const StringRef source_name,
+ const StringRef result_name,
+ const AttributeDomain result_domain,
+ const CustomDataType result_type)
+{
+ if (source_name != result_name) {
+ return false;
+ }
+ ReadAttributePtr read_attribute = component.attribute_try_get_for_read(source_name);
+ if (!read_attribute) {
+ return false;
+ }
+ if (read_attribute->domain() != result_domain) {
+ return false;
+ }
+ if (read_attribute->cpp_type() != *bke::custom_data_type_to_cpp_type(result_type)) {
+ return false;
+ }
+ return true;
+}
+
static void attribute_convert_calc(GeometryComponent &component,
const GeoNodeExecParams &params,
const StringRef source_name,
@@ -78,6 +100,10 @@ static void attribute_convert_calc(GeometryComponent &component,
component, source_name, result_name) :
domain;
+ if (conversion_can_be_skipped(component, source_name, result_name, result_domain, result_type)) {
+ return;
+ }
+
ReadAttributePtr source_attribute = component.attribute_try_get_for_read(
source_name, result_domain, result_type);
if (!source_attribute) {