diff options
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/NOD_socket_declarations.hh | 11 | ||||
-rw-r--r-- | source/blender/nodes/geometry/node_geometry_tree.cc | 1 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_socket.cc | 17 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_util.c | 8 |
4 files changed, 35 insertions, 2 deletions
diff --git a/source/blender/nodes/NOD_socket_declarations.hh b/source/blender/nodes/NOD_socket_declarations.hh index 00874cad766..e22b96cd1ff 100644 --- a/source/blender/nodes/NOD_socket_declarations.hh +++ b/source/blender/nodes/NOD_socket_declarations.hh @@ -193,6 +193,13 @@ class Texture : public IDSocketDeclaration { Texture(); }; +class Image : public IDSocketDeclaration { + public: + using Builder = SocketDeclarationBuilder<Image>; + + Image(); +}; + class Geometry : public SocketDeclaration { public: using Builder = SocketDeclarationBuilder<Geometry>; @@ -339,6 +346,10 @@ inline Texture::Texture() : IDSocketDeclaration("NodeSocketTexture") { } +inline Image::Image() : IDSocketDeclaration("NodeSocketImage") +{ +} + /** \} */ } // namespace blender::nodes::decl diff --git a/source/blender/nodes/geometry/node_geometry_tree.cc b/source/blender/nodes/geometry/node_geometry_tree.cc index 20b610a4db9..9747bb63773 100644 --- a/source/blender/nodes/geometry/node_geometry_tree.cc +++ b/source/blender/nodes/geometry/node_geometry_tree.cc @@ -109,6 +109,7 @@ static bool geometry_node_tree_socket_type_valid(bNodeTreeType *UNUSED(ntreetype SOCK_GEOMETRY, SOCK_COLLECTION, SOCK_TEXTURE, + SOCK_IMAGE, SOCK_MATERIAL); } diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index 4334f1b5030..11356178d87 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -808,6 +808,7 @@ static bNodeSocketType *make_socket_type_string() MAKE_CPP_TYPE(Object, Object *, CPPTypeFlags::BasicType) MAKE_CPP_TYPE(Collection, Collection *, CPPTypeFlags::BasicType) MAKE_CPP_TYPE(Texture, Tex *, CPPTypeFlags::BasicType) +MAKE_CPP_TYPE(Image, Image *, CPPTypeFlags::BasicType) MAKE_CPP_TYPE(Material, Material *, CPPTypeFlags::BasicType) static bNodeSocketType *make_socket_type_object() @@ -858,6 +859,18 @@ static bNodeSocketType *make_socket_type_texture() return socktype; } +static bNodeSocketType *make_socket_type_image() +{ + bNodeSocketType *socktype = make_standard_socket_type(SOCK_IMAGE, PROP_NONE); + socktype->get_base_cpp_type = []() { return &blender::fn::CPPType::get<Image *>(); }; + socktype->get_base_cpp_value = [](const bNodeSocket &socket, void *r_value) { + *(Image **)r_value = ((bNodeSocketValueImage *)socket.default_value)->value; + }; + socktype->get_geometry_nodes_cpp_type = socktype->get_base_cpp_type; + socktype->get_geometry_nodes_cpp_value = socktype->get_base_cpp_value; + return socktype; +} + static bNodeSocketType *make_socket_type_material() { bNodeSocketType *socktype = make_standard_socket_type(SOCK_MATERIAL, PROP_NONE); @@ -906,14 +919,14 @@ void register_standard_node_socket_types(void) nodeRegisterSocketType(make_socket_type_object()); - nodeRegisterSocketType(make_standard_socket_type(SOCK_IMAGE, PROP_NONE)); - nodeRegisterSocketType(make_socket_type_geometry()); nodeRegisterSocketType(make_socket_type_collection()); nodeRegisterSocketType(make_socket_type_texture()); + nodeRegisterSocketType(make_socket_type_image()); + nodeRegisterSocketType(make_socket_type_material()); nodeRegisterSocketType(make_socket_type_virtual()); diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index 1aec280fd2b..ba0cfeacb83 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -467,6 +467,14 @@ static int node_datatype_priority(eNodeSocketDatatype from, eNodeSocketDatatype return -1; } } + case SOCK_IMAGE: { + switch (from) { + case SOCK_IMAGE: + return 1; + default: + return -1; + } + } case SOCK_MATERIAL: { switch (from) { case SOCK_MATERIAL: |