diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/physics_body_2d.cpp | 4 | ||||
-rw-r--r-- | scene/3d/collision_object_3d.cpp | 6 | ||||
-rw-r--r-- | scene/3d/collision_polygon_3d.cpp | 6 | ||||
-rw-r--r-- | scene/3d/collision_shape_3d.cpp | 6 | ||||
-rw-r--r-- | scene/3d/light_3d.cpp | 3 | ||||
-rw-r--r-- | scene/3d/lightmapper.h | 16 | ||||
-rw-r--r-- | scene/3d/navigation_region_3d.cpp | 4 | ||||
-rw-r--r-- | scene/3d/physics_body_3d.cpp | 4 | ||||
-rw-r--r-- | scene/gui/tab_container.cpp | 8 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 31 | ||||
-rw-r--r-- | scene/main/multiplayer_peer.cpp | 4 | ||||
-rw-r--r-- | scene/main/node.cpp | 5 | ||||
-rw-r--r-- | scene/main/node.h | 1 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 118 | ||||
-rw-r--r-- | scene/main/viewport.h | 5 | ||||
-rw-r--r-- | scene/resources/audio_stream_wav.cpp | 56 | ||||
-rw-r--r-- | scene/resources/audio_stream_wav.h | 2 | ||||
-rw-r--r-- | scene/resources/bit_map.cpp | 2 | ||||
-rw-r--r-- | scene/resources/surface_tool.cpp | 18 | ||||
-rw-r--r-- | scene/resources/texture.cpp | 3 |
20 files changed, 200 insertions, 102 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index ba361c2656..4c1f6499ab 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -907,9 +907,7 @@ void RigidBody2D::_notification(int p_what) { } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { - if (Engine::get_singleton()->is_editor_hint()) { - update_configuration_warnings(); - } + update_configuration_warnings(); } break; } #endif diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index 19d1b83cab..6d8d60dcaa 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -83,13 +83,9 @@ void CollisionObject3D::_notification(int p_what) { _update_pickable(); } break; -#ifdef TOOLS_ENABLED case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { - if (Engine::get_singleton()->is_editor_hint()) { - update_configuration_warnings(); - } + update_configuration_warnings(); } break; -#endif case NOTIFICATION_TRANSFORM_CHANGED: { if (only_update_transform_changes) { diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp index 53a61c1368..9a2ed00274 100644 --- a/scene/3d/collision_polygon_3d.cpp +++ b/scene/3d/collision_polygon_3d.cpp @@ -104,11 +104,7 @@ void CollisionPolygon3D::_notification(int p_what) { if (parent) { _update_in_shape_owner(true); } -#ifdef TOOLS_ENABLED - if (Engine::get_singleton()->is_editor_hint()) { - update_configuration_warnings(); - } -#endif + update_configuration_warnings(); } break; case NOTIFICATION_UNPARENTED: { diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp index f1d918ad9b..b7f3b12c25 100644 --- a/scene/3d/collision_shape_3d.cpp +++ b/scene/3d/collision_shape_3d.cpp @@ -99,11 +99,7 @@ void CollisionShape3D::_notification(int p_what) { if (parent) { _update_in_shape_owner(true); } -#ifdef TOOLS_ENABLED - if (Engine::get_singleton()->is_editor_hint()) { - update_configuration_warnings(); - } -#endif + update_configuration_warnings(); } break; case NOTIFICATION_UNPARENTED: { diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index 16c82bf6d2..18198b566e 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -284,6 +284,9 @@ void Light3D::_update_visibility() { void Light3D::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_TRANSFORM_CHANGED: { + update_configuration_warnings(); + } break; case NOTIFICATION_VISIBILITY_CHANGED: case NOTIFICATION_ENTER_TREE: { _update_visibility(); diff --git a/scene/3d/lightmapper.h b/scene/3d/lightmapper.h index 018ed9485d..5a390eaede 100644 --- a/scene/3d/lightmapper.h +++ b/scene/3d/lightmapper.h @@ -71,15 +71,15 @@ public: /*! Constructs a ray from origin, direction, and ray segment. Near * has to be smaller than far. */ - _FORCE_INLINE_ Ray(const Vector3 &org, - const Vector3 &dir, - float tnear = 0.0f, - float tfar = INFINITY) : - org(org), - tnear(tnear), - dir(dir), + _FORCE_INLINE_ Ray(const Vector3 &p_org, + const Vector3 &p_dir, + float p_tnear = 0.0f, + float p_tfar = INFINITY) : + org(p_org), + tnear(p_tnear), + dir(p_dir), time(0.0f), - tfar(tfar), + tfar(p_tfar), mask(-1), u(0.0), v(0.0), diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp index 22a6ec3517..f925c5020a 100644 --- a/scene/3d/navigation_region_3d.cpp +++ b/scene/3d/navigation_region_3d.cpp @@ -372,6 +372,10 @@ NavigationRegion3D::NavigationRegion3D() { } NavigationRegion3D::~NavigationRegion3D() { + if (bake_thread.is_started()) { + bake_thread.wait_to_finish(); + } + if (navigation_mesh.is_valid()) { navigation_mesh->disconnect("changed", callable_mp(this, &NavigationRegion3D::_navigation_changed)); } diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 89bb1b5c65..9de9444fb6 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -599,9 +599,7 @@ void RigidBody3D::_notification(int p_what) { } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { - if (Engine::get_singleton()->is_editor_hint()) { - update_configuration_warnings(); - } + update_configuration_warnings(); } break; } #endif diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 208cb29772..c5f7500380 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -547,12 +547,12 @@ void TabContainer::add_child_notify(Node *p_child) { } void TabContainer::move_child_notify(Node *p_child) { + Container::move_child_notify(p_child); + if (p_child == tab_bar) { return; } - Container::move_child_notify(p_child); - Control *c = Object::cast_to<Control>(p_child); if (c && !c->is_set_as_top_level()) { int old_idx = -1; @@ -571,12 +571,12 @@ void TabContainer::move_child_notify(Node *p_child) { } void TabContainer::remove_child_notify(Node *p_child) { + Container::remove_child_notify(p_child); + if (p_child == tab_bar) { return; } - Container::remove_child_notify(p_child); - Control *c = Object::cast_to<Control>(p_child); if (!c || c->is_set_as_top_level()) { return; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 814af12d60..310177dda7 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1847,23 +1847,28 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) { Point2i pos = get_line_column_at_pos(mpos); int row = pos.y; int col = pos.x; - int caret = carets.size() - 1; + bool selection_clicked = false; if (is_move_caret_on_right_click_enabled()) { - if (has_selection(caret)) { - int from_line = get_selection_from_line(caret); - int to_line = get_selection_to_line(caret); - int from_column = get_selection_from_column(caret); - int to_column = get_selection_to_column(caret); - - if (row < from_line || row > to_line || (row == from_line && col < from_column) || (row == to_line && col > to_column)) { - // Right click is outside the selected text. - deselect(caret); + if (has_selection()) { + for (int i = 0; i < get_caret_count(); i++) { + int from_line = get_selection_from_line(i); + int to_line = get_selection_to_line(i); + int from_column = get_selection_from_column(i); + int to_column = get_selection_to_column(i); + + if (row >= from_line && row <= to_line && (row != from_line || col >= from_column) && (row != to_line || col <= to_column)) { + // Right click in one of the selected text + selection_clicked = true; + break; + } } } - if (!has_selection(caret)) { - set_caret_line(row, true, false, 0, caret); - set_caret_column(col, true, caret); + if (!selection_clicked) { + deselect(); + remove_secondary_carets(); + set_caret_line(row, false, false); + set_caret_column(col); } merge_overlapping_carets(); } diff --git a/scene/main/multiplayer_peer.cpp b/scene/main/multiplayer_peer.cpp index f3e56a1455..8c9eeea027 100644 --- a/scene/main/multiplayer_peer.cpp +++ b/scene/main/multiplayer_peer.cpp @@ -201,6 +201,9 @@ void MultiplayerPeerExtension::_bind_methods() { GDVIRTUAL_BIND(_get_packet_script) GDVIRTUAL_BIND(_put_packet_script, "p_buffer"); + GDVIRTUAL_BIND(_get_packet_channel); + GDVIRTUAL_BIND(_get_packet_mode); + GDVIRTUAL_BIND(_set_transfer_channel, "p_channel"); GDVIRTUAL_BIND(_get_transfer_channel); @@ -217,6 +220,7 @@ void MultiplayerPeerExtension::_bind_methods() { GDVIRTUAL_BIND(_get_unique_id); GDVIRTUAL_BIND(_set_refuse_new_connections, "p_enable"); GDVIRTUAL_BIND(_is_refusing_new_connections); + GDVIRTUAL_BIND(_is_server_relay_supported); GDVIRTUAL_BIND(_get_connection_status); ADD_PROPERTY_DEFAULT("transfer_mode", TRANSFER_MODE_RELIABLE); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 52c1df8110..057fd15f1b 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2759,6 +2759,10 @@ bool Node::is_displayed_folded() const { return data.display_folded; } +bool Node::is_ready() const { + return !data.ready_first; +} + void Node::request_ready() { data.ready_first = true; } @@ -2897,6 +2901,7 @@ void Node::_bind_methods() { ClassDB::bind_method(D_METHOD("queue_free"), &Node::queue_free); ClassDB::bind_method(D_METHOD("request_ready"), &Node::request_ready); + ClassDB::bind_method(D_METHOD("is_node_ready"), &Node::is_ready); ClassDB::bind_method(D_METHOD("set_multiplayer_authority", "id", "recursive"), &Node::set_multiplayer_authority, DEFVAL(true)); ClassDB::bind_method(D_METHOD("get_multiplayer_authority"), &Node::get_multiplayer_authority); diff --git a/scene/main/node.h b/scene/main/node.h index 493578bc5b..4a606538a8 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -455,6 +455,7 @@ public: bool can_process_notification(int p_what) const; bool is_enabled() const; + bool is_ready() const; void request_ready(); static void print_orphan_nodes(); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 8cd57536bf..4aaa2e8f5b 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -61,6 +61,10 @@ #include "servers/rendering/rendering_server_globals.h" void ViewportTexture::setup_local_to_scene() { + if (vp_pending) { + return; + } + Node *loc_scene = get_local_scene(); if (!loc_scene) { return; @@ -68,26 +72,14 @@ void ViewportTexture::setup_local_to_scene() { if (vp) { vp->viewport_textures.erase(this); + vp = nullptr; } - vp = nullptr; - - Node *vpn = loc_scene->get_node(path); - ERR_FAIL_COND_MSG(!vpn, "ViewportTexture: Path to node is invalid."); - - vp = Object::cast_to<Viewport>(vpn); - - ERR_FAIL_COND_MSG(!vp, "ViewportTexture: Path to node does not point to a viewport."); - - vp->viewport_textures.insert(this); - - ERR_FAIL_NULL(RenderingServer::get_singleton()); - if (proxy_ph.is_valid()) { - RS::get_singleton()->texture_proxy_update(proxy, vp->texture_rid); - RS::get_singleton()->free(proxy_ph); + if (loc_scene->is_ready()) { + _setup_local_to_scene(loc_scene); } else { - ERR_FAIL_COND(proxy.is_valid()); // Should be invalid. - proxy = RS::get_singleton()->texture_proxy_create(vp->texture_rid); + loc_scene->connect(SNAME("ready"), callable_mp(this, &ViewportTexture::_setup_local_to_scene).bind(loc_scene), CONNECT_ONE_SHOT); + vp_pending = true; } } @@ -98,8 +90,24 @@ void ViewportTexture::set_viewport_path_in_scene(const NodePath &p_path) { path = p_path; - if (get_local_scene()) { + if (vp) { + vp->viewport_textures.erase(this); + vp = nullptr; + } + + if (proxy_ph.is_valid()) { + RS::get_singleton()->free(proxy_ph); + } + if (proxy.is_valid()) { + RS::get_singleton()->free(proxy); + } + proxy_ph = RID(); + proxy = RID(); + + if (get_local_scene() && !path.is_empty()) { setup_local_to_scene(); + } else { + emit_changed(); } } @@ -108,17 +116,32 @@ NodePath ViewportTexture::get_viewport_path_in_scene() const { } int ViewportTexture::get_width() const { - ERR_FAIL_COND_V_MSG(!vp, 0, "Viewport Texture must be set to use it."); + if (!vp) { + if (!vp_pending) { + ERR_PRINT("Viewport Texture must be set to use it."); + } + return 0; + } return vp->size.width; } int ViewportTexture::get_height() const { - ERR_FAIL_COND_V_MSG(!vp, 0, "Viewport Texture must be set to use it."); + if (!vp) { + if (!vp_pending) { + ERR_PRINT("Viewport Texture must be set to use it."); + } + return 0; + } return vp->size.height; } Size2 ViewportTexture::get_size() const { - ERR_FAIL_COND_V_MSG(!vp, Size2(), "Viewport Texture must be set to use it."); + if (!vp) { + if (!vp_pending) { + ERR_PRINT("Viewport Texture must be set to use it."); + } + return Size2(); + } return vp->size; } @@ -135,10 +158,38 @@ bool ViewportTexture::has_alpha() const { } Ref<Image> ViewportTexture::get_image() const { - ERR_FAIL_COND_V_MSG(!vp, Ref<Image>(), "Viewport Texture must be set to use it."); + if (!vp) { + if (!vp_pending) { + ERR_PRINT("Viewport Texture must be set to use it."); + } + return Ref<Image>(); + } return RS::get_singleton()->texture_2d_get(vp->texture_rid); } +void ViewportTexture::_setup_local_to_scene(const Node *p_loc_scene) { + Node *vpn = p_loc_scene->get_node(path); + ERR_FAIL_COND_MSG(!vpn, "ViewportTexture: Path to node is invalid."); + + vp = Object::cast_to<Viewport>(vpn); + + ERR_FAIL_COND_MSG(!vp, "ViewportTexture: Path to node does not point to a viewport."); + + vp->viewport_textures.insert(this); + + ERR_FAIL_NULL(RenderingServer::get_singleton()); + if (proxy_ph.is_valid()) { + RS::get_singleton()->texture_proxy_update(proxy, vp->texture_rid); + RS::get_singleton()->free(proxy_ph); + } else { + ERR_FAIL_COND(proxy.is_valid()); // Should be invalid. + proxy = RS::get_singleton()->texture_proxy_create(vp->texture_rid); + } + vp_pending = false; + + emit_changed(); +} + void ViewportTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_viewport_path_in_scene", "path"), &ViewportTexture::set_viewport_path_in_scene); ClassDB::bind_method(D_METHOD("get_viewport_path_in_scene"), &ViewportTexture::get_viewport_path_in_scene); @@ -374,9 +425,28 @@ int Viewport::_sub_window_find(Window *p_window) { return -1; } +void Viewport::_update_viewport_path() { + if (viewport_textures.is_empty()) { + return; + } + + Node *scene_root = get_scene_file_path().is_empty() ? get_owner() : this; + if (!scene_root && is_inside_tree()) { + scene_root = get_tree()->get_edited_scene_root(); + } + if (scene_root && (scene_root == this || scene_root->is_ancestor_of(this))) { + NodePath path_in_scene = scene_root->get_path_to(this); + for (ViewportTexture *E : viewport_textures) { + E->path = path_in_scene; + } + } +} + void Viewport::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { + _update_viewport_path(); + if (get_parent()) { parent = get_parent()->get_viewport(); RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, parent->get_viewport_rid()); @@ -469,6 +539,10 @@ void Viewport::_notification(int p_what) { RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, RID()); } break; + case NOTIFICATION_PATH_RENAMED: { + _update_viewport_path(); + } break; + case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { if (!get_tree()) { return; diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 5213c0db01..de0abec052 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -59,6 +59,9 @@ class ViewportTexture : public Texture2D { friend class Viewport; Viewport *vp = nullptr; + bool vp_pending = false; + + void _setup_local_to_scene(const Node *p_loc_scene); mutable RID proxy_ph; mutable RID proxy; @@ -314,6 +317,8 @@ private: Ref<ViewportTexture> default_texture; HashSet<ViewportTexture *> viewport_textures; + void _update_viewport_path(); + SDFOversize sdf_oversize = SDF_OVERSIZE_120_PERCENT; SDFScale sdf_scale = SDF_SCALE_50_PERCENT; diff --git a/scene/resources/audio_stream_wav.cpp b/scene/resources/audio_stream_wav.cpp index f331e3a22c..669b455f89 100644 --- a/scene/resources/audio_stream_wav.cpp +++ b/scene/resources/audio_stream_wav.cpp @@ -87,21 +87,21 @@ void AudioStreamPlaybackWAV::seek(double p_time) { } template <class Depth, bool is_stereo, bool is_ima_adpcm> -void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &offset, int32_t &increment, uint32_t amount, IMA_ADPCM_State *ima_adpcm) { +void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &p_offset, int32_t &p_increment, uint32_t p_amount, IMA_ADPCM_State *p_ima_adpcm) { // this function will be compiled branchless by any decent compiler int32_t final, final_r, next, next_r; - while (amount) { - amount--; - int64_t pos = offset >> MIX_FRAC_BITS; + while (p_amount) { + p_amount--; + int64_t pos = p_offset >> MIX_FRAC_BITS; if (is_stereo && !is_ima_adpcm) { pos <<= 1; } if (is_ima_adpcm) { - int64_t sample_pos = pos + ima_adpcm[0].window_ofs; + int64_t sample_pos = pos + p_ima_adpcm[0].window_ofs; - while (sample_pos > ima_adpcm[0].last_nibble) { + while (sample_pos > p_ima_adpcm[0].last_nibble) { static const int16_t _ima_adpcm_step_table[89] = { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, @@ -122,20 +122,20 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, for (int i = 0; i < (is_stereo ? 2 : 1); i++) { int16_t nibble, diff, step; - ima_adpcm[i].last_nibble++; + p_ima_adpcm[i].last_nibble++; const uint8_t *src_ptr = (const uint8_t *)base->data; src_ptr += AudioStreamWAV::DATA_PAD; - uint8_t nbb = src_ptr[(ima_adpcm[i].last_nibble >> 1) * (is_stereo ? 2 : 1) + i]; - nibble = (ima_adpcm[i].last_nibble & 1) ? (nbb >> 4) : (nbb & 0xF); - step = _ima_adpcm_step_table[ima_adpcm[i].step_index]; + uint8_t nbb = src_ptr[(p_ima_adpcm[i].last_nibble >> 1) * (is_stereo ? 2 : 1) + i]; + nibble = (p_ima_adpcm[i].last_nibble & 1) ? (nbb >> 4) : (nbb & 0xF); + step = _ima_adpcm_step_table[p_ima_adpcm[i].step_index]; - ima_adpcm[i].step_index += _ima_adpcm_index_table[nibble]; - if (ima_adpcm[i].step_index < 0) { - ima_adpcm[i].step_index = 0; + p_ima_adpcm[i].step_index += _ima_adpcm_index_table[nibble]; + if (p_ima_adpcm[i].step_index < 0) { + p_ima_adpcm[i].step_index = 0; } - if (ima_adpcm[i].step_index > 88) { - ima_adpcm[i].step_index = 88; + if (p_ima_adpcm[i].step_index > 88) { + p_ima_adpcm[i].step_index = 88; } diff = step >> 3; @@ -152,26 +152,26 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, diff = -diff; } - ima_adpcm[i].predictor += diff; - if (ima_adpcm[i].predictor < -0x8000) { - ima_adpcm[i].predictor = -0x8000; - } else if (ima_adpcm[i].predictor > 0x7FFF) { - ima_adpcm[i].predictor = 0x7FFF; + p_ima_adpcm[i].predictor += diff; + if (p_ima_adpcm[i].predictor < -0x8000) { + p_ima_adpcm[i].predictor = -0x8000; + } else if (p_ima_adpcm[i].predictor > 0x7FFF) { + p_ima_adpcm[i].predictor = 0x7FFF; } /* store loop if there */ - if (ima_adpcm[i].last_nibble == ima_adpcm[i].loop_pos) { - ima_adpcm[i].loop_step_index = ima_adpcm[i].step_index; - ima_adpcm[i].loop_predictor = ima_adpcm[i].predictor; + if (p_ima_adpcm[i].last_nibble == p_ima_adpcm[i].loop_pos) { + p_ima_adpcm[i].loop_step_index = p_ima_adpcm[i].step_index; + p_ima_adpcm[i].loop_predictor = p_ima_adpcm[i].predictor; } - //printf("%i - %i - pred %i\n",int(ima_adpcm[i].last_nibble),int(nibble),int(ima_adpcm[i].predictor)); + //printf("%i - %i - pred %i\n",int(p_ima_adpcm[i].last_nibble),int(nibble),int(p_ima_adpcm[i].predictor)); } } - final = ima_adpcm[0].predictor; + final = p_ima_adpcm[0].predictor; if (is_stereo) { - final_r = ima_adpcm[1].predictor; + final_r = p_ima_adpcm[1].predictor; } } else { @@ -201,7 +201,7 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, } } - int32_t frac = int64_t(offset & MIX_FRAC_MASK); + int32_t frac = int64_t(p_offset & MIX_FRAC_MASK); final = final + ((next - final) * frac >> MIX_FRAC_BITS); if (is_stereo) { @@ -217,7 +217,7 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, p_dst->r = final_r / 32767.0; p_dst++; - offset += increment; + p_offset += p_increment; } } diff --git a/scene/resources/audio_stream_wav.h b/scene/resources/audio_stream_wav.h index bea273720c..f150a17d21 100644 --- a/scene/resources/audio_stream_wav.h +++ b/scene/resources/audio_stream_wav.h @@ -61,7 +61,7 @@ class AudioStreamPlaybackWAV : public AudioStreamPlayback { Ref<AudioStreamWAV> base; template <class Depth, bool is_stereo, bool is_ima_adpcm> - void do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &offset, int32_t &increment, uint32_t amount, IMA_ADPCM_State *ima_adpcm); + void do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &p_offset, int32_t &p_increment, uint32_t p_amount, IMA_ADPCM_State *p_ima_adpcm); public: virtual void start(double p_from_pos = 0.0) override; diff --git a/scene/resources/bit_map.cpp b/scene/resources/bit_map.cpp index 204adbcda0..dd20dc1c66 100644 --- a/scene/resources/bit_map.cpp +++ b/scene/resources/bit_map.cpp @@ -354,7 +354,7 @@ Vector<Vector<Vector2>> BitMap::_march_square(const Rect2i &p_rect, const Point2 prevx = stepx; prevy = stepy; - ERR_FAIL_COND_V((int)count > width * height, Vector<Vector<Vector2>>()); + ERR_FAIL_COND_V((int)count > 2 * (width * height + 1), Vector<Vector<Vector2>>()); } while (curx != startx || cury != starty); // Add remaining points to result. diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index ccb3ddee45..5ef3e09e3d 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -985,9 +985,21 @@ void SurfaceTool::create_from_blend_shape(const Ref<Mesh> &p_existing, int p_sur } ERR_FAIL_COND(shape_idx == -1); ERR_FAIL_COND(shape_idx >= arr.size()); - Array mesh = arr[shape_idx]; - ERR_FAIL_COND(mesh.size() != RS::ARRAY_MAX); - _create_list_from_arrays(arr[shape_idx], &vertex_array, &index_array, format); + Array blendshape_mesh_arrays = arr[shape_idx]; + ERR_FAIL_COND(blendshape_mesh_arrays.size() != RS::ARRAY_MAX); + + Array source_mesh_arrays = p_existing->surface_get_arrays(p_surface); + ERR_FAIL_COND(source_mesh_arrays.size() != RS::ARRAY_MAX); + + // Copy BlendShape vertex data over while keeping e.g. bones, weights, index from existing mesh intact. + source_mesh_arrays[RS::ARRAY_VERTEX] = blendshape_mesh_arrays[RS::ARRAY_VERTEX]; + source_mesh_arrays[RS::ARRAY_NORMAL] = blendshape_mesh_arrays[RS::ARRAY_NORMAL]; + source_mesh_arrays[RS::ARRAY_TANGENT] = blendshape_mesh_arrays[RS::ARRAY_TANGENT]; + + _create_list_from_arrays(source_mesh_arrays, &vertex_array, &index_array, format); + + material = p_existing->surface_get_material(p_surface); + format = p_existing->surface_get_format(p_surface); for (int j = 0; j < RS::ARRAY_CUSTOM_COUNT; j++) { if (format & custom_mask[j]) { diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 282c531555..7de10149db 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -168,7 +168,8 @@ void ImageTexture::_get_property_list(List<PropertyInfo> *p_list) const { } Ref<ImageTexture> ImageTexture::create_from_image(const Ref<Image> &p_image) { - ERR_FAIL_COND_V_MSG(p_image.is_null() || p_image->is_empty(), Ref<ImageTexture>(), "Invalid image"); + ERR_FAIL_COND_V_MSG(p_image.is_null(), Ref<ImageTexture>(), "Invalid image: null"); + ERR_FAIL_COND_V_MSG(p_image->is_empty(), Ref<ImageTexture>(), "Invalid image: image is empty"); Ref<ImageTexture> image_texture; image_texture.instantiate(); |