summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--README.md1
-rw-r--r--core/bind/core_bind.cpp8
-rw-r--r--core/image.cpp10
-rw-r--r--core/io/marshalls.cpp6
-rw-r--r--core/io/resource_format_binary.cpp18
-rw-r--r--core/io/stream_peer.cpp4
-rw-r--r--core/io/stream_peer_tcp.cpp12
-rw-r--r--core/io/stream_peer_tcp.h1
-rw-r--r--core/math/geometry.h32
-rw-r--r--core/math/triangle_mesh.cpp4
-rw-r--r--core/pool_vector.h8
-rw-r--r--core/register_core_types.cpp2
-rw-r--r--core/ustring.cpp2
-rw-r--r--core/variant.cpp3
-rw-r--r--core/variant_call.cpp4
-rw-r--r--doc/classes/EditorSettings.xml2
-rw-r--r--doc/classes/Node.xml2
-rw-r--r--doc/classes/String.xml13
-rw-r--r--doc/classes/Viewport.xml19
-rw-r--r--doc/classes/VisualShaderNodeTexture.xml2
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp8
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp6
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp24
-rw-r--r--drivers/unix/os_unix.cpp2
-rw-r--r--editor/create_dialog.cpp4
-rw-r--r--editor/dependency_editor.cpp2
-rw-r--r--editor/editor_help_search.cpp4
-rw-r--r--editor/editor_node.cpp14
-rw-r--r--editor/editor_profiler.cpp2
-rw-r--r--editor/import/resource_importer_wav.cpp6
-rw-r--r--editor/plugins/editor_preview_plugins.cpp2
-rw-r--r--editor/plugins/multimesh_editor_plugin.cpp2
-rw-r--r--editor/plugins/particles_editor_plugin.cpp2
-rw-r--r--editor/plugins/shader_editor_plugin.cpp2
-rw-r--r--editor/plugins/shader_editor_plugin.h2
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp1
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp8
-rw-r--r--editor/scene_tree_dock.cpp4
-rw-r--r--editor/scene_tree_editor.cpp21
-rw-r--r--editor/scene_tree_editor.h2
-rw-r--r--main/input_default.cpp2
-rw-r--r--misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist2
-rw-r--r--modules/assimp/editor_scene_importer_assimp.cpp2
-rw-r--r--modules/bullet/rigid_body_bullet.cpp4
-rw-r--r--modules/csg/csg_shape.cpp8
-rw-r--r--modules/csg/doc_classes/CSGShape.xml2
-rw-r--r--modules/cvtt/image_compress_cvtt.cpp4
-rw-r--r--modules/dds/texture_loader_dds.cpp5
-rw-r--r--modules/etc/texture_loader_pkm.cpp2
-rw-r--r--modules/gdscript/gdscript_parser.cpp3
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp2
-rw-r--r--modules/jpg/image_loader_jpegd.cpp4
-rw-r--r--modules/mono/utils/string_utils.cpp2
-rw-r--r--modules/opus/audio_stream_opus.cpp2
-rw-r--r--modules/pvr/texture_loader_pvr.cpp6
-rw-r--r--modules/squish/image_compress_squish.cpp4
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp2
-rw-r--r--modules/svg/image_loader_svg.cpp2
-rw-r--r--modules/tga/image_loader_tga.cpp2
-rw-r--r--modules/tinyexr/image_loader_tinyexr.cpp2
-rw-r--r--modules/visual_script/visual_script.cpp4
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp7
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp1
-rw-r--r--modules/vorbis/audio_stream_ogg_vorbis.cpp2
-rw-r--r--modules/webp/image_loader_webp.cpp8
-rw-r--r--modules/websocket/websocket_multiplayer_peer.cpp2
-rw-r--r--modules/websocket/websocket_multiplayer_peer.h2
-rw-r--r--modules/websocket/wsl_server.cpp33
-rw-r--r--modules/websocket/wsl_server.h6
-rw-r--r--platform/android/file_access_jandroid.cpp2
-rw-r--r--platform/android/java_godot_lib_jni.cpp8
-rw-r--r--platform/iphone/camera_ios.mm16
-rw-r--r--platform/iphone/export/export.cpp8
-rw-r--r--platform/x11/godot_x11.cpp1
-rw-r--r--scene/2d/collision_polygon_2d.cpp2
-rw-r--r--scene/2d/cpu_particles_2d.cpp5
-rw-r--r--scene/2d/path_2d.cpp2
-rw-r--r--scene/2d/polygon_2d.cpp2
-rw-r--r--scene/2d/tile_map.cpp16
-rw-r--r--scene/2d/tile_map.h7
-rw-r--r--scene/3d/baked_lightmap.h2
-rw-r--r--scene/3d/cpu_particles.cpp4
-rw-r--r--scene/3d/particles.cpp2
-rw-r--r--scene/3d/soft_body.cpp2
-rw-r--r--scene/3d/sprite_3d.cpp2
-rw-r--r--scene/gui/item_list.cpp2
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/popup.cpp8
-rw-r--r--scene/gui/text_edit.cpp2
-rw-r--r--scene/gui/tree.cpp8
-rw-r--r--scene/gui/tree.h1
-rw-r--r--scene/main/viewport.cpp1
-rw-r--r--scene/resources/animation.cpp22
-rw-r--r--scene/resources/dynamic_font_stb.cpp2
-rw-r--r--scene/resources/mesh.cpp8
-rw-r--r--scene/resources/particles_material.cpp5
-rw-r--r--scene/resources/resource_format_text.cpp3
-rw-r--r--scene/resources/surface_tool.cpp14
-rw-r--r--scene/resources/visual_shader_nodes.cpp50
-rw-r--r--scene/resources/visual_shader_nodes.h3
-rw-r--r--servers/arvr_server.cpp10
-rw-r--r--servers/physics/shape_sw.cpp4
-rw-r--r--servers/physics_2d/shape_2d_sw.cpp2
-rw-r--r--servers/visual/shader_language.cpp44
-rw-r--r--servers/visual/shader_language.h3
-rw-r--r--servers/visual/visual_server_scene.cpp2
107 files changed, 416 insertions, 261 deletions
diff --git a/.gitignore b/.gitignore
index 7a836240b8..f43f68f25f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -343,3 +343,5 @@ platform/windows/godot_res.res
# compile commands (https://clang.llvm.org/docs/JSONCompilationDatabase.html)
compile_commands.json
+# Cppcheck
+*.cppcheck
diff --git a/README.md b/README.md
index 8cfab51d58..9e772fa89f 100644
--- a/README.md
+++ b/README.md
@@ -69,3 +69,4 @@ for more info.
[![Travis Build Status](https://travis-ci.org/godotengine/godot.svg?branch=master)](https://travis-ci.org/godotengine/godot)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/bfiihqq6byxsjxxh/branch/master?svg=true)](https://ci.appveyor.com/project/akien-mga/godot)
[![Code Triagers Badge](https://www.codetriage.com/godotengine/godot/badges/users.svg)](https://www.codetriage.com/godotengine/godot)
+[![Translate on Weblate](https://hosted.weblate.org/widgets/godot-engine/-/godot/svg-badge.svg)](https://hosted.weblate.org/engage/godot-engine/?utm_source=widget)
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 1bf3425d50..34bbdb2c75 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -1932,13 +1932,15 @@ PoolVector<uint8_t> _File::get_buffer(int p_length) const {
ERR_FAIL_COND_V(p_length < 0, data);
if (p_length == 0)
return data;
+
Error err = data.resize(p_length);
ERR_FAIL_COND_V(err != OK, data);
+
PoolVector<uint8_t>::Write w = data.write();
int len = f->get_buffer(&w[0], p_length);
ERR_FAIL_COND_V(len < 0, PoolVector<uint8_t>());
- w = PoolVector<uint8_t>::Write();
+ w.release();
if (len < p_length)
data.resize(p_length);
@@ -2113,11 +2115,11 @@ void _File::store_var(const Variant &p_var, bool p_full_objects) {
PoolVector<uint8_t> buff;
buff.resize(len);
- PoolVector<uint8_t>::Write w = buff.write();
+ PoolVector<uint8_t>::Write w = buff.write();
err = encode_variant(p_var, &w[0], len, p_full_objects);
ERR_FAIL_COND(err != OK);
- w = PoolVector<uint8_t>::Write();
+ w.release();
store_32(len);
store_buffer(buff);
diff --git a/core/image.cpp b/core/image.cpp
index 18a3aae88f..a88395204a 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -495,8 +495,8 @@ void Image::convert(Format p_new_format) {
case FORMAT_RGBA8 | (FORMAT_RGB8 << 8): _convert<3, true, 3, false, false, false>(width, height, rptr, wptr); break;
}
- r = PoolVector<uint8_t>::Read();
- w = PoolVector<uint8_t>::Write();
+ r.release();
+ w.release();
bool gen_mipmaps = mipmaps;
@@ -1091,8 +1091,8 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
} break;
}
- r = PoolVector<uint8_t>::Read();
- w = PoolVector<uint8_t>::Write();
+ r.release();
+ w.release();
if (interpolate_mipmaps) {
dst._copy_internals_from(dst2);
@@ -2394,7 +2394,7 @@ void Image::lock() {
void Image::unlock() {
- write_lock = PoolVector<uint8_t>::Write();
+ write_lock.release();
}
Color Image::get_pixelv(const Point2 &p_src) const {
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 17a3f52a65..dc5581ea01 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -558,8 +558,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
w[i] = buf[i];
}
-
- w = PoolVector<uint8_t>::Write();
}
r_variant = data;
@@ -590,8 +588,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
w[i] = decode_uint32(&buf[i * 4]);
}
-
- w = PoolVector<int>::Write();
}
r_variant = Variant(data);
if (r_len) {
@@ -618,8 +614,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
w[i] = decode_float(&buf[i * 4]);
}
-
- w = PoolVector<float>::Write();
}
r_variant = data;
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 688dfc21e5..861e34e415 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -410,7 +410,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
PoolVector<uint8_t>::Write w = array.write();
f->get_buffer(w.ptr(), len);
_advance_padding(len);
- w = PoolVector<uint8_t>::Write();
+ w.release();
r_v = array;
} break;
@@ -432,7 +432,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
}
#endif
- w = PoolVector<int>::Write();
+ w.release();
r_v = array;
} break;
case VARIANT_REAL_ARRAY: {
@@ -454,7 +454,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
#endif
- w = PoolVector<real_t>::Write();
+ w.release();
r_v = array;
} break;
case VARIANT_STRING_ARRAY: {
@@ -465,7 +465,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
PoolVector<String>::Write w = array.write();
for (uint32_t i = 0; i < len; i++)
w[i] = get_unicode_string();
- w = PoolVector<String>::Write();
+ w.release();
r_v = array;
} break;
@@ -493,7 +493,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
ERR_EXPLAIN("Vector2 size is NOT 8!");
ERR_FAIL_V(ERR_UNAVAILABLE);
}
- w = PoolVector<Vector2>::Write();
+ w.release();
r_v = array;
} break;
@@ -521,7 +521,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
ERR_EXPLAIN("Vector3 size is NOT 12!");
ERR_FAIL_V(ERR_UNAVAILABLE);
}
- w = PoolVector<Vector3>::Write();
+ w.release();
r_v = array;
} break;
@@ -549,7 +549,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
ERR_EXPLAIN("Color size is NOT 16!");
ERR_FAIL_V(ERR_UNAVAILABLE);
}
- w = PoolVector<Color>::Write();
+ w.release();
r_v = array;
} break;
#ifndef DISABLE_DEPRECATED
@@ -584,7 +584,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
PoolVector<uint8_t>::Write w = imgdata.write();
f->get_buffer(w.ptr(), datalen);
_advance_padding(datalen);
- w = PoolVector<uint8_t>::Write();
+ w.release();
Ref<Image> image;
image.instance();
@@ -597,7 +597,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
data.resize(f->get_32());
PoolVector<uint8_t>::Write w = data.write();
f->get_buffer(w.ptr(), data.size());
- w = PoolVector<uint8_t>::Write();
+ w.release();
Ref<Image> image;
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index 6ad24a5f3a..acf72dbba5 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -79,7 +79,7 @@ Array StreamPeer::_get_data(int p_bytes) {
PoolVector<uint8_t>::Write w = data.write();
Error err = get_data(&w[0], p_bytes);
- w = PoolVector<uint8_t>::Write();
+ w.release();
ret.push_back(err);
ret.push_back(data);
return ret;
@@ -101,7 +101,7 @@ Array StreamPeer::_get_partial_data(int p_bytes) {
PoolVector<uint8_t>::Write w = data.write();
int received;
Error err = get_partial_data(&w[0], p_bytes, received);
- w = PoolVector<uint8_t>::Write();
+ w.release();
if (err != OK) {
data.resize(0);
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp
index a8dd263484..310bb12bc0 100644
--- a/core/io/stream_peer_tcp.cpp
+++ b/core/io/stream_peer_tcp.cpp
@@ -30,6 +30,8 @@
#include "stream_peer_tcp.h"
+#include "core/project_settings.h"
+
Error StreamPeerTCP::_poll_connection() {
ERR_FAIL_COND_V(status != STATUS_CONNECTING || !_sock.is_valid() || !_sock->is_open(), FAILED);
@@ -40,6 +42,12 @@ Error StreamPeerTCP::_poll_connection() {
status = STATUS_CONNECTED;
return OK;
} else if (err == ERR_BUSY) {
+ // Check for connect timeout
+ if (OS::get_singleton()->get_ticks_msec() > timeout) {
+ disconnect_from_host();
+ status = STATUS_ERROR;
+ return ERR_CONNECTION_ERROR;
+ }
// Still trying to connect
return OK;
}
@@ -54,6 +62,7 @@ void StreamPeerTCP::accept_socket(Ref<NetSocket> p_sock, IP_Address p_host, uint
_sock = p_sock;
_sock->set_blocking_enabled(false);
+ timeout = OS::get_singleton()->get_ticks_msec() + (((uint64_t)GLOBAL_GET("network/limits/tcp/connect_timeout_seconds")) * 1000);
status = STATUS_CONNECTING;
peer_host = p_host;
@@ -74,6 +83,7 @@ Error StreamPeerTCP::connect_to_host(const IP_Address &p_host, uint16_t p_port)
_sock->set_blocking_enabled(false);
+ timeout = OS::get_singleton()->get_ticks_msec() + (((uint64_t)GLOBAL_GET("network/limits/tcp/connect_timeout_seconds")) * 1000);
err = _sock->connect_to_host(p_host, p_port);
if (err == OK) {
@@ -281,6 +291,7 @@ void StreamPeerTCP::disconnect_from_host() {
if (_sock.is_valid() && _sock->is_open())
_sock->close();
+ timeout = 0;
status = STATUS_NONE;
peer_host = IP_Address();
peer_port = 0;
@@ -356,6 +367,7 @@ void StreamPeerTCP::_bind_methods() {
StreamPeerTCP::StreamPeerTCP() :
_sock(Ref<NetSocket>(NetSocket::create())),
+ timeout(0),
status(STATUS_NONE),
peer_port(0) {
}
diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h
index 1ca39375aa..321fb3a6c8 100644
--- a/core/io/stream_peer_tcp.h
+++ b/core/io/stream_peer_tcp.h
@@ -52,6 +52,7 @@ public:
protected:
Ref<NetSocket> _sock;
+ uint64_t timeout;
Status status;
IP_Address peer_host;
uint16_t peer_port;
diff --git a/core/math/geometry.h b/core/math/geometry.h
index 0e144e491f..e4f3ff799e 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -455,16 +455,15 @@ public:
Vector3 p = p_point - p_segment[0];
Vector3 n = p_segment[1] - p_segment[0];
- real_t l = n.length();
- if (l < 1e-10)
+ real_t l2 = n.length_squared();
+ if (l2 < 1e-20)
return p_segment[0]; // both points are the same, just give any
- n /= l;
- real_t d = n.dot(p);
+ real_t d = n.dot(p) / l2;
if (d <= 0.0)
return p_segment[0]; // before first point
- else if (d >= l)
+ else if (d >= 1.0)
return p_segment[1]; // after first point
else
return p_segment[0] + n * d; // inside
@@ -474,12 +473,11 @@ public:
Vector3 p = p_point - p_segment[0];
Vector3 n = p_segment[1] - p_segment[0];
- real_t l = n.length();
- if (l < 1e-10)
+ real_t l2 = n.length_squared();
+ if (l2 < 1e-20)
return p_segment[0]; // both points are the same, just give any
- n /= l;
- real_t d = n.dot(p);
+ real_t d = n.dot(p) / l2;
return p_segment[0] + n * d; // inside
}
@@ -488,16 +486,15 @@ public:
Vector2 p = p_point - p_segment[0];
Vector2 n = p_segment[1] - p_segment[0];
- real_t l = n.length();
- if (l < 1e-10)
+ real_t l2 = n.length_squared();
+ if (l2 < 1e-20)
return p_segment[0]; // both points are the same, just give any
- n /= l;
- real_t d = n.dot(p);
+ real_t d = n.dot(p) / l2;
if (d <= 0.0)
return p_segment[0]; // before first point
- else if (d >= l)
+ else if (d >= 1.0)
return p_segment[1]; // after first point
else
return p_segment[0] + n * d; // inside
@@ -521,12 +518,11 @@ public:
Vector2 p = p_point - p_segment[0];
Vector2 n = p_segment[1] - p_segment[0];
- real_t l = n.length();
- if (l < 1e-10)
+ real_t l2 = n.length_squared();
+ if (l2 < 1e-20)
return p_segment[0]; // both points are the same, just give any
- n /= l;
- real_t d = n.dot(p);
+ real_t d = n.dot(p) / l2;
return p_segment[0] + n * d; // inside
}
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index 83784a1fa7..546981be44 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -182,7 +182,7 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
int max_alloc = fc;
_create_bvh(bw.ptr(), bwp.ptr(), 0, fc, 1, max_depth, max_alloc);
- bw = PoolVector<BVH>::Write(); //clearup
+ bw.release(); //clearup
bvh.resize(max_alloc); //resize back
valid = true;
@@ -751,7 +751,7 @@ PoolVector<Face3> TriangleMesh::get_faces() const {
}
}
- w = PoolVector<Face3>::Write();
+ w.release();
return faces;
}
diff --git a/core/pool_vector.h b/core/pool_vector.h
index 338de966f6..98a52c6938 100644
--- a/core/pool_vector.h
+++ b/core/pool_vector.h
@@ -301,6 +301,10 @@ public:
virtual ~Access() {
_unref();
}
+
+ void release() {
+ _unref();
+ }
};
class Read : public Access {
@@ -484,9 +488,7 @@ T PoolVector<T>::get(int p_index) const {
template <class T>
void PoolVector<T>::set(int p_index, const T &p_val) {
- if (p_index < 0 || p_index >= size()) {
- ERR_FAIL_COND(p_index < 0 || p_index >= size());
- }
+ ERR_FAIL_INDEX(p_index, size());
Write w = write();
w[p_index] = p_val;
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 11cd07042f..e442546124 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -207,6 +207,8 @@ void register_core_types() {
void register_core_settings() {
//since in register core types, globals may not e present
+ GLOBAL_DEF("network/limits/tcp/connect_timeout_seconds", (30));
+ ProjectSettings::get_singleton()->set_custom_property_info("network/limits/tcp/connect_timeout_seconds", PropertyInfo(Variant::INT, "network/limits/tcp/connect_timeout_seconds", PROPERTY_HINT_RANGE, "1,1800,1"));
GLOBAL_DEF_RST("network/limits/packet_peer_stream/max_buffer_po2", (16));
ProjectSettings::get_singleton()->set_custom_property_info("network/limits/packet_peer_stream/max_buffer_po2", PropertyInfo(Variant::INT, "network/limits/packet_peer_stream/max_buffer_po2", PROPERTY_HINT_RANGE, "0,64,1,or_greater"));
}
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 21ac304a1b..706e8a3cc1 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -778,7 +778,7 @@ Vector<String> String::split(const String &p_splitter, bool p_allow_empty, int p
if (p_allow_empty || (end > from)) {
if (p_maxsplit <= 0)
ret.push_back(substr(from, end - from));
- else if (p_maxsplit > 0) {
+ else {
// Put rest of the string and leave cycle.
if (p_maxsplit == ret.size()) {
diff --git a/core/variant.cpp b/core/variant.cpp
index 5b51a4e513..fe9623d068 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -2418,9 +2418,6 @@ Variant::Variant(const PoolVector<Face3> &p_face_array) {
for (int j = 0; j < 3; j++)
w[i * 3 + j] = r[i].vertex[j];
}
-
- r = PoolVector<Face3>::Read();
- w = PoolVector<Vector3>::Write();
}
type = NIL;
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 4c3cbfa484..3fdd18a630 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -319,7 +319,7 @@ struct _VariantCall {
retval.resize(len);
PoolByteArray::Write w = retval.write();
copymem(w.ptr(), charstr.ptr(), len);
- w = PoolVector<uint8_t>::Write();
+ w.release();
r_ret = retval;
}
@@ -334,7 +334,7 @@ struct _VariantCall {
retval.resize(len);
PoolByteArray::Write w = retval.write();
copymem(w.ptr(), charstr.ptr(), len);
- w = PoolVector<uint8_t>::Write();
+ w.release();
r_ret = retval;
}
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 83e3729391..5395a8fcb0 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -182,7 +182,7 @@
</signals>
<constants>
<constant name="NOTIFICATION_EDITOR_SETTINGS_CHANGED" value="10000">
- Emitted when editor settings change. It used by various editor plugins to update their visuals on theme changes or logic on configuration changes.
+ Emitted when editor settings change. It used by various editor plugins to update their visuals on theme changes or logic on configuration changes.
</constant>
</constants>
</class>
diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml
index 5a90354124..889ce4d3eb 100644
--- a/doc/classes/Node.xml
+++ b/doc/classes/Node.xml
@@ -553,7 +553,7 @@
<return type="void">
</return>
<description>
- Moves this node to the top of the array of nodes of the parent node. This is often useful in GUIs ([Control] nodes), because their order of drawing depends on their order in the tree.
+ Moves this node to the bottom of parent node's children hierarchy. This is often useful in GUIs ([Control] nodes), because their order of drawing depends on their order in the tree, i.e. the further they are on the node list, the higher they are drawn. After using [code]raise[/code], a Control will be drawn on top of their siblings.
</description>
</method>
<method name="remove_and_skip">
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index 1934c5af9a..e513a44b1d 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -385,19 +385,30 @@
<return type="int">
</return>
<description>
- Converts a string containing a hexadecimal number into an integer.
+ Converts a string containing a hexadecimal number into an integer. Hexadecimal strings are expected to be prefixed with "[code]0x[/code]" otherwise [code]0[/code] is returned.
+ [codeblock]
+ print("0xff".hex_to_int()) # Print "255"
+ [/codeblock]
</description>
</method>
<method name="http_escape">
<return type="String">
</return>
<description>
+ Escapes (encodes) a string to URL friendly format. Also referred to as 'URL encode'.
+ [codeblock]
+ print("https://example.org/?escaped=" + "Godot Engine:'docs'".http_escape())
+ [/codeblock]
</description>
</method>
<method name="http_unescape">
<return type="String">
</return>
<description>
+ Unescapes (decodes) a string in URL encoded format. Also referred to as 'URL decode'.
+ [codeblock]
+ print("https://example.org/?escaped=" + "Godot%20Engine%3A%27docs%27".http_unescape())
+ [/codeblock]
</description>
</method>
<method name="insert">
diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml
index a9ffd9f66d..5d5a62456f 100644
--- a/doc/classes/Viewport.xml
+++ b/doc/classes/Viewport.xml
@@ -141,13 +141,6 @@
Returns [code]true[/code] if the size override is enabled. See [method set_size_override].
</description>
</method>
- <method name="is_size_override_stretch_enabled" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- Returns [code]true[/code] if the size stretch override is enabled. See [method set_size_override_stretch].
- </description>
- </method>
<method name="set_attach_to_screen_rect">
<return type="void">
</return>
@@ -175,15 +168,6 @@
Sets the size override of the viewport. If the [code]enable[/code] parameter is [code]true[/code] the override is used, otherwise it uses the default size. If the size parameter is [code](-1, -1)[/code], it won't update the size.
</description>
</method>
- <method name="set_size_override_stretch">
- <return type="void">
- </return>
- <argument index="0" name="enabled" type="bool">
- </argument>
- <description>
- If [code]true[/code], the size override affects stretch as well.
- </description>
- </method>
<method name="unhandled_input">
<return type="void">
</return>
@@ -284,6 +268,9 @@
<member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 0, 0 )">
The width and height of viewport.
</member>
+ <member name="size_override_stretch" type="bool" setter="set_size_override_stretch" getter="is_size_override_stretch_enabled" default="false">
+ If [code]true[/code], the size override affects stretch as well.
+ </member>
<member name="transparent_bg" type="bool" setter="set_transparent_background" getter="has_transparent_background" default="false">
If [code]true[/code], the viewport should render its background as transparent.
</member>
diff --git a/doc/classes/VisualShaderNodeTexture.xml b/doc/classes/VisualShaderNodeTexture.xml
index 1f4d3b16d1..b3b89eb29b 100644
--- a/doc/classes/VisualShaderNodeTexture.xml
+++ b/doc/classes/VisualShaderNodeTexture.xml
@@ -25,6 +25,8 @@
</constant>
<constant name="SOURCE_2D_NORMAL" value="3" enum="Source">
</constant>
+ <constant name="SOURCE_DEPTH" value="4" enum="Source">
+ </constant>
<constant name="TYPE_DATA" value="0" enum="TextureType">
</constant>
<constant name="TYPE_COLOR" value="1" enum="TextureType">
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index b08202ae45..c591db4f3d 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -807,7 +807,7 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer)
}
}
- wb = PoolVector<uint8_t>::Write();
+ wb.release();
data.resize(data_size);
@@ -871,7 +871,7 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &temp_framebuffer);
- wb = PoolVector<uint8_t>::Write();
+ wb.release();
data.resize(data_size);
@@ -2155,8 +2155,8 @@ static PoolVector<uint8_t> _unpack_half_floats(const PoolVector<uint8_t> &array,
dst_offset += dst_size[i];
}
- r = PoolVector<uint8_t>::Read();
- w = PoolVector<uint8_t>::Write();
+ r.release();
+ w.release();
return ret;
}
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index c2fde148e2..fb3d154a7a 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -1459,8 +1459,8 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e, const Transfo
#else
PoolVector<RasterizerGLES3Particle> particle_vector;
particle_vector.resize(particles->amount);
- PoolVector<RasterizerGLES3Particle>::Write w = particle_vector.write();
- particle_array = w.ptr();
+ PoolVector<RasterizerGLES3Particle>::Write particle_writer = particle_vector.write();
+ particle_array = particle_writer.ptr();
glGetBufferSubData(GL_ARRAY_BUFFER, 0, particles->amount * sizeof(RasterizerGLES3Particle), particle_array);
#endif
@@ -1477,7 +1477,7 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e, const Transfo
#ifndef __EMSCRIPTEN__
glUnmapBuffer(GL_ARRAY_BUFFER);
#else
- w = PoolVector<RasterizerGLES3Particle>::Write();
+ particle_writer.release();
particle_array = NULL;
{
PoolVector<RasterizerGLES3Particle>::Read r = particle_vector.read();
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index b280898188..c4cfd1e765 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -1173,7 +1173,7 @@ Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer)
glDeleteFramebuffers(1, &tmp_fbo);
}
- wb = PoolVector<uint8_t>::Write();
+ wb.release();
data.resize(data_size);
@@ -1248,7 +1248,7 @@ Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer)
img_format = real_format;
}
- wb = PoolVector<uint8_t>::Write();
+ wb.release();
data.resize(data_size);
@@ -1316,7 +1316,7 @@ Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &temp_framebuffer);
- wb = PoolVector<uint8_t>::Write();
+ wb.release();
data.resize(data_size);
@@ -2526,19 +2526,19 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
int v = value;
GLuint *gui = (GLuint *)data;
- gui[0] = v & 1 ? GL_TRUE : GL_FALSE;
- gui[1] = v & 2 ? GL_TRUE : GL_FALSE;
- gui[2] = v & 4 ? GL_TRUE : GL_FALSE;
+ gui[0] = (v & 1) ? GL_TRUE : GL_FALSE;
+ gui[1] = (v & 2) ? GL_TRUE : GL_FALSE;
+ gui[2] = (v & 4) ? GL_TRUE : GL_FALSE;
} break;
case ShaderLanguage::TYPE_BVEC4: {
int v = value;
GLuint *gui = (GLuint *)data;
- gui[0] = v & 1 ? GL_TRUE : GL_FALSE;
- gui[1] = v & 2 ? GL_TRUE : GL_FALSE;
- gui[2] = v & 4 ? GL_TRUE : GL_FALSE;
- gui[3] = v & 8 ? GL_TRUE : GL_FALSE;
+ gui[0] = (v & 1) ? GL_TRUE : GL_FALSE;
+ gui[1] = (v & 2) ? GL_TRUE : GL_FALSE;
+ gui[2] = (v & 4) ? GL_TRUE : GL_FALSE;
+ gui[3] = (v & 8) ? GL_TRUE : GL_FALSE;
} break;
case ShaderLanguage::TYPE_INT: {
@@ -3441,7 +3441,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
glGenBuffers(1, &surface->vertex_id);
glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id);
- glBufferData(GL_ARRAY_BUFFER, array_size, vr.ptr(), p_format & VS::ARRAY_FLAG_USE_DYNAMIC_UPDATE ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, array_size, vr.ptr(), (p_format & VS::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
if (p_format & VS::ARRAY_FORMAT_INDEX) {
@@ -6337,7 +6337,7 @@ AABB RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) {
}
#if defined(GLES_OVER_GL) || defined(__EMSCRIPTEN__)
- r = PoolVector<uint8_t>::Read();
+ r.release();
vector = PoolVector<uint8_t>();
#else
glUnmapBuffer(GL_ARRAY_BUFFER);
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 4de910ee1c..aa61cf5dcc 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -256,7 +256,7 @@ OS::TimeZoneInfo OS_Unix::get_time_zone_info() const {
void OS_Unix::delay_usec(uint32_t p_usec) const {
- struct timespec rem = { static_cast<time_t>(p_usec / 1000000), static_cast<long>((p_usec % 1000000) * 1000) };
+ struct timespec rem = { static_cast<time_t>(p_usec / 1000000), (static_cast<long>(p_usec) % 1000000) * 1000 };
while (nanosleep(&rem, &rem) == EINTR) {
}
}
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 547d627925..8a8d52c6f1 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -210,13 +210,13 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
if (is_subsequence_of_type && !is_selected_equal) {
if (is_substring_of_type) {
- if (!is_substring_of_selected || (is_substring_of_selected && (current_type_prefered && !selected_type_prefered))) {
+ if (!is_substring_of_selected || (current_type_prefered && !selected_type_prefered)) {
*to_select = item;
}
} else {
// substring results weigh more than subsequences, so let's make sure we don't override them
if (!is_substring_of_selected) {
- if (!is_subsequence_of_selected || (is_subsequence_of_selected && (current_type_prefered && !selected_type_prefered))) {
+ if (!is_subsequence_of_selected || (current_type_prefered && !selected_type_prefered)) {
*to_select = item;
}
}
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 9a049f3ae3..5f8660e108 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -474,7 +474,7 @@ void DependencyRemoveDialog::show(const Vector<String> &p_folders, const Vector<
removed_deps.sort();
if (removed_deps.empty()) {
owners->hide();
- text->set_text(TTR("Remove selected files from the project? (no undo)"));
+ text->set_text(TTR("Remove selected files from the project? (Can't be restored)"));
set_size(Size2());
popup_centered();
} else {
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp
index 4ec24c76f2..fbfc999dbf 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -337,7 +337,7 @@ bool EditorHelpSearch::Runner::_phase_match_classes() {
if (term.length() > 1) {
if (search_flags & SEARCH_METHODS)
for (int i = 0; i < class_doc.methods.size(); i++) {
- String method_name = search_flags & SEARCH_CASE_SENSITIVE ? class_doc.methods[i].name : class_doc.methods[i].name.to_lower();
+ String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.methods[i].name : class_doc.methods[i].name.to_lower();
if (method_name.find(term) > -1 ||
(term.begins_with(".") && method_name.begins_with(term.right(1))) ||
(term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) ||
@@ -405,7 +405,7 @@ bool EditorHelpSearch::Runner::_phase_member_items() {
ClassMatch &match = iterator_match->value();
- TreeItem *parent = search_flags & SEARCH_SHOW_HIERARCHY ? class_items[match.doc->name] : root_item;
+ TreeItem *parent = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item;
for (int i = 0; i < match.methods.size(); i++)
_create_method_item(parent, match.doc, match.methods[i]);
for (int i = 0; i < match.signals.size(); i++)
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 9d3be1ab9e..1e9cb2f88d 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -4967,18 +4967,18 @@ void EditorNode::dim_editor(bool p_dimming) {
static int dim_count = 0;
bool dim_ui = EditorSettings::get_singleton()->get("interface/editor/dim_editor_on_dialog_popup");
if (p_dimming) {
- if (dim_ui) {
- if (dim_count == 0) {
- _start_dimming(true);
- }
- dim_count++;
+ if (dim_ui && dim_count == 0) {
+ _start_dimming(true);
}
+ dim_count++;
} else {
if (dim_count == 1) {
_start_dimming(false);
- dim_count = 0;
- } else if (dim_ui && dim_count > 0) {
+ }
+ if (dim_count > 0) {
dim_count--;
+ } else {
+ ERR_PRINT("Undimmed before dimming!");
}
}
}
diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp
index 9cf36f162d..471742948f 100644
--- a/editor/editor_profiler.cpp
+++ b/editor/editor_profiler.cpp
@@ -340,7 +340,7 @@ void EditorProfiler::_update_plot() {
}
}
- wr = PoolVector<uint8_t>::Write();
+ wr.release();
Ref<Image> img;
img.instance();
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index 1787a3b88d..e728dbac31 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -62,6 +62,10 @@ String ResourceImporterWAV::get_resource_type() const {
bool ResourceImporterWAV::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
+ if (p_option == "force/max_rate_hz" && !bool(p_options["force/max_rate"])) {
+ return false;
+ }
+
return true;
}
@@ -77,7 +81,7 @@ void ResourceImporterWAV::get_import_options(List<ImportOption> *r_options, int
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/8_bit"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/mono"), false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/max_rate"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/max_rate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "force/max_rate_hz", PROPERTY_HINT_EXP_RANGE, "11025,192000,1"), 44100));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/trim"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/normalize"), true));
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 285823d95a..d260b171a8 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -676,7 +676,7 @@ Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const S
}
}
- imgdata = PoolVector<uint8_t>::Write();
+ imgdata.release();
//post_process_preview(img);
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp
index cae705a697..d59efe49e7 100644
--- a/editor/plugins/multimesh_editor_plugin.cpp
+++ b/editor/plugins/multimesh_editor_plugin.cpp
@@ -144,7 +144,7 @@ void MultiMeshEditor::_populate() {
}
}
- w = PoolVector<Face3>::Write();
+ w.release();
PoolVector<Face3> faces = geometry;
ERR_EXPLAIN(TTR("Parent has no solid faces to populate."));
diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp
index f05e7d65d3..75d31459e8 100644
--- a/editor/plugins/particles_editor_plugin.cpp
+++ b/editor/plugins/particles_editor_plugin.cpp
@@ -197,7 +197,7 @@ void ParticlesEditorBase::_node_selected(const NodePath &p_path) {
}
}
- w = PoolVector<Face3>::Write();
+ w.release();
emission_dialog->popup_centered(Size2(300, 130));
}
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 04d13f0027..994c542187 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -190,7 +190,7 @@ void ShaderTextEditor::_check_shader_mode() {
}
}
-void ShaderTextEditor::_code_complete_script(const String &p_code, List<String> *r_options) {
+void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options) {
_check_shader_mode();
diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h
index f01e39189f..8e55a1ad70 100644
--- a/editor/plugins/shader_editor_plugin.h
+++ b/editor/plugins/shader_editor_plugin.h
@@ -53,7 +53,7 @@ protected:
static void _bind_methods();
virtual void _load_theme_settings();
- virtual void _code_complete_script(const String &p_code, List<String> *r_options);
+ virtual void _code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options);
public:
virtual void _validate_script();
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 7f7ae8f273..fc72f25b04 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -6048,7 +6048,6 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const
void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard) {
Ref<SpatialMaterial> handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true);
Ref<Texture> handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons");
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 35cfdf15be..2b59787f17 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -1491,7 +1491,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
w[i] = current_shape[i] - shape_anchor;
}
- w = PoolVector<Vector2>::Write();
+ w.release();
undo_redo->create_action(TTR("Edit Occlusion Polygon"));
undo_redo->add_do_method(edited_occlusion_shape.ptr(), "set_polygon", polygon);
@@ -1514,7 +1514,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
indices.push_back(i);
}
- w = PoolVector<Vector2>::Write();
+ w.release();
undo_redo->create_action(TTR("Edit Navigation Polygon"));
undo_redo->add_do_method(edited_navigation_shape.ptr(), "set_vertices", polygon);
@@ -2785,7 +2785,7 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
w[i] = current_shape[i] - shape_anchor;
}
- w = PoolVector<Vector2>::Write();
+ w.release();
shape->set_polygon(polygon);
undo_redo->create_action(TTR("Create Occlusion Polygon"));
@@ -2813,7 +2813,7 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
indices.push_back(i);
}
- w = PoolVector<Vector2>::Write();
+ w.release();
shape->set_vertices(polygon);
shape->add_polygon(indices);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 5f62ed0702..935946bf24 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -569,7 +569,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *dupsingle = NULL;
List<Node *> editable_children;
- for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
+ selection.sort_custom<Node::Comparator>();
+
+ for (List<Node *>::Element *E = selection.back(); E; E = E->prev()) {
Node *node = E->get();
Node *parent = node->get_parent();
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index ff188a00d3..445ca3a792 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -1164,6 +1164,8 @@ void SceneTreeDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
connect("confirmed", this, "_select");
+ filter->set_right_icon(get_icon("Search", "EditorIcons"));
+ filter->set_clear_button_enabled(true);
} break;
case NOTIFICATION_EXIT_TREE: {
disconnect("confirmed", this, "_select");
@@ -1187,20 +1189,37 @@ void SceneTreeDialog::_select() {
}
}
+void SceneTreeDialog::_filter_changed(const String &p_filter) {
+
+ tree->set_filter(p_filter);
+}
+
void SceneTreeDialog::_bind_methods() {
ClassDB::bind_method("_select", &SceneTreeDialog::_select);
ClassDB::bind_method("_cancel", &SceneTreeDialog::_cancel);
+ ClassDB::bind_method(D_METHOD("_filter_changed"), &SceneTreeDialog::_filter_changed);
+
ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::NODE_PATH, "path")));
}
SceneTreeDialog::SceneTreeDialog() {
set_title(TTR("Select a Node"));
+ VBoxContainer *vbc = memnew(VBoxContainer);
+ add_child(vbc);
+
+ filter = memnew(LineEdit);
+ filter->set_h_size_flags(SIZE_EXPAND_FILL);
+ filter->set_placeholder(TTR("Filter nodes"));
+ filter->add_constant_override("minimum_spaces", 0);
+ filter->connect("text_changed", this, "_filter_changed");
+ vbc->add_child(filter);
tree = memnew(SceneTreeEditor(false, false, true));
- add_child(tree);
+ tree->set_v_size_flags(SIZE_EXPAND_FILL);
tree->get_scene_tree()->connect("item_activated", this, "_select");
+ vbc->add_child(tree);
}
SceneTreeDialog::~SceneTreeDialog() {
diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h
index 68642910e8..61cb59ce6f 100644
--- a/editor/scene_tree_editor.h
+++ b/editor/scene_tree_editor.h
@@ -171,10 +171,12 @@ class SceneTreeDialog : public ConfirmationDialog {
SceneTreeEditor *tree;
//Button *select;
//Button *cancel;
+ LineEdit *filter;
void update_tree();
void _select();
void _cancel();
+ void _filter_changed(const String &p_filter);
protected:
void _notification(int p_what);
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 199fcfcf66..a03d015fc3 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -873,7 +873,7 @@ void InputDefault::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
return;
}
float deadzone = p_value.min == 0 ? 0.5f : 0.0f;
- bool pressed = p_value.value > deadzone ? true : false;
+ bool pressed = p_value.value > deadzone;
if (pressed == joy_buttons_pressed.has(_combine_device(map.index, p_device))) {
// button already pressed or released, this is an axis bounce value
return;
diff --git a/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist b/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist
index b7cd94e3d5..e7c4f8f340 100644
--- a/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist
+++ b/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist
@@ -36,6 +36,8 @@
<string>$camera_usage_description</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$photolibrary_usage_description</string>
+ <key>NSMicrophoneUsageDescription</key>
+ <string>$microphone_usage_description</string>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIStatusBarHidden</key>
diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp
index 093e2f3006..f23c66dbcf 100644
--- a/modules/assimp/editor_scene_importer_assimp.cpp
+++ b/modules/assimp/editor_scene_importer_assimp.cpp
@@ -854,7 +854,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
if (found) {
Ref<Texture> texture = _load_texture(state, path);
- if (texture != NULL) {
+ if (texture.is_valid()) {
_set_texture_mapping_mode(map_mode, texture);
mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true);
mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture);
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index 085cce9733..8d21b25b20 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -728,12 +728,12 @@ bool RigidBodyBullet::is_axis_locked(PhysicsServer::BodyAxis p_axis) const {
void RigidBodyBullet::reload_axis_lock() {
- btBody->setLinearFactor(btVector3(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_X), !is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Y), !is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Z)));
+ btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Z))));
if (PhysicsServer::BODY_MODE_CHARACTER == mode) {
/// When character angular is always locked
btBody->setAngularFactor(btVector3(0., 0., 0.));
} else {
- btBody->setAngularFactor(btVector3(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_X), !is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Y), !is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Z)));
+ btBody->setAngularFactor(btVector3(float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_X)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Y)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Z))));
}
}
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 0a714dcc6c..23725c4960 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -436,10 +436,10 @@ void CSGShape::_update_shape() {
}
// unset write access
- surfaces.write[i].verticesw = PoolVector<Vector3>::Write();
- surfaces.write[i].normalsw = PoolVector<Vector3>::Write();
- surfaces.write[i].uvsw = PoolVector<Vector2>::Write();
- surfaces.write[i].tansw = PoolVector<float>::Write();
+ surfaces.write[i].verticesw.release();
+ surfaces.write[i].normalsw.release();
+ surfaces.write[i].uvsw.release();
+ surfaces.write[i].tansw.release();
if (surfaces[i].last_added == 0)
continue;
diff --git a/modules/csg/doc_classes/CSGShape.xml b/modules/csg/doc_classes/CSGShape.xml
index 91f54f8246..755d8df67e 100644
--- a/modules/csg/doc_classes/CSGShape.xml
+++ b/modules/csg/doc_classes/CSGShape.xml
@@ -92,7 +92,7 @@
Only intersecting geometry remains, the rest is removed.
</constant>
<constant name="OPERATION_SUBTRACTION" value="2" enum="Operation">
- The second shape is susbtracted from the first, leaving a dent with it's shape.
+ The second shape is subtracted from the first, leaving a dent with its shape.
</constant>
</constants>
</class>
diff --git a/modules/cvtt/image_compress_cvtt.cpp b/modules/cvtt/image_compress_cvtt.cpp
index 024e9ffc3b..17b0038780 100644
--- a/modules/cvtt/image_compress_cvtt.cpp
+++ b/modules/cvtt/image_compress_cvtt.cpp
@@ -388,8 +388,8 @@ void image_decompress_cvtt(Image *p_image) {
h >>= 1;
}
- rb = PoolVector<uint8_t>::Read();
- wb = PoolVector<uint8_t>::Write();
+ rb.release();
+ wb.release();
p_image->create(p_image->get_width(), p_image->get_height(), p_image->has_mipmaps(), target_format, data);
}
diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp
index 197b41b30c..4628bd9a5b 100644
--- a/modules/dds/texture_loader_dds.cpp
+++ b/modules/dds/texture_loader_dds.cpp
@@ -251,7 +251,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
src_data.resize(size);
PoolVector<uint8_t>::Write wb = src_data.write();
f->get_buffer(wb.ptr(), size);
- wb = PoolVector<uint8_t>::Write();
} else if (info.palette) {
@@ -296,8 +295,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
if (colsize == 4)
wb[dst_ofs + 3] = palette[src_ofs + 3];
}
-
- wb = PoolVector<uint8_t>::Write();
} else {
//uncompressed generic...
@@ -444,8 +441,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
default: {
}
}
-
- wb = PoolVector<uint8_t>::Write();
}
Ref<Image> img = memnew(Image(width, height, mipmaps - 1, info.format, src_data));
diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp
index f302834222..ff925480b8 100644
--- a/modules/etc/texture_loader_pkm.cpp
+++ b/modules/etc/texture_loader_pkm.cpp
@@ -80,7 +80,7 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path,
src_data.resize(size);
PoolVector<uint8_t>::Write wb = src_data.write();
f->get_buffer(wb.ptr(), size);
- wb = PoolVector<uint8_t>::Write();
+ wb.release();
int mipmaps = h.format;
int width = h.origWidth;
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index c5c86fda0a..80da606967 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -5077,6 +5077,9 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
+ } else if (tokenizer->is_token_literal(0, true)) {
+ _set_error("Unexpected identifier");
+ return;
}
if (enum_name != "") {
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 20e454c218..2cf566941e 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -578,7 +578,7 @@ void GridMapEditor::_update_paste_indicator() {
return;
}
- Vector3 center = 0.5 * Vector3(node->get_center_x(), node->get_center_y(), node->get_center_z());
+ Vector3 center = 0.5 * Vector3(float(node->get_center_x()), float(node->get_center_y()), float(node->get_center_z()));
Vector3 scale = (Vector3(1, 1, 1) + (paste_indicator.end - paste_indicator.begin)) * node->get_cell_size();
Transform xf;
xf.scale(scale);
diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp
index 5493223cb0..dcd8b8aebd 100644
--- a/modules/jpg/image_loader_jpegd.cpp
+++ b/modules/jpg/image_loader_jpegd.cpp
@@ -96,7 +96,7 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
else
fmt = Image::FORMAT_RGB8;
- dw = PoolVector<uint8_t>::Write();
+ dw.release();
p_image->create(image_width, image_height, 0, fmt, data);
return OK;
@@ -117,8 +117,6 @@ Error ImageLoaderJPG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
Error err = jpeg_load_image_from_buffer(p_image.ptr(), w.ptr(), src_image_len);
- w = PoolVector<uint8_t>::Write();
-
return err;
}
diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp
index 877122985d..2b014c2a45 100644
--- a/modules/mono/utils/string_utils.cpp
+++ b/modules/mono/utils/string_utils.cpp
@@ -44,7 +44,7 @@ int sfind(const String &p_text, int p_from) {
int src_len = 2;
int len = p_text.length();
- if (src_len == 0 || len == 0)
+ if (len == 0)
return -1;
const CharType *src = p_text.c_str();
diff --git a/modules/opus/audio_stream_opus.cpp b/modules/opus/audio_stream_opus.cpp
index 70d0f770d8..615081d818 100644
--- a/modules/opus/audio_stream_opus.cpp
+++ b/modules/opus/audio_stream_opus.cpp
@@ -280,7 +280,7 @@ int AudioStreamPlaybackOpus::mix(int16_t *p_buffer, int p_frames) {
int todo = p_frames;
- if (todo == 0 || todo < MIN_MIX) {
+ if (todo < MIN_MIX) {
break;
}
diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp
index 8f6ffcc83f..8b1f21d95d 100644
--- a/modules/pvr/texture_loader_pvr.cpp
+++ b/modules/pvr/texture_loader_pvr.cpp
@@ -153,7 +153,7 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path,
ERR_FAIL_V(RES());
}
- w = PoolVector<uint8_t>::Write();
+ w.release();
int tex_flags = Texture::FLAG_FILTER | Texture::FLAG_REPEAT;
@@ -655,8 +655,8 @@ static void _pvrtc_decompress(Image *p_img) {
decompress_pvrtc((PVRTCBlock *)r.ptr(), _2bit, p_img->get_width(), p_img->get_height(), 0, (unsigned char *)w.ptr());
- w = PoolVector<uint8_t>::Write();
- r = PoolVector<uint8_t>::Read();
+ w.release();
+ r.release();
bool make_mipmaps = p_img->has_mipmaps();
p_img->create(p_img->get_width(), p_img->get_height(), false, Image::FORMAT_RGBA8, newdata);
diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp
index 4f38357aa1..64f4c169cb 100644
--- a/modules/squish/image_compress_squish.cpp
+++ b/modules/squish/image_compress_squish.cpp
@@ -198,8 +198,8 @@ void image_compress_squish(Image *p_image, float p_lossy_quality, Image::Compres
h = MAX(h / 2, 1);
}
- rb = PoolVector<uint8_t>::Read();
- wb = PoolVector<uint8_t>::Write();
+ rb.release();
+ wb.release();
p_image->create(p_image->get_width(), p_image->get_height(), p_image->has_mipmaps(), target_format, data);
}
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index b5f4718c72..0922471500 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -188,7 +188,7 @@ void AudioStreamOGGVorbis::set_data(const PoolVector<uint8_t> &p_data) {
ogg_stream = stb_vorbis_open_memory((const unsigned char *)src_datar.ptr(), src_data_len, &error, &ogg_alloc);
if (!ogg_stream && error == VORBIS_outofmem) {
- w = PoolVector<char>::Write();
+ w.release();
alloc_try *= 2;
} else {
diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp
index e36844a1bc..b0cd648734 100644
--- a/modules/svg/image_loader_svg.cpp
+++ b/modules/svg/image_loader_svg.cpp
@@ -123,7 +123,7 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t
rasterizer.rasterize(svg_image, 0, 0, p_scale * upscale, (unsigned char *)dw.ptr(), w, h, w * 4);
- dw = PoolVector<uint8_t>::Write();
+ dw.release();
p_image->create(w, h, false, Image::FORMAT_RGBA8, dst_image);
if (upsample)
p_image->shrink_x2();
diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp
index a3c0f5ded7..6ee408d472 100644
--- a/modules/tga/image_loader_tga.cpp
+++ b/modules/tga/image_loader_tga.cpp
@@ -199,7 +199,7 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
}
}
- image_data_w = PoolVector<uint8_t>::Write();
+ image_data_w.release();
p_image->create(width, height, 0, Image::FORMAT_RGBA8, image_data);
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp
index a9340b1498..74a584821a 100644
--- a/modules/tinyexr/image_loader_tinyexr.cpp
+++ b/modules/tinyexr/image_loader_tinyexr.cpp
@@ -235,7 +235,7 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
p_image->create(exr_image.width, exr_image.height, false, format, imgdata);
- w = PoolVector<uint8_t>::Write();
+ w.release();
FreeEXRHeader(&exr_header);
FreeEXRImage(&exr_image);
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index df5bb9ca2e..b816e37936 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -1487,7 +1487,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
Variant **output_args = (Variant **)(input_args + max_input_args);
int flow_max = f->flow_stack_size;
int *flow_stack = flow_max ? (int *)(output_args + max_output_args) : (int *)NULL;
- int *pass_stack = flow_stack + flow_max;
+ int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)NULL;
String error_str;
@@ -1905,7 +1905,7 @@ Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p
Variant **output_args = (Variant **)(input_args + max_input_args);
int flow_max = f->flow_stack_size;
int *flow_stack = flow_max ? (int *)(output_args + max_output_args) : (int *)NULL;
- int *pass_stack = flow_stack + flow_max;
+ int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)NULL;
for (int i = 0; i < f->node_count; i++) {
sequence_bits[i] = false; //all starts as false
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index f8cb6cfa3c..0413bbf303 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -570,7 +570,6 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
Node *bnode = _get_base_node();
if (bnode) {
property.hint_string = bnode->get_path(); //convert to loong string
- } else {
}
}
}
@@ -1035,8 +1034,6 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const
pi.name = (call_mode == CALL_MODE_INSTANCE ? String("instance") : Variant::get_type_name(basic_type).to_lower());
_adjust_input_index(pi);
return pi;
- } else {
- p_idx--;
}
}
@@ -1352,7 +1349,6 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
Node *bnode = _get_base_node();
if (bnode) {
property.hint_string = bnode->get_path(); //convert to loong string
- } else {
}
}
}
@@ -1794,8 +1790,6 @@ PropertyInfo VisualScriptPropertyGet::get_input_value_port_info(int p_idx) const
pi.type = (call_mode == CALL_MODE_INSTANCE ? Variant::OBJECT : basic_type);
pi.name = (call_mode == CALL_MODE_INSTANCE ? String("instance") : Variant::get_type_name(basic_type).to_lower());
return pi;
- } else {
- p_idx--;
}
}
return PropertyInfo();
@@ -2073,7 +2067,6 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
Node *bnode = _get_base_node();
if (bnode) {
property.hint_string = bnode->get_path(); //convert to loong string
- } else {
}
}
}
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index 962560cc96..ebd0f0b3cb 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -431,7 +431,6 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const {
Node *bnode = _get_base_node();
if (bnode) {
property.hint_string = bnode->get_path(); //convert to loong string
- } else {
}
}
}
diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp
index e652abbe6a..2f4a45f108 100644
--- a/modules/vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp
@@ -103,7 +103,7 @@ int AudioStreamPlaybackOGGVorbis::mix(int16_t *p_buffer, int p_frames) {
int todo = p_frames;
- if (todo == 0 || todo < MIN_MIX) {
+ if (todo < MIN_MIX) {
break;
}
diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp
index 928a0dcbd3..630c15f140 100644
--- a/modules/webp/image_loader_webp.cpp
+++ b/modules/webp/image_loader_webp.cpp
@@ -71,7 +71,7 @@ static PoolVector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_q
w[3] = 'P';
copymem(&w[4], dst_buff, dst_size);
free(dst_buff);
- w = PoolVector<uint8_t>::Write();
+ w.release();
return dst;
}
@@ -110,7 +110,7 @@ static Ref<Image> _webp_lossy_unpack(const PoolVector<uint8_t> &p_buffer) {
//ERR_EXPLAIN("Error decoding webp! - "+p_file);
ERR_FAIL_COND_V(errdec, Ref<Image>());
- dst_w = PoolVector<uint8_t>::Write();
+ dst_w.release();
Ref<Image> img = memnew(Image(features.width, features.height, 0, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image));
return img;
@@ -137,7 +137,7 @@ Error webp_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
} else {
errdec = WebPDecodeRGBInto(p_buffer, p_buffer_len, dst_w.ptr(), datasize, 3 * features.width) == NULL;
}
- dst_w = PoolVector<uint8_t>::Write();
+ dst_w.release();
//ERR_EXPLAIN("Error decoding webp!");
ERR_FAIL_COND_V(errdec, ERR_FILE_CORRUPT);
@@ -171,8 +171,6 @@ Error ImageLoaderWEBP::load_image(Ref<Image> p_image, FileAccess *f, bool p_forc
Error err = webp_load_image_from_buffer(p_image.ptr(), w.ptr(), src_image_len);
- w = PoolVector<uint8_t>::Write();
-
return err;
}
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp
index 23cbf916eb..e24cb850ec 100644
--- a/modules/websocket/websocket_multiplayer_peer.cpp
+++ b/modules/websocket/websocket_multiplayer_peer.cpp
@@ -191,7 +191,7 @@ void WebSocketMultiplayerPeer::_send_sys(Ref<WebSocketPeer> p_peer, uint8_t p_ty
p_peer->put_packet(&(message.read()[0]), message.size());
}
-PoolVector<uint8_t> WebSocketMultiplayerPeer::_make_pkt(uint32_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size) {
+PoolVector<uint8_t> WebSocketMultiplayerPeer::_make_pkt(uint8_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size) {
PoolVector<uint8_t> out;
out.resize(PROTO_SIZE + p_data_size);
diff --git a/modules/websocket/websocket_multiplayer_peer.h b/modules/websocket/websocket_multiplayer_peer.h
index 7fd97a6595..e3ab0784ab 100644
--- a/modules/websocket/websocket_multiplayer_peer.h
+++ b/modules/websocket/websocket_multiplayer_peer.h
@@ -41,7 +41,7 @@ class WebSocketMultiplayerPeer : public NetworkedMultiplayerPeer {
GDCLASS(WebSocketMultiplayerPeer, NetworkedMultiplayerPeer);
private:
- PoolVector<uint8_t> _make_pkt(uint32_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size);
+ PoolVector<uint8_t> _make_pkt(uint8_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size);
void _store_pkt(int32_t p_source, int32_t p_dest, const uint8_t *p_data, uint32_t p_data_size);
Error _server_relay(int32_t p_from, int32_t p_to, const uint8_t *p_buffer, uint32_t p_buffer_size);
diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp
index 1e140a716f..0d09a4d74e 100644
--- a/modules/websocket/wsl_server.cpp
+++ b/modules/websocket/wsl_server.cpp
@@ -42,7 +42,7 @@ WSLServer::PendingPeer::PendingPeer() {
memset(req_buf, 0, sizeof(req_buf));
}
-bool WSLServer::PendingPeer::_parse_request(String &r_key) {
+bool WSLServer::PendingPeer::_parse_request(const PoolStringArray p_protocols) {
Vector<String> psa = String((char *)req_buf).split("\r\n");
int len = psa.size();
if (len < 4) {
@@ -87,11 +87,29 @@ bool WSLServer::PendingPeer::_parse_request(String &r_key) {
_WLS_CHECK_EX("connection");
#undef _WLS_CHECK_EX
#undef _WLS_CHECK
- r_key = headers["sec-websocket-key"];
+ key = headers["sec-websocket-key"];
+ if (headers.has("sec-websocket-protocol")) {
+ Vector<String> protos = headers["sec-websocket-protocol"].split(",");
+ for (int i = 0; i < protos.size(); i++) {
+ // Check if we have the given protocol
+ for (int j = 0; j < p_protocols.size(); j++) {
+ if (protos[i] != p_protocols[j])
+ continue;
+ protocol = protos[i];
+ break;
+ }
+ // Found a protocol
+ if (protocol != "")
+ break;
+ }
+ if (protocol == "") // Invalid protocol(s) requested
+ return false;
+ } else if (p_protocols.size() > 0) // No protocol requested, but we need one
+ return false;
return true;
}
-Error WSLServer::PendingPeer::do_handshake() {
+Error WSLServer::PendingPeer::do_handshake(PoolStringArray p_protocols) {
if (OS::get_singleton()->get_ticks_msec() - time > WSL_SERVER_TIMEOUT)
return ERR_TIMEOUT;
if (!has_request) {
@@ -111,13 +129,15 @@ Error WSLServer::PendingPeer::do_handshake() {
int l = req_pos;
if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') {
r[l - 3] = '\0';
- if (!_parse_request(key)) {
+ if (!_parse_request(p_protocols)) {
return FAILED;
}
String s = "HTTP/1.1 101 Switching Protocols\r\n";
s += "Upgrade: websocket\r\n";
s += "Connection: Upgrade\r\n";
s += "Sec-WebSocket-Accept: " + WSLPeer::compute_key_response(key) + "\r\n";
+ if (protocol != "")
+ s += "Sec-WebSocket-Protocol: " + protocol + "\r\n";
s += "\r\n";
response = s.utf8();
has_request = true;
@@ -143,6 +163,7 @@ Error WSLServer::listen(int p_port, PoolVector<String> p_protocols, bool gd_mp_a
ERR_FAIL_COND_V(is_listening(), ERR_ALREADY_IN_USE);
_is_multiplayer = gd_mp_api;
+ _protocols = p_protocols;
_server->listen(p_port);
return OK;
@@ -167,7 +188,7 @@ void WSLServer::poll() {
List<Ref<PendingPeer> > remove_peers;
for (List<Ref<PendingPeer> >::Element *E = _pending.front(); E; E = E->next()) {
Ref<PendingPeer> ppeer = E->get();
- Error err = ppeer->do_handshake();
+ Error err = ppeer->do_handshake(_protocols);
if (err == ERR_BUSY) {
continue;
} else if (err != OK) {
@@ -188,7 +209,7 @@ void WSLServer::poll() {
_peer_map[id] = ws_peer;
remove_peers.push_back(ppeer);
- _on_connect(id, "");
+ _on_connect(id, ppeer->protocol);
}
for (List<Ref<PendingPeer> >::Element *E = remove_peers.front(); E; E = E->next()) {
_pending.erase(E->get());
diff --git a/modules/websocket/wsl_server.h b/modules/websocket/wsl_server.h
index b0520bd731..2ceb941073 100644
--- a/modules/websocket/wsl_server.h
+++ b/modules/websocket/wsl_server.h
@@ -49,7 +49,7 @@ private:
class PendingPeer : public Reference {
private:
- bool _parse_request(String &r_key);
+ bool _parse_request(const PoolStringArray p_protocols);
public:
Ref<StreamPeer> connection;
@@ -58,13 +58,14 @@ private:
uint8_t req_buf[WSL_MAX_HEADER_SIZE];
int req_pos;
String key;
+ String protocol;
bool has_request;
CharString response;
int response_sent;
PendingPeer();
- Error do_handshake();
+ Error do_handshake(const PoolStringArray p_protocols);
};
int _in_buf_size;
@@ -74,6 +75,7 @@ private:
List<Ref<PendingPeer> > _pending;
Ref<TCP_Server> _server;
+ PoolStringArray _protocols;
public:
Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets);
diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp
index 63bc5f69d1..5b8cf01138 100644
--- a/platform/android/file_access_jandroid.cpp
+++ b/platform/android/file_access_jandroid.cpp
@@ -62,7 +62,7 @@ Error FileAccessJAndroid::_open(const String &p_path, int p_mode_flags) {
JNIEnv *env = ThreadAndroid::get_env();
jstring js = env->NewStringUTF(path.utf8().get_data());
- int res = env->CallIntMethod(io, _file_open, js, p_mode_flags & WRITE ? true : false);
+ int res = env->CallIntMethod(io, _file_open, js, (p_mode_flags & WRITE) ? true : false);
env->DeleteLocalRef(js);
OS::get_singleton()->print("fopen: '%s' ret %i\n", path.utf8().get_data(), res);
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index 466f79c215..77f077456e 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -289,7 +289,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
PoolVector<int>::Write w = sarr.write();
env->GetIntArrayRegion(arr, 0, fCount, w.ptr());
- w = PoolVector<int>::Write();
+ w.release();
return sarr;
};
@@ -302,7 +302,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
PoolVector<uint8_t>::Write w = sarr.write();
env->GetByteArrayRegion(arr, 0, fCount, reinterpret_cast<signed char *>(w.ptr()));
- w = PoolVector<uint8_t>::Write();
+ w.release();
return sarr;
};
@@ -514,7 +514,7 @@ public:
PoolVector<int>::Write w = sarr.write();
env->GetIntArrayRegion(arr, 0, fCount, w.ptr());
- w = PoolVector<int>::Write();
+ w.release();
ret = sarr;
env->DeleteLocalRef(arr);
} break;
@@ -528,7 +528,7 @@ public:
PoolVector<float>::Write w = sarr.write();
env->GetFloatArrayRegion(arr, 0, fCount, w.ptr());
- w = PoolVector<float>::Write();
+ w.release();
ret = sarr;
env->DeleteLocalRef(arr);
} break;
diff --git a/platform/iphone/camera_ios.mm b/platform/iphone/camera_ios.mm
index 5a54eaee9b..029ce6debf 100644
--- a/platform/iphone/camera_ios.mm
+++ b/platform/iphone/camera_ios.mm
@@ -397,6 +397,22 @@ void CameraIOS::update_feeds() {
};
CameraIOS::CameraIOS() {
+ // check if we have our usage description
+ NSString *usage_desc = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSCameraUsageDescription"];
+ if (usage_desc == NULL) {
+ // don't initialise if we don't get anything
+ print_line("No NSCameraUsageDescription key in pList, no access to cameras.");
+ return;
+ } else if (usage_desc.length == 0) {
+ // don't initialise if we don't get anything
+ print_line("Empty NSCameraUsageDescription key in pList, no access to cameras.");
+ return;
+ }
+
+ // now we'll request access.
+ // If this is the first time the user will be prompted with the string (iOS will read it).
+ // Once a decision is made it is returned. If the user wants to change it later on they
+ // need to go into setting.
print_line("Requesting Camera permissions");
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp
index 99ce2e8f87..85a45d62f8 100644
--- a/platform/iphone/export/export.cpp
+++ b/platform/iphone/export/export.cpp
@@ -268,8 +268,9 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/in_app_purchases"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/push_notifications"), false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/camera_usage_description"), "Godot would like to use your camera"));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/photolibrary_usage_description"), "Godot would like to use your photos"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/camera_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the camera"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/microphone_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the microphone"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/photolibrary_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need access to the photo library"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/portrait"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/landscape_left"), true));
@@ -398,6 +399,9 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
} else if (lines[i].find("$camera_usage_description") != -1) {
String description = p_preset->get("privacy/camera_usage_description");
strnew += lines[i].replace("$camera_usage_description", description) + "\n";
+ } else if (lines[i].find("$microphone_usage_description") != -1) {
+ String description = p_preset->get("privacy/microphone_usage_description");
+ strnew += lines[i].replace("$microphone_usage_description", description) + "\n";
} else if (lines[i].find("$photolibrary_usage_description") != -1) {
String description = p_preset->get("privacy/photolibrary_usage_description");
strnew += lines[i].replace("$photolibrary_usage_description", description) + "\n";
diff --git a/platform/x11/godot_x11.cpp b/platform/x11/godot_x11.cpp
index 9baa4d6dca..755ef7a84f 100644
--- a/platform/x11/godot_x11.cpp
+++ b/platform/x11/godot_x11.cpp
@@ -43,6 +43,7 @@ int main(int argc, char *argv[]) {
setlocale(LC_CTYPE, "");
char *cwd = (char *)malloc(PATH_MAX);
+ ERR_FAIL_COND_V(!cwd, ERR_OUT_OF_MEMORY);
char *ret = getcwd(cwd, PATH_MAX);
Error err = Main::setup(argv[0], argc - 1, &argv[1]);
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index ef7644fcab..bb144dda96 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -70,7 +70,7 @@ void CollisionPolygon2D::_build_polygon() {
w[(i << 1) + 1] = polygon[(i + 1) % polygon.size()];
}
- w = PoolVector<Vector2>::Write();
+ w.release();
concave->set_segments(segments);
parent->shape_owner_add_shape(owner_id, concave);
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index 2091085420..591933d972 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -661,8 +661,9 @@ void CPUParticles2D::_particles_process(float p_delta) {
//do none
} break;
case EMISSION_SHAPE_SPHERE: {
- Vector3 sphere_shape = Vector3(Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0).normalized() * emission_sphere_radius;
- p.transform[2] = Vector2(sphere_shape.x, sphere_shape.y);
+ float s = Math::randf(), t = 2.0 * Math_PI * Math::randf();
+ float radius = emission_sphere_radius * Math::sqrt(1.0 - s * s);
+ p.transform[2] = Vector2(Math::cos(t), Math::sin(t)) * radius;
} break;
case EMISSION_SHAPE_RECTANGLE: {
p.transform[2] = Vector2(Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0) * emission_rect_extents;
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index e062067248..f2f53d4354 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -58,7 +58,7 @@ Rect2 Path2D::_edit_get_rect() const {
}
bool Path2D::_edit_use_rect() const {
- return true;
+ return curve.is_valid() && curve->get_point_count() != 0;
}
bool Path2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index f6f1bad581..32a0b732c0 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -76,7 +76,7 @@ Rect2 Polygon2D::_edit_get_rect() const {
}
bool Polygon2D::_edit_use_rect() const {
- return true;
+ return polygon.size() > 0;
}
bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 22bc0e44e6..cf544a5473 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -861,7 +861,7 @@ void TileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_
if (!E && p_tile == INVALID_CELL)
return; //nothing to do
- PosKey qk(p_x / _get_quadrant_size(), p_y / _get_quadrant_size());
+ PosKey qk = pk.to_quadrant(_get_quadrant_size());
if (p_tile == INVALID_CELL) {
//erase existing
tile_map.erase(pk);
@@ -1020,7 +1020,7 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) {
E->get().autotile_coord_x = (int)coord.x;
E->get().autotile_coord_y = (int)coord.y;
- PosKey qk(p_x / _get_quadrant_size(), p_y / _get_quadrant_size());
+ PosKey qk = p.to_quadrant(_get_quadrant_size());
Map<PosKey, Quadrant>::Element *Q = quadrant_map.find(qk);
_make_quadrant_dirty(Q);
@@ -1117,7 +1117,7 @@ void TileMap::set_cell_autotile_coord(int p_x, int p_y, const Vector2 &p_coord)
c.autotile_coord_y = p_coord.y;
tile_map[pk] = c;
- PosKey qk(p_x / _get_quadrant_size(), p_y / _get_quadrant_size());
+ PosKey qk = pk.to_quadrant(_get_quadrant_size());
Map<PosKey, Quadrant>::Element *Q = quadrant_map.find(qk);
if (!Q)
@@ -1144,7 +1144,7 @@ void TileMap::_recreate_quadrants() {
for (Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) {
- PosKey qk(E->key().x / _get_quadrant_size(), E->key().y / _get_quadrant_size());
+ PosKey qk = PosKey(E->key().x, E->key().y).to_quadrant(_get_quadrant_size());
Map<PosKey, Quadrant>::Element *Q = quadrant_map.find(qk);
if (!Q) {
@@ -1275,13 +1275,17 @@ PoolVector<int> TileMap::_get_tile_data() const {
idx += 3;
}
- w = PoolVector<int>::Write();
+ w.release();
return data;
}
Rect2 TileMap::_edit_get_rect() const {
- const_cast<TileMap *>(this)->update_dirty_quadrants();
+ if (pending_update) {
+ const_cast<TileMap *>(this)->update_dirty_quadrants();
+ } else {
+ const_cast<TileMap *>(this)->_recompute_rect_cache();
+ }
return rect_cache;
}
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 6c9648ff32..e30b7eff83 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -94,6 +94,13 @@ private:
bool operator==(const PosKey &p_k) const { return (y == p_k.y && x == p_k.x); }
+ PosKey to_quadrant(const int &p_quadrant_size) const {
+ // rounding down, instead of simply rounding towards zero (truncating)
+ return PosKey(
+ x > 0 ? x / p_quadrant_size : (x - (p_quadrant_size - 1)) / p_quadrant_size,
+ y > 0 ? y / p_quadrant_size : (y - (p_quadrant_size - 1)) / p_quadrant_size);
+ }
+
PosKey(int16_t p_x, int16_t p_y) {
x = p_x;
y = p_y;
diff --git a/scene/3d/baked_lightmap.h b/scene/3d/baked_lightmap.h
index fac4ad3908..3a9f4cf01d 100644
--- a/scene/3d/baked_lightmap.h
+++ b/scene/3d/baked_lightmap.h
@@ -179,7 +179,7 @@ public:
void set_extents(const Vector3 &p_extents);
Vector3 get_extents() const;
- void set_bake_default_texels_per_unit(const float &p_extents);
+ void set_bake_default_texels_per_unit(const float &p_bake_texels_per_unit);
float get_bake_default_texels_per_unit() const;
void set_propagation(float p_propagation);
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp
index 358c4bdb44..86b407b9e6 100644
--- a/scene/3d/cpu_particles.cpp
+++ b/scene/3d/cpu_particles.cpp
@@ -643,7 +643,9 @@ void CPUParticles::_particles_process(float p_delta) {
//do none
} break;
case EMISSION_SHAPE_SPHERE: {
- p.transform.origin = Vector3(Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0).normalized() * emission_sphere_radius;
+ float s = 2.0 * Math::randf() - 1.0, t = 2.0 * Math_PI * Math::randf();
+ float radius = emission_sphere_radius * Math::sqrt(1.0 - s * s);
+ p.transform.origin = Vector3(radius * Math::cos(t), radius * Math::sin(t), emission_sphere_radius * s);
} break;
case EMISSION_SHAPE_BOX: {
p.transform.origin = Vector3(Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0) * emission_box_extents;
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 00a168fc39..a6ccdb5791 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -257,7 +257,7 @@ String Particles::get_configuration_warning() const {
SpatialMaterial *spat = Object::cast_to<SpatialMaterial>(draw_passes[i]->surface_get_material(j).ptr());
anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == SpatialMaterial::BILLBOARD_PARTICLES);
}
- if (meshes_found && anim_material_found) break;
+ if (anim_material_found) break;
}
}
diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body.cpp
index b9f6865298..386e127f8b 100644
--- a/scene/3d/soft_body.cpp
+++ b/scene/3d/soft_body.cpp
@@ -73,7 +73,7 @@ void SoftBodyVisualServerHandler::open() {
}
void SoftBodyVisualServerHandler::close() {
- write_buffer = PoolVector<uint8_t>::Write();
+ write_buffer.release();
}
void SoftBodyVisualServerHandler::commit_changes() {
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 9f73484b6a..d0f8799a64 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -254,7 +254,7 @@ Ref<TriangleMesh> SpriteBase3D::generate_triangle_mesh() const {
facesw[j] = vtx;
}
- facesw = PoolVector<Vector3>::Write();
+ facesw.release();
triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh));
triangle_mesh->create(faces);
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 91b76839d7..a3bc68ffcd 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -754,7 +754,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
for (int i = current + 1; i <= items.size(); i++) {
if (i == items.size()) {
- if (current == 0)
+ if (current == 0 || current == -1)
break;
else
i = 0;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 7a015f77db..3dcbf64e7c 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1191,7 +1191,7 @@ void LineEdit::set_cursor_position(int p_pos) {
if (cursor_pos <= window_pos) {
/* Adjust window if cursor goes too much to the left */
set_window_pos(MAX(0, cursor_pos - 1));
- } else if (cursor_pos > window_pos) {
+ } else {
/* Adjust window if cursor goes too much to the right */
int window_width = get_size().width - style->get_minimum_size().width;
bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled;
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 492e379440..9e996e5519 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -48,6 +48,14 @@ void Popup::_notification(int p_what) {
update_configuration_warning();
}
+ if (p_what == NOTIFICATION_EXIT_TREE) {
+ if (popped_up) {
+ popped_up = false;
+ notification(NOTIFICATION_POPUP_HIDE);
+ emit_signal("popup_hide");
+ }
+ }
+
if (p_what == NOTIFICATION_ENTER_TREE) {
//small helper to make editing of these easier in editor
#ifdef TOOLS_ENABLED
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 9242e7997a..a7b4e08553 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1403,7 +1403,7 @@ void TextEdit::_notification(int p_what) {
}
int line_from = CLAMP(completion_index - lines / 2, 0, completion_options.size() - lines);
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(completion_rect.position.x, completion_rect.position.y + (completion_index - line_from) * get_row_height()), Size2(completion_rect.size.width, get_row_height())), cache.completion_selected_color);
- draw_rect(Rect2(completion_rect.position, Size2(nofs, completion_rect.size.height)), cache.completion_existing_color);
+ draw_rect(Rect2(completion_rect.position + Vector2(icon_area_size.x + icon_hsep, 0), Size2(nofs, completion_rect.size.height)), cache.completion_existing_color);
for (int i = 0; i < lines; i++) {
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index c2493ab321..8624baa005 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -571,7 +571,14 @@ int TreeItem::get_button_by_id(int p_column, int p_id) const {
return -1;
}
+void TreeItem::set_disable_button(int p_column, int p_idx, bool p_disabled) {
+ ERR_FAIL_INDEX(p_column, cells.size());
+ ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size());
+
+ cells.write[p_column].buttons.write[p_idx].disabled = p_disabled;
+ _changed_notify(p_column);
+}
bool TreeItem::is_button_disabled(int p_column, int p_idx) const {
ERR_FAIL_INDEX_V(p_column, cells.size(), false);
@@ -786,6 +793,7 @@ void TreeItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_button", "column", "button_idx", "button"), &TreeItem::set_button);
ClassDB::bind_method(D_METHOD("erase_button", "column", "button_idx"), &TreeItem::erase_button);
ClassDB::bind_method(D_METHOD("is_button_disabled", "column", "button_idx"), &TreeItem::is_button_disabled);
+ ClassDB::bind_method(D_METHOD("set_disable_button", "column", "button_idx", "disabled"), &TreeItem::set_disable_button);
ClassDB::bind_method(D_METHOD("set_expand_right", "column", "enable"), &TreeItem::set_expand_right);
ClassDB::bind_method(D_METHOD("get_expand_right", "column"), &TreeItem::get_expand_right);
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 45d451eb72..6e5e2c1eba 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -212,6 +212,7 @@ public:
bool is_button_disabled(int p_column, int p_idx) const;
void set_button(int p_column, int p_idx, const Ref<Texture> &p_button);
void set_button_color(int p_column, int p_idx, const Color &p_color);
+ void set_disable_button(int p_column, int p_idx, bool p_disabled);
/* range works for mode number or mode combo */
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 8561d9aedb..334c49f7cc 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -3064,6 +3064,7 @@ void Viewport::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "arvr"), "set_use_arvr", "use_arvr");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "size_override_stretch"), "set_size_override_stretch", "is_size_override_stretch_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world"), "set_use_own_world", "is_using_own_world");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world", PROPERTY_HINT_RESOURCE_TYPE, "World"), "set_world", "get_world");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_2d", PROPERTY_HINT_RESOURCE_TYPE, "World2D", 0), "set_world_2d", "get_world_2d");
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 1ca643cd7a..af2a8c931f 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -403,7 +403,7 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
w[idx++] = scale.z;
}
- w = PoolVector<real_t>::Write();
+ w.release();
r_ret = keys;
return true;
@@ -438,8 +438,8 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
idx++;
}
- wti = PoolVector<float>::Write();
- wtr = PoolVector<float>::Write();
+ wti.release();
+ wtr.release();
d["times"] = key_times;
d["transitions"] = key_transitions;
@@ -478,8 +478,8 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
idx++;
}
- wti = PoolVector<float>::Write();
- wtr = PoolVector<float>::Write();
+ wti.release();
+ wtr.release();
d["times"] = key_times;
d["transitions"] = key_transitions;
@@ -523,8 +523,8 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
idx++;
}
- wti = PoolVector<float>::Write();
- wpo = PoolVector<float>::Write();
+ wti.release();
+ wpo.release();
d["times"] = key_times;
d["points"] = key_points;
@@ -562,7 +562,7 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
idx++;
}
- wti = PoolVector<float>::Write();
+ wti.release();
d["times"] = key_times;
d["clips"] = clips;
@@ -595,8 +595,8 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
wcl[i] = vls[i].value;
}
- wti = PoolVector<float>::Write();
- wcl = PoolVector<String>::Write();
+ wti.release();
+ wcl.release();
d["times"] = key_times;
d["clips"] = clips;
@@ -1815,7 +1815,7 @@ T Animation::_interpolate(const Vector<TKey<T> > &p_keys, float p_time, Interpol
next = idx;
}
- } else if (idx < 0) {
+ } else {
// only allow extending first key to anim start if looping
if (loop)
diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp
index 3b44f05b94..ccff617a16 100644
--- a/scene/resources/dynamic_font_stb.cpp
+++ b/scene/resources/dynamic_font_stb.cpp
@@ -55,7 +55,7 @@ void DynamicFontData::lock() {
void DynamicFontData::unlock() {
- fr = PoolVector<uint8_t>::Read();
+ fr.release();
}
void DynamicFontData::set_font_data(const PoolVector<uint8_t> &p_font) {
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 6443b44bb6..aff274cd21 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -98,7 +98,7 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
}
}
- facesw = PoolVector<Vector3>::Write();
+ facesw.release();
triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh));
triangle_mesh->create(faces);
@@ -436,7 +436,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
r[i] = t;
}
- r = PoolVector<Vector3>::Write();
+ r.release();
arrays[ARRAY_VERTEX] = vertices;
if (!has_indices) {
@@ -452,7 +452,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
iw[j + 2] = j + 1;
}
- iw = PoolVector<int>::Write();
+ iw.release();
arrays[ARRAY_INDEX] = new_indices;
} else {
@@ -461,7 +461,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
SWAP(ir[j + 1], ir[j + 2]);
}
- ir = PoolVector<int>::Write();
+ ir.release();
arrays[ARRAY_INDEX] = indices;
}
}
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
index edca9e5171..b4818755b4 100644
--- a/scene/resources/particles_material.cpp
+++ b/scene/resources/particles_material.cpp
@@ -332,7 +332,10 @@ void ParticlesMaterial::_update_shader() {
//do none
} break;
case EMISSION_SHAPE_SPHERE: {
- code += " TRANSFORM[3].xyz = normalize(vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0 - 1.0)) * emission_sphere_radius;\n";
+ code += " float s = rand_from_seed(alt_seed) * 2.0 - 1.0;\n";
+ code += " float t = rand_from_seed(alt_seed) * 2.0 * pi;\n";
+ code += " float radius = emission_sphere_radius * sqrt(1.0 - s * s);\n";
+ code += " TRANSFORM[3].xyz = vec3(radius * cos(t), radius * sin(t), emission_sphere_radius * s);\n";
} break;
case EMISSION_SHAPE_BOX: {
code += " TRANSFORM[3].xyz = vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0 - 1.0) * emission_box_extents;\n";
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index 339f008a3d..12bf007bb1 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -1537,9 +1537,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
f->store_line("]\n"); //one empty line
}
- {
- }
-
#ifdef TOOLS_ENABLED
//keep order from cached ids
Set<int> cached_ids_found;
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index 496b1b2bdc..2588e41951 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -307,7 +307,7 @@ Array SurfaceTool::commit_to_arrays() {
}
}
- w = PoolVector<Vector3>::Write();
+ w.release();
a[i] = array;
} break;
@@ -335,7 +335,7 @@ Array SurfaceTool::commit_to_arrays() {
}
}
- w = PoolVector<Vector2>::Write();
+ w.release();
a[i] = array;
} break;
case Mesh::ARRAY_TANGENT: {
@@ -358,7 +358,7 @@ Array SurfaceTool::commit_to_arrays() {
w[idx + 3] = d < 0 ? -1 : 1;
}
- w = PoolVector<float>::Write();
+ w.release();
a[i] = array;
} break;
@@ -375,7 +375,7 @@ Array SurfaceTool::commit_to_arrays() {
w[idx] = v.color;
}
- w = PoolVector<Color>::Write();
+ w.release();
a[i] = array;
} break;
case Mesh::ARRAY_BONES: {
@@ -396,7 +396,7 @@ Array SurfaceTool::commit_to_arrays() {
}
}
- w = PoolVector<int>::Write();
+ w.release();
a[i] = array;
} break;
@@ -418,7 +418,7 @@ Array SurfaceTool::commit_to_arrays() {
}
}
- w = PoolVector<float>::Write();
+ w.release();
a[i] = array;
} break;
@@ -436,7 +436,7 @@ Array SurfaceTool::commit_to_arrays() {
w[idx] = E->get();
}
- w = PoolVector<int>::Write();
+ w.release();
a[i] = array;
} break;
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index a44471a365..746edc65b0 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -357,9 +357,13 @@ int VisualShaderNodeTexture::get_output_port_count() const {
return 2;
}
VisualShaderNodeTexture::PortType VisualShaderNodeTexture::get_output_port_type(int p_port) const {
+ if (p_port == 0 && source == SOURCE_DEPTH)
+ return PORT_TYPE_SCALAR;
return p_port == 0 ? PORT_TYPE_VECTOR : PORT_TYPE_SCALAR;
}
String VisualShaderNodeTexture::get_output_port_name(int p_port) const {
+ if (p_port == 0 && source == SOURCE_DEPTH)
+ return "depth";
return p_port == 0 ? "rgb" : "alpha";
}
@@ -475,6 +479,41 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
return code;
}
+ if (p_for_preview) // DEPTH_TEXTURE is not supported in preview(canvas_item) shader
+ {
+ if (source == SOURCE_DEPTH) {
+ String code;
+ code += "\t" + p_output_vars[0] + " = 0.0;\n";
+ code += "\t" + p_output_vars[1] + " = 1.0;\n";
+ return code;
+ }
+ }
+
+ if (source == SOURCE_DEPTH && p_mode == Shader::MODE_SPATIAL && p_type == VisualShader::TYPE_FRAGMENT) {
+
+ String code = "\t{\n";
+ if (p_input_vars[0] == String()) { //none bound, do nothing
+
+ code += "\t\tfloat _depth = 0.0;\n";
+
+ } else if (p_input_vars[1] == String()) {
+ //no lod
+ code += "\t\tfloat _depth = texture( DEPTH_TEXTURE , " + p_input_vars[0] + ".xy ).r;\n";
+ } else {
+ code += "\t\tfloat _depth = textureLod( DEPTH_TEXTURE , " + p_input_vars[0] + ".xy , " + p_input_vars[1] + " ).r;\n";
+ }
+
+ code += "\t\t" + p_output_vars[0] + " = _depth;\n";
+ code += "\t\t" + p_output_vars[1] + " = 1.0;\n";
+ code += "\t}\n";
+ return code;
+ } else if (source == SOURCE_DEPTH) {
+ String code;
+ code += "\t" + p_output_vars[0] + " = 0.0;\n";
+ code += "\t" + p_output_vars[1] + " = 1.0;\n";
+ return code;
+ }
+
//none
String code;
code += "\t" + p_output_vars[0] + " = vec3(0.0);\n";
@@ -543,6 +582,14 @@ String VisualShaderNodeTexture::get_warning(Shader::Mode p_mode, VisualShader::T
return String(); // all good
}
+ if (source == SOURCE_DEPTH && p_mode == Shader::MODE_SPATIAL && p_type == VisualShader::TYPE_FRAGMENT) {
+
+ if (get_output_port_for_preview() == 0) { // DEPTH_TEXTURE is not supported in preview(canvas_item) shader
+ return TTR("Invalid source for preview.");
+ }
+ return String(); // all good
+ }
+
return TTR("Invalid source for shader.");
}
@@ -557,7 +604,7 @@ void VisualShaderNodeTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_texture_type", "value"), &VisualShaderNodeTexture::set_texture_type);
ClassDB::bind_method(D_METHOD("get_texture_type"), &VisualShaderNodeTexture::get_texture_type);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "source", PROPERTY_HINT_ENUM, "Texture,Screen,Texture2D,NormalMap2D"), "set_source", "get_source");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "source", PROPERTY_HINT_ENUM, "Texture,Screen,Texture2D,NormalMap2D,Depth"), "set_source", "get_source");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_type", PROPERTY_HINT_ENUM, "Data,Color,Normalmap"), "set_texture_type", "get_texture_type");
@@ -565,6 +612,7 @@ void VisualShaderNodeTexture::_bind_methods() {
BIND_ENUM_CONSTANT(SOURCE_SCREEN);
BIND_ENUM_CONSTANT(SOURCE_2D_TEXTURE);
BIND_ENUM_CONSTANT(SOURCE_2D_NORMAL);
+ BIND_ENUM_CONSTANT(SOURCE_DEPTH);
BIND_ENUM_CONSTANT(TYPE_DATA);
BIND_ENUM_CONSTANT(TYPE_COLOR);
BIND_ENUM_CONSTANT(TYPE_NORMALMAP);
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index ef64b50711..235714f697 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -198,7 +198,8 @@ public:
SOURCE_TEXTURE,
SOURCE_SCREEN,
SOURCE_2D_TEXTURE,
- SOURCE_2D_NORMAL
+ SOURCE_2D_NORMAL,
+ SOURCE_DEPTH
};
enum TextureType {
diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp
index f6a01939da..7d89764d20 100644
--- a/servers/arvr_server.cpp
+++ b/servers/arvr_server.cpp
@@ -87,11 +87,11 @@ real_t ARVRServer::get_world_scale() const {
};
void ARVRServer::set_world_scale(real_t p_world_scale) {
- if (world_scale < 0.01) {
- world_scale = 0.01;
- } else if (world_scale > 1000.0) {
- world_scale = 1000.0;
- };
+ if (p_world_scale < 0.01) {
+ p_world_scale = 0.01;
+ } else if (p_world_scale > 1000.0) {
+ p_world_scale = 1000.0;
+ }
world_scale = p_world_scale;
};
diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp
index d40de669fd..8a52f29729 100644
--- a/servers/physics/shape_sw.cpp
+++ b/servers/physics/shape_sw.cpp
@@ -1524,8 +1524,8 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) {
_aabb.merge_with(bvh_arrayw[i].aabb);
}
- w = PoolVector<Face>::Write();
- vw = PoolVector<Vector3>::Write();
+ w.release();
+ vw.release();
int count = 0;
_VolumeSW_BVH *bvh_tree = _volume_sw_build_bvh(bvh_arrayw, src_face_count, count);
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp
index 0043b948b0..48799a56fb 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -986,7 +986,7 @@ Variant ConcavePolygonShape2DSW::get_data() const {
w[(i << 1) + 1] = points[segments[i].points[1]];
}
- w = PoolVector<Vector2>::Write();
+ w.release();
return rsegments;
}
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 42b9f19d9d..63b5f206f2 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -4684,7 +4684,7 @@ Error ShaderLanguage::compile(const String &p_code, const Map<StringName, Functi
return OK;
}
-Error ShaderLanguage::complete(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types, List<String> *r_options, String &r_call_hint) {
+Error ShaderLanguage::complete(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types, List<ScriptCodeCompletionOption> *r_options, String &r_call_hint) {
clear();
@@ -4705,8 +4705,8 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
} break;
case COMPLETION_RENDER_MODE: {
for (int i = 0; i < p_render_modes.size(); i++) {
-
- r_options->push_back(p_render_modes[i]);
+ ScriptCodeCompletionOption option(p_render_modes[i], ScriptCodeCompletionOption::KIND_ENUM);
+ r_options->push_back(option);
}
return OK;
@@ -4714,8 +4714,8 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
case COMPLETION_MAIN_FUNCTION: {
for (const Map<StringName, FunctionInfo>::Element *E = p_functions.front(); E; E = E->next()) {
-
- r_options->push_back(E->key());
+ ScriptCodeCompletionOption option(E->key(), ScriptCodeCompletionOption::KIND_FUNCTION);
+ r_options->push_back(option);
}
return OK;
@@ -4724,10 +4724,8 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
case COMPLETION_FUNCTION_CALL: {
bool comp_ident = completion_type == COMPLETION_IDENTIFIER;
- Set<String> matches;
-
+ Map<String, ScriptCodeCompletionOption::Kind> matches;
StringName skip_function;
-
BlockNode *block = completion_block;
while (block) {
@@ -4736,7 +4734,7 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
for (const Map<StringName, BlockNode::Variable>::Element *E = block->variables.front(); E; E = E->next()) {
if (E->get().line < completion_line) {
- matches.insert(E->key());
+ matches.insert(E->key(), ScriptCodeCompletionOption::KIND_VARIABLE);
}
}
}
@@ -4744,7 +4742,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);
+ matches.insert(block->parent_function->arguments[i].name, ScriptCodeCompletionOption::KIND_FUNCTION);
}
}
skip_function = block->parent_function->name;
@@ -4755,35 +4753,43 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
if (comp_ident && skip_function != StringName() && p_functions.has(skip_function)) {
for (Map<StringName, BuiltInInfo>::Element *E = p_functions[skip_function].built_ins.front(); E; E = E->next()) {
- matches.insert(E->key());
+ ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER;
+ if (E->get().constant) {
+ kind = ScriptCodeCompletionOption::KIND_CONSTANT;
+ }
+ matches.insert(E->key(), kind);
}
}
if (comp_ident) {
for (const Map<StringName, ShaderNode::Varying>::Element *E = shader->varyings.front(); E; E = E->next()) {
- matches.insert(E->key());
+ matches.insert(E->key(), ScriptCodeCompletionOption::KIND_VARIABLE);
}
for (const Map<StringName, ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) {
- matches.insert(E->key());
+ matches.insert(E->key(), ScriptCodeCompletionOption::KIND_MEMBER);
}
}
for (int i = 0; i < shader->functions.size(); i++) {
if (!shader->functions[i].callable || shader->functions[i].name == skip_function)
continue;
- matches.insert(String(shader->functions[i].name) + "(");
+ matches.insert(String(shader->functions[i].name), ScriptCodeCompletionOption::KIND_FUNCTION);
}
int idx = 0;
while (builtin_func_defs[idx].name) {
- matches.insert(String(builtin_func_defs[idx].name) + "(");
+ matches.insert(String(builtin_func_defs[idx].name), ScriptCodeCompletionOption::KIND_FUNCTION);
idx++;
}
- for (Set<String>::Element *E = matches.front(); E; E = E->next()) {
- r_options->push_back(E->get());
+ for (Map<String, ScriptCodeCompletionOption::Kind>::Element *E = matches.front(); E; E = E->next()) {
+ ScriptCodeCompletionOption option(E->key(), E->value());
+ if (E->value() == ScriptCodeCompletionOption::KIND_FUNCTION) {
+ option.insert_text += "(";
+ }
+ r_options->push_back(option);
}
return OK;
@@ -4923,8 +4929,8 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
}
for (int i = 0; i < limit; i++) {
- r_options->push_back(String::chr(colv[i]));
- r_options->push_back(String::chr(coordv[i]));
+ r_options->push_back(ScriptCodeCompletionOption(String::chr(colv[i]), ScriptCodeCompletionOption::KIND_PLAIN_TEXT));
+ r_options->push_back(ScriptCodeCompletionOption(String::chr(coordv[i]), ScriptCodeCompletionOption::KIND_PLAIN_TEXT));
}
} break;
diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h
index 934dc2c403..65bf78bddd 100644
--- a/servers/visual/shader_language.h
+++ b/servers/visual/shader_language.h
@@ -33,6 +33,7 @@
#include "core/list.h"
#include "core/map.h"
+#include "core/script_language.h"
#include "core/string_name.h"
#include "core/typedefs.h"
#include "core/ustring.h"
@@ -689,7 +690,7 @@ public:
static String get_shader_type(const String &p_code);
Error compile(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types);
- Error complete(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types, List<String> *r_options, String &r_call_hint);
+ Error complete(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types, List<ScriptCodeCompletionOption> *r_options, String &r_call_hint);
String get_error_text();
int get_error_line();
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index faf5a1f8fa..7c100be0f2 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -2396,7 +2396,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
mipmap.resize(size);
PoolVector<uint8_t>::Write w = mipmap.write();
zeromem(w.ptr(), size);
- w = PoolVector<uint8_t>::Write();
+ w.release();
probe->dynamic.mipmaps_3d.push_back(mipmap);