Skip to content

Commit

Permalink
Merge pull request godotengine#46992 from akien-mga/3.2-cherrypicks
Browse files Browse the repository at this point in the history
Cherry-picks for the 3.2 branch (future 3.2.4) - 29th batch
  • Loading branch information
akien-mga authored Mar 14, 2021
2 parents 1d0929a + 5f4ac65 commit 6a9e7c5
Show file tree
Hide file tree
Showing 53 changed files with 552 additions and 173 deletions.
11 changes: 7 additions & 4 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,16 @@ for path in module_search_paths:
# Built-in modules don't have nested modules,
# so save the time it takes to parse directories.
modules = methods.detect_modules(path, recursive=False)
else: # External.
else: # Custom.
modules = methods.detect_modules(path, env_base["custom_modules_recursive"])
# Provide default include path for both the custom module search `path`
# and the base directory containing custom modules, as it may be different
# from the built-in "modules" name (e.g. "custom_modules/summator/summator.h"),
# so it can be referenced simply as `#include "summator/summator.h"`
# independently of where a module is located on user's filesystem.
env_base.Prepend(CPPPATH=[path, os.path.dirname(path)])
# Note: custom modules can override built-in ones.
modules_detected.update(modules)
include_path = os.path.dirname(path)
if include_path:
env_base.Prepend(CPPPATH=[include_path])

# Add module options
for name, path in modules_detected.items():
Expand Down
7 changes: 4 additions & 3 deletions core/io/file_access_compressed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,10 @@ uint8_t FileAccessCompressed::get_8() const {
return ret;
}
int FileAccessCompressed::get_buffer(uint8_t *p_dst, int p_length) const {

ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
ERR_FAIL_COND_V(!p_dst, -1);
ERR_FAIL_COND_V(p_length < 0, -1);
ERR_FAIL_COND_V_MSG(!f, -1, "File must be opened before use.");
ERR_FAIL_COND_V_MSG(writing, -1, "File has not been opened in read mode.");

if (at_end) {
read_eof = true;
Expand Down
6 changes: 4 additions & 2 deletions core/io/file_access_encrypted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,11 @@ uint8_t FileAccessEncrypted::get_8() const {
pos++;
return b;
}
int FileAccessEncrypted::get_buffer(uint8_t *p_dst, int p_length) const {

ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
int FileAccessEncrypted::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!p_dst, -1);
ERR_FAIL_COND_V(p_length < 0, -1);
ERR_FAIL_COND_V_MSG(writing, -1, "File has not been opened in read mode.");

int to_copy = MIN(p_length, data.size() - pos);
for (int i = 0; i < to_copy; i++) {
Expand Down
3 changes: 2 additions & 1 deletion core/io/file_access_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ uint8_t FileAccessMemory::get_8() const {
}

int FileAccessMemory::get_buffer(uint8_t *p_dst, int p_length) const {

ERR_FAIL_COND_V(!p_dst, -1);
ERR_FAIL_COND_V(p_length < 0, -1);
ERR_FAIL_COND_V(!data, -1);

int left = length - pos;
Expand Down
2 changes: 2 additions & 0 deletions core/io/file_access_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ void FileAccessNetwork::_queue_page(int p_page) const {
}

int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!p_dst, -1);
ERR_FAIL_COND_V(p_length < 0, -1);

//bool eof=false;
if (pos + p_length > total_size) {
Expand Down
2 changes: 2 additions & 0 deletions core/io/file_access_pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ uint8_t FileAccessPack::get_8() const {
}

int FileAccessPack::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!p_dst, -1);
ERR_FAIL_COND_V(p_length < 0, -1);

if (eof)
return 0;
Expand Down
3 changes: 2 additions & 1 deletion core/io/file_access_zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ uint8_t FileAccessZip::get_8() const {
}

int FileAccessZip::get_buffer(uint8_t *p_dst, int p_length) const {

ERR_FAIL_COND_V(!p_dst, -1);
ERR_FAIL_COND_V(p_length < 0, -1);
ERR_FAIL_COND_V(!zfile, -1);
at_eof = unzeof(zfile);
if (at_eof)
Expand Down
3 changes: 2 additions & 1 deletion core/os/file_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
}

int FileAccess::get_buffer(uint8_t *p_dst, int p_length) const {

ERR_FAIL_COND_V(!p_dst, -1);
ERR_FAIL_COND_V(p_length < 0, -1);
int i = 0;
for (i = 0; i < p_length && !eof_reached(); i++)
p_dst[i] = get_8();
Expand Down
30 changes: 18 additions & 12 deletions drivers/coreaudio/audio_driver_coreaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,8 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) {

UInt32 size = 0;
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, NULL, &size);
AudioDeviceID *audioDevices = (AudioDeviceID *)malloc(size);
AudioDeviceID *audioDevices = (AudioDeviceID *)memalloc(size);
ERR_FAIL_NULL_V_MSG(audioDevices, list, "Out of memory.");
AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, NULL, &size, audioDevices);

UInt32 deviceCount = size / sizeof(AudioDeviceID);
Expand All @@ -523,14 +524,15 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) {
prop.mSelector = kAudioDevicePropertyStreamConfiguration;

AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, NULL, &size);
AudioBufferList *bufferList = (AudioBufferList *)malloc(size);
AudioBufferList *bufferList = (AudioBufferList *)memalloc(size);
ERR_FAIL_NULL_V_MSG(bufferList, list, "Out of memory.");
AudioObjectGetPropertyData(audioDevices[i], &prop, 0, NULL, &size, bufferList);

UInt32 channelCount = 0;
for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++)
channelCount += bufferList->mBuffers[j].mNumberChannels;

