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:
-rw-r--r--source/blender/nodes/geometry/node_geometry_util.cc42
-rw-r--r--source/blender/nodes/geometry/node_geometry_util.hh5
2 files changed, 46 insertions, 1 deletions
diff --git a/source/blender/nodes/geometry/node_geometry_util.cc b/source/blender/nodes/geometry/node_geometry_util.cc
index 34c7d224f03..f9ded0e1995 100644
--- a/source/blender/nodes/geometry/node_geometry_util.cc
+++ b/source/blender/nodes/geometry/node_geometry_util.cc
@@ -36,6 +36,48 @@ void update_attribute_input_socket_availabilities(bNode &node,
}
}
+static int attribute_data_type_complexity(const CustomDataType data_type)
+{
+ switch (data_type) {
+ case CD_PROP_BOOL:
+ return 0;
+ case CD_PROP_FLOAT:
+ return 2;
+ case CD_PROP_FLOAT3:
+ return 4;
+ case CD_PROP_COLOR:
+ return 5;
+#if 0 /* Attribute types are not supported yet. */
+ case CD_PROP_INT32:
+ return 1;
+ case CD_MLOOPCOL:
+ return 3;
+ case CD_PROP_STRING:
+ return 6;
+#endif
+ default:
+ /* Only accept "generic" custom data types used by the attribute system. */
+ BLI_assert(false);
+ return 0;
+ }
+}
+
+CustomDataType attribute_domain_lowest_complexity(Span<CustomDataType> data_types)
+{
+ int lowest_complexity = INT_MAX;
+ CustomDataType least_complex_type = CD_PROP_BOOL;
+
+ for (const CustomDataType data_type : data_types) {
+ const int complexity = attribute_data_type_complexity(data_type);
+ if (complexity < lowest_complexity) {
+ lowest_complexity = complexity;
+ least_complex_type = data_type;
+ }
+ }
+
+ return least_complex_type;
+}
+
} // namespace blender::nodes
bool geo_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
diff --git a/source/blender/nodes/geometry/node_geometry_util.hh b/source/blender/nodes/geometry/node_geometry_util.hh
index ec389961615..b8728016230 100644
--- a/source/blender/nodes/geometry/node_geometry_util.hh
+++ b/source/blender/nodes/geometry/node_geometry_util.hh
@@ -42,4 +42,7 @@ namespace blender::nodes {
void update_attribute_input_socket_availabilities(bNode &node,
const StringRef name,
const GeometryNodeAttributeInputMode mode);
-}
+
+CustomDataType attribute_domain_lowest_complexity(Span<CustomDataType>);
+
+} // namespace blender::nodes \ No newline at end of file