summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/audio_server.cpp1
-rw-r--r--servers/audio_server.h2
-rw-r--r--servers/physics/body_sw.cpp4
-rw-r--r--servers/physics_2d/body_2d_sw.cpp4
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.cpp1
-rw-r--r--servers/visual/shader_language.cpp69
-rw-r--r--servers/visual/shader_language.h2
-rw-r--r--servers/visual/visual_server_canvas.cpp11
-rw-r--r--servers/visual/visual_server_wrap_mt.cpp2
9 files changed, 75 insertions, 21 deletions
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 2cf6a67bef..1da0146084 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -1079,6 +1079,7 @@ void AudioServer::finish() {
for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) {
AudioDriverManager::get_driver(i)->finish();
+ AudioDriverManager::get_driver(i)->clear_capture_buffer();
}
for (int i = 0; i < buses.size(); i++) {
diff --git a/servers/audio_server.h b/servers/audio_server.h
index 72bb6faf42..da4b9daf5b 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -115,6 +115,8 @@ public:
unsigned int get_capture_position() { return capture_position; }
unsigned int get_capture_size() { return capture_size; }
+ void clear_capture_buffer() { capture_buffer.resize(0); }
+
#ifdef DEBUG_ENABLED
uint64_t get_profiling_time() const { return prof_time; }
void reset_profiling_time() { prof_time = 0; }
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp
index a3bb581cb5..ba98e14d2e 100644
--- a/servers/physics/body_sw.cpp
+++ b/servers/physics/body_sw.cpp
@@ -260,12 +260,14 @@ void BodySW::set_mode(PhysicsServer::BodyMode p_mode) {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_set_static(false);
+ set_active(true);
} break;
case PhysicsServer::BODY_MODE_CHARACTER: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_set_static(false);
+ set_active(true);
angular_velocity = Vector3();
} break;
}
@@ -794,7 +796,7 @@ BodySW::BodySW() :
still_time = 0;
continuous_cd = false;
- can_sleep = false;
+ can_sleep = true;
fi_callback = NULL;
}
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index 6ba159ca0a..de1dfc9ee7 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -238,6 +238,7 @@ void Body2DSW::set_mode(Physics2DServer::BodyMode p_mode) {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_inv_inertia = inertia > 0 ? (1.0 / inertia) : 0;
_set_static(false);
+ set_active(true);
} break;
case Physics2DServer::BODY_MODE_CHARACTER: {
@@ -245,6 +246,7 @@ void Body2DSW::set_mode(Physics2DServer::BodyMode p_mode) {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_inv_inertia = 0;
_set_static(false);
+ set_active(true);
angular_velocity = 0;
} break;
}
@@ -694,7 +696,7 @@ Body2DSW::Body2DSW() :
still_time = 0;
continuous_cd_mode = Physics2DServer::CCD_MODE_DISABLED;
- can_sleep = false;
+ can_sleep = true;
fi_callback = NULL;
}
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp
index c698290fd9..9fc15d9660 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp
@@ -139,6 +139,7 @@ void Physics2DServerWrapMT::finish() {
segment_shape_free_cached_ids();
circle_shape_free_cached_ids();
rectangle_shape_free_cached_ids();
+ capsule_shape_free_cached_ids();
convex_polygon_shape_free_cached_ids();
concave_polygon_shape_free_cached_ids();
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 3b549afb02..41a6b27b84 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -2914,6 +2914,16 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
bool ok = _parse_function_arguments(p_block, p_builtin_types, func, &carg);
+ // Check if block has a variable with the same name as function to prevent shader crash.
+ ShaderLanguage::BlockNode *bnode = p_block;
+ while (bnode) {
+ if (bnode->variables.has(name)) {
+ _set_error("Expected function name");
+ return NULL;
+ }
+ bnode = bnode->parent_block;
+ }
+
//test if function was parsed first
for (int i = 0; i < shader->functions.size(); i++) {
if (shader->functions[i].name == name) {
@@ -3842,9 +3852,12 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
}
StringName name = tk.text;
- if (_find_identifier(p_block, p_builtin_types, name)) {
- _set_error("Redefinition of '" + String(name) + "'");
- return ERR_PARSE_ERROR;
+ ShaderLanguage::IdentifierType itype;
+ if (_find_identifier(p_block, p_builtin_types, name, (ShaderLanguage::DataType *)0, &itype)) {
+ if (itype != IDENTIFIER_FUNCTION) {
+ _set_error("Redefinition of '" + String(name) + "'");
+ return ERR_PARSE_ERROR;
+ }
}
BlockNode::Variable var;
@@ -4002,6 +4015,11 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
return ERR_PARSE_ERROR;
}
+ if (node->is_const && n->type == Node::TYPE_OPERATOR && ((OperatorNode *)n)->op == OP_CALL) {
+ _set_error("Expected constant expression");
+ return ERR_PARSE_ERROR;
+ }
+
if (var.type != n->get_datatype()) {
_set_error("Invalid assignment of '" + get_datatype_name(n->get_datatype()) + "' to '" + get_datatype_name(var.type) + "'");
return ERR_PARSE_ERROR;
@@ -4062,7 +4080,10 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
if (!n)
return ERR_PARSE_ERROR;
-
+ if (node->is_const && n->type == Node::TYPE_OPERATOR && ((OperatorNode *)n)->op == OP_CALL) {
+ _set_error("Expected constant expression after '='");
+ return ERR_PARSE_ERROR;
+ }
decl.initializer = n;
if (var.type != n->get_datatype()) {
@@ -4589,19 +4610,34 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
return OK;
}
+String ShaderLanguage::_get_shader_type_list(const Set<String> &p_shader_types) const {
+
+ // Return a list of shader types as an human-readable string
+ String valid_types;
+ for (const Set<String>::Element *E = p_shader_types.front(); E; E = E->next()) {
+ if (valid_types != String()) {
+ valid_types += ", ";
+ }
+
+ valid_types += "'" + E->get() + "'";
+ }
+
+ return valid_types;
+}
+
Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types) {
Token tk = _get_token();
if (tk.type != TK_SHADER_TYPE) {
- _set_error("Expected 'shader_type' at the beginning of shader.");
+ _set_error("Expected 'shader_type' at the beginning of shader. Valid types are: " + _get_shader_type_list(p_shader_types));
return ERR_PARSE_ERROR;
}
tk = _get_token();
if (tk.type != TK_IDENTIFIER) {
- _set_error("Expected identifier after 'shader_type', indicating type of shader.");
+ _set_error("Expected identifier after 'shader_type', indicating type of shader. Valid types are: " + _get_shader_type_list(p_shader_types));
return ERR_PARSE_ERROR;
}
@@ -4610,15 +4646,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
shader_type_identifier = tk.text;
if (!p_shader_types.has(shader_type_identifier)) {
-
- String valid;
- for (Set<String>::Element *E = p_shader_types.front(); E; E = E->next()) {
- if (valid != String()) {
- valid += ", ";
- }
- valid += "'" + E->get() + "'";
- }
- _set_error("Invalid shader type, valid types are: " + valid);
+ _set_error("Invalid shader type. Valid types are: " + _get_shader_type_list(p_shader_types));
return ERR_PARSE_ERROR;
}
@@ -5121,9 +5149,12 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
pname = tk.text;
- if (_find_identifier(func_node->body, builtin_types, pname)) {
- _set_error("Redefinition of '" + String(pname) + "'");
- return ERR_PARSE_ERROR;
+ ShaderLanguage::IdentifierType itype;
+ if (_find_identifier(func_node->body, builtin_types, pname, (ShaderLanguage::DataType *)0, &itype)) {
+ if (itype != IDENTIFIER_FUNCTION) {
+ _set_error("Redefinition of '" + String(pname) + "'");
+ return ERR_PARSE_ERROR;
+ }
}
FunctionNode::Argument arg;
arg.type = ptype;
@@ -5395,7 +5426,7 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
if (block->parent_function) {
if (comp_ident) {
for (int i = 0; i < block->parent_function->arguments.size(); i++) {
- matches.insert(block->parent_function->arguments[i].name, ScriptCodeCompletionOption::KIND_FUNCTION);
+ matches.insert(block->parent_function->arguments[i].name, ScriptCodeCompletionOption::KIND_VARIABLE);
}
}
skip_function = block->parent_function->name;
diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h
index 3a5630ef42..ceeaaf8872 100644
--- a/servers/visual/shader_language.h
+++ b/servers/visual/shader_language.h
@@ -750,6 +750,8 @@ private:
Node *_parse_and_reduce_expression(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types);
Error _parse_block(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, bool p_just_one = false, bool p_can_break = false, bool p_can_continue = false);
+ String _get_shader_type_list(const Set<String> &p_shader_types) const;
+
Error _parse_shader(const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types);
Error _find_last_flow_op_in_block(BlockNode *p_block, FlowOperation p_op);
diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp
index f5a1276c27..ed06a67e4c 100644
--- a/servers/visual/visual_server_canvas.cpp
+++ b/servers/visual/visual_server_canvas.cpp
@@ -680,11 +680,22 @@ void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const R
rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_H;
rect->rect.size.x = -rect->rect.size.x;
}
+ if (p_src_rect.size.x < 0) {
+
+ rect->flags ^= RasterizerCanvas::CANVAS_RECT_FLIP_H;
+ rect->source.size.x = -rect->source.size.x;
+ }
if (p_rect.size.y < 0) {
rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_V;
rect->rect.size.y = -rect->rect.size.y;
}
+ if (p_src_rect.size.y < 0) {
+
+ rect->flags ^= RasterizerCanvas::CANVAS_RECT_FLIP_V;
+ rect->source.size.y = -rect->source.size.y;
+ }
+
if (p_transpose) {
rect->flags |= RasterizerCanvas::CANVAS_RECT_TRANSPOSE;
SWAP(rect->rect.size.x, rect->rect.size.y);
diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp
index 79e4d8cbba..1f0217c0ce 100644
--- a/servers/visual/visual_server_wrap_mt.cpp
+++ b/servers/visual/visual_server_wrap_mt.cpp
@@ -137,6 +137,7 @@ void VisualServerWrapMT::finish() {
}
texture_free_cached_ids();
+ sky_free_cached_ids();
shader_free_cached_ids();
material_free_cached_ids();
mesh_free_cached_ids();
@@ -148,6 +149,7 @@ void VisualServerWrapMT::finish() {
spot_light_free_cached_ids();
reflection_probe_free_cached_ids();
gi_probe_free_cached_ids();
+ lightmap_capture_free_cached_ids();
particles_free_cached_ids();
camera_free_cached_ids();
viewport_free_cached_ids();