[Bf-blender-cvs] [107231eb956] master: Geometry Nodes: improve support for Color attributes
Jacques Lucke
noreply at git.blender.org
Thu Dec 3 16:26:22 CET 2020
Commit: 107231eb956a953c89a2ab134371988ebe338c59
Author: Jacques Lucke
Date: Thu Dec 3 16:25:48 2020 +0100
Branches: master
https://developer.blender.org/rB107231eb956a953c89a2ab134371988ebe338c59
Geometry Nodes: improve support for Color attributes
* Add typed attribute accessors for color attributes.
* Support implicit conversions between colors and floats.
===================================================================
M source/blender/blenkernel/BKE_attribute_access.hh
M source/blender/nodes/NOD_geometry_exec.hh
M source/blender/nodes/intern/node_tree_multi_function.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh
index f5ee2cf2bf5..c4a704ef385 100644
--- a/source/blender/blenkernel/BKE_attribute_access.hh
+++ b/source/blender/blenkernel/BKE_attribute_access.hh
@@ -23,6 +23,7 @@
#include "BKE_attribute.h"
+#include "BLI_color.hh"
#include "BLI_float3.hh"
struct Mesh;
@@ -267,10 +268,9 @@ template<typename T> class TypedWriteAttribute {
using FloatReadAttribute = TypedReadAttribute<float>;
using Float3ReadAttribute = TypedReadAttribute<float3>;
+using Color4fReadAttribute = TypedReadAttribute<Color4f>;
using FloatWriteAttribute = TypedWriteAttribute<float>;
using Float3WriteAttribute = TypedWriteAttribute<float3>;
-
-const CPPType *custom_data_type_to_cpp_type(const CustomDataType type);
-CustomDataType cpp_type_to_custom_data_type(const CPPType &type);
+using Color4fWriteAttribute = TypedWriteAttribute<Color4f>;
} // namespace blender::bke
diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh
index 2b95f76d06b..fde576d7429 100644
--- a/source/blender/nodes/NOD_geometry_exec.hh
+++ b/source/blender/nodes/NOD_geometry_exec.hh
@@ -26,6 +26,8 @@
namespace blender::nodes {
+using bke::Color4fReadAttribute;
+using bke::Color4fWriteAttribute;
using bke::Float3ReadAttribute;
using bke::Float3WriteAttribute;
using bke::FloatReadAttribute;
diff --git a/source/blender/nodes/intern/node_tree_multi_function.cc b/source/blender/nodes/intern/node_tree_multi_function.cc
index 8440e996651..ec5527a2970 100644
--- a/source/blender/nodes/intern/node_tree_multi_function.cc
+++ b/source/blender/nodes/intern/node_tree_multi_function.cc
@@ -204,6 +204,10 @@ static DataTypeConversions create_implicit_conversions()
conversions, "float3 to Color4f", [](float3 a) { return Color4f(a.x, a.y, a.z, 1.0f); });
add_implicit_conversion<Color4f, float3>(
conversions, "Color4f to float3", [](Color4f a) { return float3(a.r, a.g, a.b); });
+ add_implicit_conversion<float, Color4f>(
+ conversions, "float to Color4f", [](float a) { return Color4f(a, a, a, 1.0f); });
+ add_implicit_conversion<Color4f, float>(
+ conversions, "Color4f to float", [](Color4f a) { return rgb_to_grayscale(a); });
return conversions;
}
More information about the Bf-blender-cvs
mailing list