diff options
-rw-r--r-- | core/array.cpp | 11 | ||||
-rw-r--r-- | core/array.h | 2 | ||||
-rw-r--r-- | core/variant_call.cpp | 2 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 2 | ||||
-rw-r--r-- | drivers/gles3/shaders/subsurf_scattering.glsl | 113 | ||||
-rw-r--r-- | editor/project_settings_editor.cpp | 8 | ||||
-rw-r--r-- | modules/stb_vorbis/audio_stream_ogg_vorbis.cpp | 6 | ||||
-rw-r--r-- | scene/2d/audio_stream_player_2d.cpp | 8 | ||||
-rw-r--r-- | scene/3d/audio_stream_player_3d.cpp | 8 | ||||
-rw-r--r-- | scene/3d/gi_probe.cpp | 31 | ||||
-rw-r--r-- | scene/audio/audio_player.cpp | 2 |
11 files changed, 112 insertions, 81 deletions
diff --git a/core/array.cpp b/core/array.cpp index c35bf5bf0c..2e3fbf858d 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -210,6 +210,17 @@ const Variant &Array::get(int p_idx) const { return operator[](p_idx); } +Array Array::duplicate() const { + + Array new_arr; + int element_count = size(); + new_arr.resize(element_count); + for (int i = 0; i < element_count; i++) { + new_arr[i] = get(i); + } + + return new_arr; +} struct _ArrayVariantSort { _FORCE_INLINE_ bool operator()(const Variant &p_l, const Variant &p_r) const { diff --git a/core/array.h b/core/array.h index 777116ab56..8a647dd13b 100644 --- a/core/array.h +++ b/core/array.h @@ -84,6 +84,8 @@ public: Variant pop_back(); Variant pop_front(); + Array duplicate() const; + Array(const Array &p_from); Array(); ~Array(); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index ad15f8f5cb..dc1c24d234 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -481,6 +481,7 @@ struct _VariantCall { VCALL_LOCALMEM1(Array, erase); VCALL_LOCALMEM0(Array, sort); VCALL_LOCALMEM2(Array, sort_custom); + VCALL_LOCALMEM0R(Array, duplicate); VCALL_LOCALMEM0(Array, invert); static void _call_PoolByteArray_get_string_from_ascii(Variant &r_ret, Variant &p_self, const Variant **p_args) { @@ -1575,6 +1576,7 @@ void register_variant_methods() { ADDFUNC0(ARRAY, NIL, Array, sort, varray()); ADDFUNC2(ARRAY, NIL, Array, sort_custom, OBJECT, "obj", STRING, "func", varray()); ADDFUNC0(ARRAY, NIL, Array, invert, varray()); + ADDFUNC0(ARRAY, ARRAY, Array, duplicate, varray()); ADDFUNC0(POOL_BYTE_ARRAY, INT, PoolByteArray, size, varray()); ADDFUNC2(POOL_BYTE_ARRAY, NIL, PoolByteArray, set, INT, "idx", INT, "byte", varray()); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 2615f9c1b3..b695b7e704 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -3739,6 +3739,8 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p SWAP(exposure_shrink[exposure_shrink.size() - 1].color, storage->frame.current_rt->exposure.color); glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height); + + VisualServerRaster::redraw_request(); //if using auto exposure, redraw must happen } int max_glow_level = -1; diff --git a/drivers/gles3/shaders/subsurf_scattering.glsl b/drivers/gles3/shaders/subsurf_scattering.glsl index 8873443727..ad39c61990 100644 --- a/drivers/gles3/shaders/subsurf_scattering.glsl +++ b/drivers/gles3/shaders/subsurf_scattering.glsl @@ -17,36 +17,36 @@ void main() { //#define QUALIFIER uniform // some guy on the interweb says it may be faster with this #define QUALIFIER const + #ifdef USE_25_SAMPLES const int kernel_size=25; - QUALIFIER vec2 kernel[25] = vec2[] ( -vec2(0.099654,0.0), -vec2(0.001133,-3.0), -vec2(0.002316,-2.52083), -vec2(0.00445,-2.08333), -vec2(0.008033,-1.6875), -vec2(0.013627,-1.33333), -vec2(0.021724,-1.02083), -vec2(0.032542,-0.75), -vec2(0.04581,-0.520833), -vec2(0.0606,-0.333333), -vec2(0.075333,-0.1875), -vec2(0.088001,-0.0833333), -vec2(0.096603,-0.0208333), -vec2(0.096603,0.0208333), -vec2(0.088001,0.0833333), -vec2(0.075333,0.1875), -vec2(0.0606,0.333333), -vec2(0.04581,0.520833), -vec2(0.032542,0.75), -vec2(0.021724,1.02083), -vec2(0.013627,1.33333), -vec2(0.008033,1.6875), -vec2(0.00445,2.08333), -vec2(0.002316,2.52), -vec2(0.001133,3.0) + vec2(0.530605, 0.0), + vec2(0.000973794, -3.0), + vec2(0.00333804, -2.52083), + vec2(0.00500364, -2.08333), + vec2(0.00700976, -1.6875), + vec2(0.0094389, -1.33333), + vec2(0.0128496, -1.02083), + vec2(0.017924, -0.75), + vec2(0.0263642, -0.520833), + vec2(0.0410172, -0.333333), + vec2(0.0493588, -0.1875), + vec2(0.0402784, -0.0833333), + vec2(0.0211412, -0.0208333), + vec2(0.0211412, 0.0208333), + vec2(0.0402784, 0.0833333), + vec2(0.0493588, 0.1875), + vec2(0.0410172, 0.333333), + vec2(0.0263642, 0.520833), + vec2(0.017924, 0.75), + vec2(0.0128496, 1.02083), + vec2(0.0094389, 1.33333), + vec2(0.00700976, 1.6875), + vec2(0.00500364, 2.08333), + vec2(0.00333804, 2.52083), + vec2(0.000973794, 3.0) ); #endif //USE_25_SAMPLES @@ -56,23 +56,23 @@ vec2(0.001133,3.0) const int kernel_size=17; QUALIFIER vec2 kernel[17] = vec2[]( -vec2(0.197417,0.0), -vec2(0.000078,-2.0), -vec2(0.000489,-1.53125), -vec2(0.002403,-1.125), -vec2(0.009245,-0.78125), -vec2(0.027835,-0.5), -vec2(0.065592,-0.28125), -vec2(0.12098,-0.125), -vec2(0.17467,-0.03125), -vec2(0.17467,0.03125), -vec2(0.12098,0.125), -vec2(0.065592,0.28125), -vec2(0.027835,0.5), -vec2(0.009245,0.78125), -vec2(0.002403,1.125), -vec2(0.000489,1.53125), -vec2(0.000078,2.0) + vec2(0.536343, 0.0), + vec2(0.00317394, -2.0), + vec2(0.0100386, -1.53125), + vec2(0.0144609, -1.125), + vec2(0.0216301, -0.78125), + vec2(0.0347317, -0.5), + vec2(0.0571056, -0.28125), + vec2(0.0582416, -0.125), + vec2(0.0324462, -0.03125), + vec2(0.0324462, 0.03125), + vec2(0.0582416, 0.125), + vec2(0.0571056, 0.28125), + vec2(0.0347317, 0.5), + vec2(0.0216301, 0.78125), + vec2(0.0144609, 1.125), + vec2(0.0100386, 1.53125), + vec2(0.00317394,2.0) ); #endif //USE_17_SAMPLES @@ -82,23 +82,24 @@ vec2(0.000078,2.0) const int kernel_size=11; -QUALIFIER vec2 kernel[kernel_size] = vec2[]( -vec2(0.198596,0.0), -vec2(0.0093,-2.0), -vec2(0.028002,-1.28), -vec2(0.065984,-0.72), -vec2(0.121703,-0.32), -vec2(0.175713,-0.08), -vec2(0.175713,0.08), -vec2(0.121703,0.32), -vec2(0.065984,0.72), -vec2(0.028002,1.28), -vec2(0.0093,2.0) +QUALIFIER vec4 kernel[11] = vec4[]( + vec4(0.560479, 0.0), + vec4(0.00471691, -2.0), + vec4(0.0192831, -1.28), + vec4(0.03639, -0.72), + vec4(0.0821904, -0.32), + vec4(0.0771802, -0.08), + vec4(0.0771802, 0.08), + vec4(0.0821904, 0.32), + vec4(0.03639, 0.72), + vec4(0.0192831, 1.28), + vec4(0.00471691,2.0) ); #endif //USE_11_SAMPLES + uniform float max_radius; uniform float camera_z_far; uniform float camera_z_near; @@ -155,7 +156,7 @@ void main() { float depth_cmp = texture(source_depth, offset).r *2.0 - 1.0; depth_cmp = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - depth_cmp * (camera_z_far - camera_z_near)); - float s = clamp(300.0f * distance * + float s = clamp(300.0f * scale * max_radius * abs(depth - depth_cmp),0.0,1.0); color = mix(color, base_color.rgb, s); #endif diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 49687a504f..1f65589643 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -182,8 +182,8 @@ void ProjectSettingsEditor::_device_input_add() { Ref<InputEvent> ie; String name = add_at; int idx = edit_idx; - Variant old_val = ProjectSettings::get_singleton()->get(name); - Array arr = old_val; + Array old_val = ProjectSettings::get_singleton()->get(name); + Array arr = old_val.duplicate(); switch (add_type) { @@ -285,8 +285,8 @@ void ProjectSettingsEditor::_press_a_key_confirm() { String name = add_at; int idx = edit_idx; - Variant old_val = ProjectSettings::get_singleton()->get(name); - Array arr = old_val; + Array old_val = ProjectSettings::get_singleton()->get(name); + Array arr = old_val.duplicate(); for (int i = 0; i < arr.size(); i++) { diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index df427907f8..9457fbfaf6 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -45,6 +45,12 @@ void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fra while (todo && active) { int mixed = stb_vorbis_get_samples_float_interleaved(ogg_stream, 2, (float *)p_buffer, todo * 2); + if (vorbis_stream->channels == 1 && mixed > 0) { + //mix mono to stereo + for (int i = 0; i < mixed; i++) { + p_buffer[i].r = p_buffer[i].l; + } + } todo -= mixed; frames_mixed += mixed; diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 39d3f2d6bf..ea2e77fc47 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -217,13 +217,15 @@ void AudioStreamPlayer2D::_notification(int p_what) { setseek = setplay; active = true; setplay = -1; - _change_notify("playing"); //update property in editor + //do not update, this makes it easier to animate (will shut off otherise) + //_change_notify("playing"); //update property in editor } //stop playing if no longer active if (!active) { set_fixed_process_internal(false); - _change_notify("playing"); //update property in editor + //do not update, this makes it easier to animate (will shut off otherise) + //_change_notify("playing"); //update property in editor emit_signal("finished"); } } @@ -439,7 +441,7 @@ void AudioStreamPlayer2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE, "-80,24"), "set_volume_db", "get_volume_db"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_RANGE, "1,65536,1"), "set_max_distance", "get_max_distance"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "attenuation", PROPERTY_HINT_EXP_EASING), "set_attenuation", "get_attenuation"); diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index a69bec2fc8..2073ebf94e 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -530,13 +530,15 @@ void AudioStreamPlayer3D::_notification(int p_what) { setseek = setplay; active = true; setplay = -1; - _change_notify("playing"); //update property in editor + //do not update, this makes it easier to animate (will shut off otherise) + ///_change_notify("playing"); //update property in editor } //stop playing if no longer active if (!active) { set_fixed_process_internal(false); - _change_notify("playing"); //update property in editor + //do not update, this makes it easier to animate (will shut off otherise) + //_change_notify("playing"); //update property in editor emit_signal("finished"); } } @@ -877,7 +879,7 @@ void AudioStreamPlayer3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_db", PROPERTY_HINT_RANGE, "-80,80"), "set_unit_db", "get_unit_db"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_size", PROPERTY_HINT_RANGE, "0.1,100,0.1"), "set_unit_size", "get_unit_size"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_db", PROPERTY_HINT_RANGE, "-24,6"), "set_max_db", "get_max_db"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_RANGE, "0,65536,1"), "set_max_distance", "get_max_distance"); ADD_PROPERTY(PropertyInfo(Variant::INT, "out_of_range_mode", PROPERTY_HINT_ENUM, "Mix,Pause"), "set_out_of_range_mode", "get_out_of_range_mode"); diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index bb54a43028..7792a86b4a 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -1092,7 +1092,7 @@ void GIProbe::_plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, Baker *p_b void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) { MeshInstance *mi = Object::cast_to<MeshInstance>(p_at_node); - if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT)) { + if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT) && mi->is_visible_in_tree()) { Ref<Mesh> mesh = mi->get_mesh(); if (mesh.is_valid()) { @@ -1115,23 +1115,26 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) { if (Spatial *s = Object::cast_to<Spatial>(p_at_node)) { - Array meshes = p_at_node->call("get_meshes"); - for (int i = 0; i < meshes.size(); i += 2) { + if (s->is_visible_in_tree()) { - Transform mxf = meshes[i]; - Ref<Mesh> mesh = meshes[i + 1]; - if (!mesh.is_valid()) - continue; + Array meshes = p_at_node->call("get_meshes"); + for (int i = 0; i < meshes.size(); i += 2) { - Rect3 aabb = mesh->get_aabb(); + Transform mxf = meshes[i]; + Ref<Mesh> mesh = meshes[i + 1]; + if (!mesh.is_valid()) + continue; - Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf); + Rect3 aabb = mesh->get_aabb(); - if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) { - Baker::PlotMesh pm; - pm.local_xform = xf; - pm.mesh = mesh; - p_baker->mesh_list.push_back(pm); + Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf); + + if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) { + Baker::PlotMesh pm; + pm.local_xform = xf; + pm.mesh = mesh; + p_baker->mesh_list.push_back(pm); + } } } } diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp index 8bd924e7ce..341ae45ce8 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -304,7 +304,7 @@ void AudioStreamPlayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE, "-80,24"), "set_volume_db", "get_volume_db"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_target", PROPERTY_HINT_ENUM, "Stereo,Surround,Center"), "set_mix_target", "get_mix_target"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); |