Allow constructing larger data types by swizzling

GLSL allows the construction of larger data types by swizzling smaller
ones, but Godot shading language treated this as an error:

  vec2 test2 = vec2(0.0, 1.0);
  vec3 test3 = test2.xxx; // error: Invalid member for vec2 expression

This commit updates the expression parser for the 2 and 3-component data
types accordingly.

Fixes #10496
This commit is contained in:
Jesse Dubay 2019-05-11 10:41:13 -07:00
parent 89c37dae49
commit 1b9d26765f

View file

@ -2968,6 +2968,10 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
member_type = DataType(dt - 1);
} else if (l == 2) {
member_type = dt;
} else if (l == 3) {
member_type = DataType(dt + 1);
} else if (l == 4) {
member_type = DataType(dt + 2);
} else {
ok = false;
break;
@ -3001,6 +3005,8 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
member_type = DataType(dt - 1);
} else if (l == 3) {
member_type = dt;
} else if (l == 4) {
member_type = DataType(dt + 1);
} else {
ok = false;
break;