summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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/math/triangle_mesh.cpp4
-rw-r--r--core/pool_vector.h4
-rw-r--r--core/variant.cpp3
-rw-r--r--core/variant_call.cpp4
-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.cpp8
-rw-r--r--editor/editor_node.cpp14
-rw-r--r--editor/editor_profiler.cpp2
-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/tile_set_editor_plugin.cpp8
-rw-r--r--editor/scene_tree_dock.cpp4
-rw-r--r--modules/csg/csg_shape.cpp8
-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/jpg/image_loader_jpegd.cpp4
-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/webp/image_loader_webp.cpp8
-rw-r--r--platform/android/java_godot_lib_jni.cpp8
-rw-r--r--scene/2d/collision_polygon_2d.cpp2
-rw-r--r--scene/2d/tile_map.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/popup.cpp8
-rw-r--r--scene/gui/text_edit.cpp2
-rw-r--r--scene/resources/animation.cpp20
-rw-r--r--scene/resources/dynamic_font_stb.cpp2
-rw-r--r--scene/resources/mesh.cpp8
-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/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
55 files changed, 208 insertions, 148 deletions
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/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..aba66e3909 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 {
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/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..7efe6a987a 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);
@@ -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/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/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/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/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/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/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/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/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/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/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/tile_map.cpp b/scene/2d/tile_map.cpp
index 22bc0e44e6..0a6d630428 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -1275,7 +1275,7 @@ PoolVector<int> TileMap::_get_tile_data() const {
idx += 3;
}
- w = PoolVector<int>::Write();
+ w.release();
return data;
}
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/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/resources/animation.cpp b/scene/resources/animation.cpp
index 1ca643cd7a..89cbf0becd 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;
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/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/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);