From 1b9d26765f88d37ecd21dd3ce7fb1fecda15f4d9 Mon Sep 17 00:00:00 2001 From: Jesse Dubay Date: Sat, 11 May 2019 10:41:13 -0700 Subject: [PATCH] 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 --- servers/visual/shader_language.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 33714a79b2f..73f8da7c5e8 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -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;