Fix T62305: Unconnected group vector inputs are mapped incorrectly

The issue was that `bNodeSocketValueVector` and `bNodeSocketValueRGBA`
don't store the value at the same location in the struct.

I kept the cases for `SOCK_VECTOR` and `SOCK_RGBA` completely separate
for now, because they only share code by coincidence and not because
they are actually the same. Eventually there could be a "Vector Input"
node similar to the "RGB" node.

Reviewers: fclem

Differential Revision: https://developer.blender.org/D4472
This commit is contained in:
Jacques Lucke 2019-03-07 18:03:20 +01:00
parent 1eea4b2634
commit b38b0cdb0d
Notes: blender-bot 2023-05-03 10:14:48 +02:00
Referenced by issue #62305, Unconnected node group vector inputs map [X,Y,Z] to [Y,Z,-]
1 changed files with 9 additions and 0 deletions

View File

@ -445,6 +445,7 @@ static void ntree_shader_groups_expand_inputs(bNodeTree *localtree)
{
bNode *value_node, *group_node;
bNodeSocket *value_socket;
bNodeSocketValueVector *src_vector;
bNodeSocketValueRGBA *src_rgba, *dst_rgba;
bNodeSocketValueFloat *src_float, *dst_float;
bool link_added = false;
@ -468,6 +469,14 @@ static void ntree_shader_groups_expand_inputs(bNodeTree *localtree)
switch (group_socket->type) {
case SOCK_VECTOR:
value_node = nodeAddStaticNode(NULL, localtree, SH_NODE_RGB);
value_socket = ntree_shader_node_find_output(value_node, "Color");
BLI_assert(value_socket != NULL);
src_vector = group_socket->default_value;
dst_rgba = value_socket->default_value;
copy_v3_v3(dst_rgba->value, src_vector->value);
dst_rgba->value[3] = 1.0f; /* should never be read */
break;
case SOCK_RGBA:
value_node = nodeAddStaticNode(NULL, localtree, SH_NODE_RGB);
value_socket = ntree_shader_node_find_output(value_node, "Color");