summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/Particles.xml2
-rw-r--r--modules/gdscript/gdscript_functions.cpp3
-rw-r--r--servers/visual/shader_language.cpp41
-rw-r--r--servers/visual/shader_language.h1
4 files changed, 46 insertions, 1 deletions
diff --git a/doc/classes/Particles.xml b/doc/classes/Particles.xml
index fb74c5a3d4..7bfea8bce4 100644
--- a/doc/classes/Particles.xml
+++ b/doc/classes/Particles.xml
@@ -24,6 +24,7 @@
<argument index="0" name="pass" type="int">
</argument>
<description>
+ Returns the [Mesh] that is drawn at index [code]pass[/code].
</description>
</method>
<method name="restart">
@@ -41,6 +42,7 @@
<argument index="1" name="mesh" type="Mesh">
</argument>
<description>
+ Sets the [Mesh] that is drawn at index [code]pass[/code].
</description>
</method>
</methods>
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index d9535d0f1f..c4c7ba5ef7 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -589,7 +589,8 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
r_ret = wref;
}
} else if (p_args[0]->get_type() == Variant::NIL) {
- r_ret = memnew(WeakRef);
+ Ref<WeakRef> wref = memnew(WeakRef);
+ r_ret = wref;
} else {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 4e5e816c02..46f65bb758 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -4754,6 +4754,11 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
return ERR_PARSE_ERROR;
}
+ if (has_builtin(p_functions, name)) {
+ _set_error("Redefinition of '" + String(name) + "'");
+ return ERR_PARSE_ERROR;
+ }
+
if (uniform) {
ShaderNode::Uniform uniform2;
@@ -5002,6 +5007,11 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
return ERR_PARSE_ERROR;
}
+ if (has_builtin(p_functions, name)) {
+ _set_error("Redefinition of '" + String(name) + "'");
+ return ERR_PARSE_ERROR;
+ }
+
tk = _get_token();
if (tk.type != TK_PARENTHESIS_OPEN) {
if (type == TYPE_VOID) {
@@ -5060,6 +5070,11 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
return ERR_PARSE_ERROR;
}
+ if (has_builtin(p_functions, name)) {
+ _set_error("Redefinition of '" + String(name) + "'");
+ return ERR_PARSE_ERROR;
+ }
+
tk = _get_token();
} else if (tk.type == TK_SEMICOLON) {
@@ -5161,6 +5176,12 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
return ERR_PARSE_ERROR;
}
}
+
+ if (has_builtin(p_functions, pname)) {
+ _set_error("Redefinition of '" + String(pname) + "'");
+ return ERR_PARSE_ERROR;
+ }
+
FunctionNode::Argument arg;
arg.type = ptype;
arg.name = pname;
@@ -5227,6 +5248,26 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
return OK;
}
+bool ShaderLanguage::has_builtin(const Map<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name) {
+
+ if (p_functions.has("vertex")) {
+ if (p_functions["vertex"].built_ins.has(p_name)) {
+ return true;
+ }
+ }
+ if (p_functions.has("fragment")) {
+ if (p_functions["fragment"].built_ins.has(p_name)) {
+ return true;
+ }
+ }
+ if (p_functions.has("light")) {
+ if (p_functions["light"].built_ins.has(p_name)) {
+ return true;
+ }
+ }
+ return false;
+}
+
Error ShaderLanguage::_find_last_flow_op_in_op(ControlFlowNode *p_flow, FlowOperation p_op) {
bool found = false;
diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h
index ceeaaf8872..e62881f5c6 100644
--- a/servers/visual/shader_language.h
+++ b/servers/visual/shader_language.h
@@ -645,6 +645,7 @@ public:
Map<StringName, BuiltInInfo> built_ins;
bool can_discard;
};
+ static bool has_builtin(const Map<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name);
private:
struct KeyWord {