From 670453d1ecdbb43a552b2f607cac9d1b84f09d6c Mon Sep 17 00:00:00 2001 From: Charlie Jolly Date: Sat, 13 Mar 2021 11:49:56 -0500 Subject: Geometry Nodes: Add Attribute Convert node The Attribute Convert node provides functionality to change attributes between different domains and data types. Before it was impossible to write to a UV Map attribute with the attribute math nodes since they did not output a 2D vector type. This makes it possible to "convert into" a UV map attribute. The data type conversion uses the implicit conversions provided by `\nodes\intern\node_tree_multi_function.cc`. The `Auto` domain mode chooses the domain based on the following rules: 1. If the result attribute already exists, use that domain. 2. If the result attribute doesn't exist, use the source attribute domain. 3. Otherwise use the default domain (points). See {T85700} Differential Revision: https://developer.blender.org/D10624 --- source/blender/blenkernel/BKE_attribute.h | 1 + source/blender/blenkernel/BKE_node.h | 1 + source/blender/blenkernel/intern/node.cc | 1 + 3 files changed, 3 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h index 574d9904dc4..a98bfd1e3df 100644 --- a/source/blender/blenkernel/BKE_attribute.h +++ b/source/blender/blenkernel/BKE_attribute.h @@ -39,6 +39,7 @@ struct ReportList; /* Attribute.domain */ typedef enum AttributeDomain { + ATTR_DOMAIN_AUTO = -1, /* Use for nodes to choose automatically based on other data. */ ATTR_DOMAIN_POINT = 0, /* Mesh, Hair or PointCloud Point */ ATTR_DOMAIN_EDGE = 1, /* Mesh Edge */ ATTR_DOMAIN_CORNER = 2, /* Mesh Corner */ diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 2c543a0a014..0379dea9e8c 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -1373,6 +1373,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree, #define GEO_NODE_ATTRIBUTE_SEPARATE_XYZ 1028 #define GEO_NODE_SUBDIVIDE 1029 #define GEO_NODE_ATTRIBUTE_REMOVE 1030 +#define GEO_NODE_ATTRIBUTE_CONVERT 1031 /** \} */ diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 528088b2ee7..156f6a0c7ae 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -4788,6 +4788,7 @@ static void registerGeometryNodes() register_node_type_geo_attribute_color_ramp(); register_node_type_geo_attribute_combine_xyz(); register_node_type_geo_attribute_compare(); + register_node_type_geo_attribute_convert(); register_node_type_geo_attribute_fill(); register_node_type_geo_attribute_math(); register_node_type_geo_attribute_mix(); -- cgit v1.2.3