free(bufferList);
memfree(bufferList);

if (channelCount >= 1) {
CFStringRef cfname;
Expand All @@ -542,17 +544,18 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) {

CFIndex length = CFStringGetLength(cfname);
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1;
char *buffer = (char *)malloc(maxSize);
char *buffer = (char *)memalloc(maxSize);
ERR_FAIL_NULL_V_MSG(buffer, list, "Out of memory.");
if (CFStringGetCString(cfname, buffer, maxSize, kCFStringEncodingUTF8)) {
// Append the ID to the name in case we have devices with duplicate name
list.push_back(String(buffer) + " (" + itos(audioDevices[i]) + ")");
}

free(buffer);
memfree(buffer);
}
}

free(audioDevices);
memfree(audioDevices);

return list;
}
Expand All @@ -570,7 +573,8 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {

UInt32 size = 0;
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, NULL, &size);
AudioDeviceID *audioDevices = (AudioDeviceID *)malloc(size);
AudioDeviceID *audioDevices = (AudioDeviceID *)memalloc(size);
ERR_FAIL_NULL_MSG(audioDevices, "Out of memory.");
AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, NULL, &size, audioDevices);

UInt32 deviceCount = size / sizeof(AudioDeviceID);
Expand All @@ -579,14 +583,15 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
prop.mSelector = kAudioDevicePropertyStreamConfiguration;

AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, NULL, &size);
AudioBufferList *bufferList = (AudioBufferList *)malloc(size);
AudioBufferList *bufferList = (AudioBufferList *)memalloc(size);
ERR_FAIL_NULL_MSG(bufferList, "Out of memory.");
AudioObjectGetPropertyData(audioDevices[i], &prop, 0, NULL, &size, bufferList);

UInt32 channelCount = 0;
for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++)
channelCount += bufferList->mBuffers[j].mNumberChannels;

free(bufferList);
memfree(bufferList);

if (channelCount >= 1) {
CFStringRef cfname;
Expand All @@ -598,7 +603,8 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {

CFIndex length = CFStringGetLength(cfname);
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1;
char *buffer = (char *)malloc(maxSize);
char *buffer = (char *)memalloc(maxSize);
ERR_FAIL_NULL_MSG(buffer, "Out of memory.");
if (CFStringGetCString(cfname, buffer, maxSize, kCFStringEncodingUTF8)) {
String name = String(buffer) + " (" + itos(audioDevices[i]) + ")";
if (name == device) {
Expand All @@ -607,11 +613,11 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
}
}

free(buffer);
memfree(buffer);
}
}

free(audioDevices);
memfree(audioDevices);
}

