Fix #112622: draw_color_simple is optional for custom nodes

Use magenta fallback color for sockets without a `draw_color_simple`
callback. This is not ideal, but without a context or node instance
the older `draw_color` callback can't be used.

Pull Request: https://projects.blender.org/blender/blender/pulls/112658
This commit is contained in:
Lukas Tönne
2023-09-21 11:25:55 +02:00
parent faf8d9d8ba
commit b00c2f9ac4
2 changed files with 13 additions and 8 deletions

View File

@@ -622,15 +622,14 @@ bNodeSocketType *bNodeTreeInterfaceSocket::socket_typeinfo() const
blender::ColorGeometry4f bNodeTreeInterfaceSocket::socket_color() const
{
bNodeSocketType *typeinfo = this->socket_typeinfo();
if (!typeinfo || !typeinfo->draw_color_simple) {
if (typeinfo && typeinfo->draw_color_simple) {
float color[4];
typeinfo->draw_color_simple(typeinfo, color);
return blender::ColorGeometry4f(color);
}
else {
return blender::ColorGeometry4f(1.0f, 0.0f, 1.0f, 1.0f);
}
float color[4];
if (typeinfo->draw_color_simple) {
typeinfo->draw_color_simple(typeinfo, color);
}
return blender::ColorGeometry4f(color);
}
bool bNodeTreeInterfaceSocket::set_socket_type(const char *new_socket_type)

View File

@@ -1089,7 +1089,13 @@ static void node_socket_outline_color_get(const bool selected,
void node_socket_color_get(const bNodeSocketType &type, float r_color[4])
{
type.draw_color_simple(&type, r_color);
if (type.draw_color_simple) {
float color[4];
type.draw_color_simple(&type, color);
}
else {
copy_v4_v4(r_color, float4(1.0f, 0.0f, 1.0f, 1.0f));
}
}
static void create_inspection_string_for_generic_value(const bNodeSocket &socket,