diff options
-rw-r--r-- | editor/import/resource_importer_wav.cpp | 64 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.cpp | 21 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.h | 3 | ||||
-rw-r--r-- | editor/project_manager.cpp | 1 | ||||
-rw-r--r-- | modules/gltf/gltf_document.cpp | 4 | ||||
-rw-r--r-- | modules/webrtc/webrtc_peer_connection_js.cpp | 2 | ||||
-rw-r--r-- | modules/webrtc/webrtc_peer_connection_js.h | 2 |
7 files changed, 61 insertions, 36 deletions
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index 362940dc17..f0ba1eb7a1 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -162,7 +162,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s //Consider revision for engine version 3.0 compression_code = file->get_16(); if (compression_code != 1 && compression_code != 3) { - ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead."); + ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM or IEEE float instead."); } format_channels = file->get_16(); @@ -180,6 +180,10 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Invalid amount of bits in the sample (should be one of 8, 16, 24 or 32)."); } + if (compression_code == 3 && format_bits % 32) { + ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Invalid amount of bits in the IEEE float sample (should be 32 or 64)."); + } + /* Don't need anything else, continue */ format_found = true; } @@ -208,36 +212,46 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s data.resize(frames * format_channels); - if (format_bits == 8) { - for (int i = 0; i < frames * format_channels; i++) { - // 8 bit samples are UNSIGNED + if (compression_code == 1) { + if (format_bits == 8) { + for (int i = 0; i < frames * format_channels; i++) { + // 8 bit samples are UNSIGNED - data.write[i] = int8_t(file->get_8() - 128) / 128.f; - } - } else if (format_bits == 32 && compression_code == 3) { - for (int i = 0; i < frames * format_channels; i++) { - //32 bit IEEE Float + data.write[i] = int8_t(file->get_8() - 128) / 128.f; + } + } else if (format_bits == 16) { + for (int i = 0; i < frames * format_channels; i++) { + //16 bit SIGNED - data.write[i] = file->get_float(); - } - } else if (format_bits == 16) { - for (int i = 0; i < frames * format_channels; i++) { - //16 bit SIGNED + data.write[i] = int16_t(file->get_16()) / 32768.f; + } + } else { + for (int i = 0; i < frames * format_channels; i++) { + //16+ bits samples are SIGNED + // if sample is > 16 bits, just read extra bytes + + uint32_t s = 0; + for (int b = 0; b < (format_bits >> 3); b++) { + s |= ((uint32_t)file->get_8()) << (b * 8); + } + s <<= (32 - format_bits); - data.write[i] = int16_t(file->get_16()) / 32768.f; + data.write[i] = (int32_t(s) >> 16) / 32768.f; + } } - } else { - for (int i = 0; i < frames * format_channels; i++) { - //16+ bits samples are SIGNED - // if sample is > 16 bits, just read extra bytes - - uint32_t s = 0; - for (int b = 0; b < (format_bits >> 3); b++) { - s |= ((uint32_t)file->get_8()) << (b * 8); + } else if (compression_code == 3) { + if (format_bits == 32) { + for (int i = 0; i < frames * format_channels; i++) { + //32 bit IEEE Float + + data.write[i] = file->get_float(); } - s <<= (32 - format_bits); + } else if (format_bits == 64) { + for (int i = 0; i < frames * format_channels; i++) { + //64 bit IEEE Float - data.write[i] = (int32_t(s) >> 16) / 32768.f; + data.write[i] = file->get_double(); + } } } diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index e9547e02e8..57c7f34018 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -624,6 +624,10 @@ void EditorAssetLibrary::_notification(int p_what) { } break; + case NOTIFICATION_RESIZED: { + _update_asset_items_columns(); + } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { _update_repository_options(); setup_http_request(request); @@ -1213,7 +1217,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const library_vb->add_child(asset_top_page); asset_items = memnew(GridContainer); - asset_items->set_columns(2); + _update_asset_items_columns(); asset_items->add_theme_constant_override("h_separation", 10 * EDSCALE); asset_items->add_theme_constant_override("v_separation", 10 * EDSCALE); @@ -1379,12 +1383,17 @@ void EditorAssetLibrary::_install_external_asset(String p_zip_path, String p_tit emit_signal(SNAME("install_asset"), p_zip_path, p_title); } -void EditorAssetLibrary::disable_community_support() { - support->get_popup()->set_item_checked(SUPPORT_COMMUNITY, false); +void EditorAssetLibrary::_update_asset_items_columns() { + int new_columns = get_size().x / (450.0 * EDSCALE); + new_columns = MAX(1, new_columns); + + if (new_columns != asset_items->get_columns()) { + asset_items->set_columns(new_columns); + } } -void EditorAssetLibrary::set_columns(const int p_columns) { - asset_items->set_columns(p_columns); +void EditorAssetLibrary::disable_community_support() { + support->get_popup()->set_item_checked(SUPPORT_COMMUNITY, false); } void EditorAssetLibrary::_bind_methods() { @@ -1542,7 +1551,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { library_vb->add_child(asset_top_page); asset_items = memnew(GridContainer); - asset_items->set_columns(2); + _update_asset_items_columns(); asset_items->add_theme_constant_override("h_separation", 10 * EDSCALE); asset_items->add_theme_constant_override("v_separation", 10 * EDSCALE); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index 2b43719cdd..e02662b8db 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -301,6 +301,8 @@ class EditorAssetLibrary : public PanelContainer { void _install_external_asset(String p_zip_path, String p_title); + void _update_asset_items_columns(); + friend class EditorAssetLibraryItemDescription; friend class EditorAssetLibraryItem; @@ -311,7 +313,6 @@ protected: public: void disable_community_support(); - void set_columns(int p_columns); EditorAssetLibrary(bool p_templates_only = false); }; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index ef91128146..49a3cbe185 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1895,7 +1895,6 @@ void ProjectManager::_notification(int p_what) { } if (asset_library) { real_t size = get_size().x / EDSCALE; - asset_library->set_columns(size < 1000 ? 1 : 2); // Adjust names of tabs to fit the new size. if (size < 650) { local_projects_hb->set_name(TTR("Local")); diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 2017355717..36d985eff3 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -3080,9 +3080,9 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> state, const String &p_base_pat // We'll assume that we use either URI or bufferView, so let's warn the user // if their image somehow uses both. And fail if it has neither. - ERR_CONTINUE_MSG(!d.has("uri") && !d.has("bufferView"), "Invalid image definition in glTF file, it should specific an 'uri' or 'bufferView'."); + ERR_CONTINUE_MSG(!d.has("uri") && !d.has("bufferView"), "Invalid image definition in glTF file, it should specify an 'uri' or 'bufferView'."); if (d.has("uri") && d.has("bufferView")) { - WARN_PRINT("Invalid image definition in glTF file using both 'uri' and 'bufferView'. 'bufferView' will take precedence."); + WARN_PRINT("Invalid image definition in glTF file using both 'uri' and 'bufferView'. 'uri' will take precedence."); } String mimetype; diff --git a/modules/webrtc/webrtc_peer_connection_js.cpp b/modules/webrtc/webrtc_peer_connection_js.cpp index 90e19fe4f1..ee3a302fa2 100644 --- a/modules/webrtc/webrtc_peer_connection_js.cpp +++ b/modules/webrtc/webrtc_peer_connection_js.cpp @@ -57,7 +57,7 @@ void WebRTCPeerConnectionJS::_on_error(void *p_obj) { void WebRTCPeerConnectionJS::_on_data_channel(void *p_obj, int p_id) { WebRTCPeerConnectionJS *peer = static_cast<WebRTCPeerConnectionJS *>(p_obj); - peer->emit_signal(SNAME("data_channel_received"), Ref<WebRTCDataChannelJS>(new WebRTCDataChannelJS(p_id))); + peer->emit_signal(SNAME("data_channel_received"), Ref<WebRTCDataChannel>(memnew(WebRTCDataChannelJS(p_id)))); } void WebRTCPeerConnectionJS::close() { diff --git a/modules/webrtc/webrtc_peer_connection_js.h b/modules/webrtc/webrtc_peer_connection_js.h index 8fa5ea7779..76b8c7fff8 100644 --- a/modules/webrtc/webrtc_peer_connection_js.h +++ b/modules/webrtc/webrtc_peer_connection_js.h @@ -52,6 +52,8 @@ extern int godot_js_rtc_pc_datachannel_create(int p_id, const char *p_label, con } class WebRTCPeerConnectionJS : public WebRTCPeerConnection { + GDCLASS(WebRTCPeerConnectionJS, WebRTCPeerConnection); + private: int _js_id; ConnectionState _conn_state; |