if (!found) {
Expand Down
3 changes: 2 additions & 1 deletion drivers/unix/file_access_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ uint8_t FileAccessUnix::get_8() const {
}

int FileAccessUnix::get_buffer(uint8_t *p_dst, int p_length) const {

ERR_FAIL_COND_V(!p_dst, -1);
ERR_FAIL_COND_V(p_length < 0, -1);
ERR_FAIL_COND_V_MSG(!f, -1, "File must be opened before use.");
int read = fread(p_dst, 1, p_length, f);
check_errors();
Expand Down
3 changes: 2 additions & 1 deletion drivers/windows/file_access_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ uint8_t FileAccessWindows::get_8() const {
}

int FileAccessWindows::get_buffer(uint8_t *p_dst, int p_length) const {

ERR_FAIL_COND_V(!p_dst, -1);
ERR_FAIL_COND_V(p_length < 0, -1);
ERR_FAIL_COND_V(!f, -1);
if (flags == READ_WRITE || flags == WRITE_READ) {
if (prev_op == WRITE) {
Expand Down
4 changes: 2 additions & 2 deletions editor/editor_file_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,9 +1105,9 @@ EditorFileDialog::Access EditorFileDialog::get_access() const {

void EditorFileDialog::_make_dir_confirm() {

Error err = dir_access->make_dir(makedirname->get_text());
Error err = dir_access->make_dir(makedirname->get_text().strip_edges());
if (err == OK) {
dir_access->change_dir(makedirname->get_text());
dir_access->change_dir(makedirname->get_text().strip_edges());
invalidate();
update_filters();
update_dir();
Expand Down
13 changes: 8 additions & 5 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2340,11 +2340,14 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
_scene_tab_changed(tab_closing);

if (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER) {
String scene_filename = editor_data.get_edited_scene_root(tab_closing)->get_filename();
save_confirmation->get_ok()->set_text(TTR("Save & Close"));
save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene_filename != "" ? scene_filename : "unsaved scene"));
save_confirmation->popup_centered_minsize();
break;
Node *scene_root = editor_data.get_edited_scene_root(tab_closing);
if (scene_root) {
String scene_filename = scene_root->get_filename();
save_confirmation->get_ok()->set_text(TTR("Save & Close"));
save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene_filename != "" ? scene_filename : "unsaved scene"));
save_confirmation->popup_centered_minsize();
break;
}
}
} else if (p_option == FILE_CLOSE) {
tab_closing = editor_data.get_edited_scene();
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2702,7 +2702,7 @@ void EditorPropertyResource::update_property() {
sub_inspector->set_use_doc_hints(true);

sub_inspector->set_sub_inspector(true);
sub_inspector->set_enable_capitalize_paths(true);
sub_inspector->set_enable_capitalize_paths(bool(EDITOR_GET("interface/inspector/capitalize_properties")));

sub_inspector->connect("property_keyed", this, "_sub_inspector_property_keyed");
sub_inspector->connect("resource_selected", this, "_sub_inspector_resource_selected");
Expand Down
8 changes: 6 additions & 2 deletions editor/editor_spin_slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) {
if (mousewheel_over_grabber)
return;

float grabbing_ofs = (grabber->get_transform().xform(mm->get_position()).x - grabbing_from) / float(grabber_range);
float scale_x = get_global_transform_with_canvas().get_scale().x;
ERR_FAIL_COND(Math::is_zero_approx(scale_x));
float grabbing_ofs = (grabber->get_transform().xform(mm->get_position()).x - grabbing_from) / float(grabber_range) / scale_x;
set_as_ratio(grabbing_ratio + grabbing_ofs);
update();
}
Expand Down Expand Up @@ -311,8 +313,10 @@ void EditorSpinSlider::_notification(int p_what) {
grabber->set_texture(grabber_tex);
}

Vector2 scale = get_global_transform_with_canvas().get_scale();
grabber->set_scale(scale);
grabber->set_size(Size2(0, 0));
grabber->set_position(get_global_position() + grabber_rect.position + grabber_rect.size * 0.5 - grabber->get_size() * 0.5);
grabber->set_position(get_global_position() + (grabber_rect.position + grabber_rect.size * 0.5 - grabber->get_size() * 0.5) * scale);

if (mousewheel_over_grabber) {
Input::get_singleton()->warp_mouse_position(grabber->get_position() + grabber_rect.size);
Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/abstract_polygon_2d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,12 +686,12 @@ void AbstractPolygon2DEditor::edit(Node *p_polygon) {
edited_point = PosVertex();
hover_point = Vertex();
selected_point = Vertex();

canvas_item_editor->update_viewport();
} else {

_set_node(NULL);
}

canvas_item_editor->update_viewport();
}

void AbstractPolygon2DEditor::_bind_methods() {
Expand Down
31 changes: 19 additions & 12 deletions editor/plugins/asset_library_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,24 @@ void EditorAssetLibrary::_notification(int p_what) {
filter->set_right_icon(get_icon("Search", "EditorIcons"));
filter->set_clear_button_enabled(true);
} break;

case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_update_repository_options();
} break;
}
}

void EditorAssetLibrary::_update_repository_options() {
Dictionary default_urls;
default_urls["godotengine.org"] = "https://godotengine.org/asset-library/api";
default_urls["localhost"] = "http://127.0.0.1/asset-library/api";
Dictionary available_urls = _EDITOR_DEF("asset_library/available_urls", default_urls, true);
repository->clear();
Array keys = available_urls.keys();
for (int i = 0; i < available_urls.size(); i++) {
String key = keys[i];
repository->add_item(key);
repository->set_item_metadata(i, available_urls[key]);
}
}

Expand Down Expand Up @@ -1432,18 +1450,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
search_hb2->add_child(memnew(Label(TTR("Site:") + " ")));
repository = memnew(OptionButton);

{
Dictionary default_urls;
default_urls["godotengine.org"] = "https://godotengine.org/asset-library/api";
default_urls["localhost"] = "http://127.0.0.1/asset-library/api";
Dictionary available_urls = _EDITOR_DEF("asset_library/available_urls", default_urls, true);
Array keys = available_urls.keys();
for (int i = 0; i < available_urls.size(); i++) {
String key = keys[i];
repository->add_item(key);
repository->set_item_metadata(i, available_urls[key]);
}
}
_update_repository_options();

repository->connect("item_selected", this, "_repository_changed");

Expand Down
1 change: 1 addition & 0 deletions editor/plugins/asset_library_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class EditorAssetLibrary : public PanelContainer {

void _asset_open();
void _asset_file_selected(const String &p_file);
void _update_repository_options();

PanelContainer *library_scroll_bg;
ScrollContainer *library_scroll;
Expand Down
7 changes: 3 additions & 4 deletions editor/plugins/spatial_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1847,10 +1847,8 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {

} else if (m->get_button_mask() & BUTTON_MASK_MIDDLE) {

const int mod = _get_key_modifier(m);
if (nav_scheme == NAVIGATION_GODOT) {

const int mod = _get_key_modifier(m);

if (mod == _get_key_modifier_setting("editors/3d/navigation/pan_modifier")) {
nav_mode = NAVIGATION_PAN;
} else if (mod == _get_key_modifier_setting("editors/3d/navigation/zoom_modifier")) {
Expand All @@ -1861,8 +1859,9 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}

} else if (nav_scheme == NAVIGATION_MAYA) {
if (m->get_alt())
if (mod == _get_key_modifier_setting("editors/3d/navigation/pan_modifier")) {
nav_mode = NAVIGATION_PAN;
}
}

} else if (EditorSettings::get_singleton()->get("editors/3d/navigation/emulate_3_button_mouse")) {
Expand Down
4 changes: 2 additions & 2 deletions editor/scene_tree_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,7 @@ void SceneTreeEditor::_selected_changed() {
}

void SceneTreeEditor::_deselect_items() {

// Clear currently elected items in scene tree dock.
// Clear currently selected items in scene tree dock.
if (editor_selection) {
editor_selection->clear();
emit_signal("node_changed");
Expand Down Expand Up @@ -1196,6 +1195,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope
tree->set_begin(Point2(0, p_label ? 18 : 0));
tree->set_end(Point2(0, 0));
tree->add_constant_override("button_margin", 0);
tree->set_allow_reselect(true);

add_child(tree);

Expand Down
Loading

0 comments on commit 6a9e7c5

Please sign in to comment.