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:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user