summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/math/math_funcs.cpp15
-rw-r--r--core/math/math_funcs.h5
-rw-r--r--core/math/matrix3.cpp25
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp53
-rw-r--r--drivers/wasapi/audio_driver_wasapi.h2
-rw-r--r--editor/filesystem_dock.cpp653
-rw-r--r--editor/filesystem_dock.h35
-rw-r--r--editor/project_settings_editor.cpp1
-rw-r--r--modules/gdscript/gd_functions.cpp22
-rw-r--r--modules/gdscript/gd_functions.h2
-rw-r--r--modules/mono/csharp_script.cpp73
-rw-r--r--modules/mono/csharp_script.h11
-rw-r--r--modules/mono/mono_gc_handle.cpp4
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp6
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp2
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.h4
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp40
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.h2
-rw-r--r--scene/2d/joints_2d.cpp107
-rw-r--r--scene/2d/joints_2d.h13
-rw-r--r--scene/3d/physics_joint.cpp31
-rw-r--r--scene/gui/text_edit.cpp7
-rw-r--r--servers/audio_server.cpp2
-rw-r--r--servers/physics/body_sw.cpp5
-rw-r--r--servers/physics/joints/generic_6dof_joint_sw.cpp4
-rw-r--r--servers/physics/physics_server_sw.cpp14
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp14
27 files changed, 636 insertions, 516 deletions
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 6fb688f16b..64e01e5841 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -176,3 +176,18 @@ float Math::random(float from, float to) {
float ret = (float)r / (float)RANDOM_MAX;
return (ret) * (to - from) + from;
}
+
+int Math::wrapi(int value, int min, int max) {
+ --max;
+ int rng = max - min + 1;
+ value = ((value - min) % rng);
+ if (value < 0)
+ return max + 1 + value;
+ else
+ return min + value;
+}
+
+float Math::wrapf(float value, float min, float max) {
+ float rng = max - min;
+ return min + (value - min) - (rng * floor((value - min) / rng));
+}
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 65b2ffb0df..7715e5d6e5 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -207,6 +207,9 @@ public:
static _ALWAYS_INLINE_ double round(double p_val) { return (p_val >= 0) ? Math::floor(p_val + 0.5) : -Math::floor(-p_val + 0.5); }
static _ALWAYS_INLINE_ float round(float p_val) { return (p_val >= 0) ? Math::floor(p_val + 0.5) : -Math::floor(-p_val + 0.5); }
+ static int wrapi(int value, int min, int max);
+ static float wrapf(float value, float min, float max);
+
// double only, as these functions are mainly used by the editor and not performance-critical,
static double ease(double p_x, double p_c);
static int step_decimals(double p_step);
@@ -268,7 +271,7 @@ public:
#elif defined(_MSC_VER) && _MSC_VER < 1800
__asm fld a __asm fistp b
-/*#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) )
+ /*#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) )
// use AT&T inline assembly style, document that
// we use memory as output (=m) and input (m)
__asm__ __volatile__ (
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index 85421c074b..ab3bca79ae 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -279,7 +279,7 @@ Vector3 Basis::get_signed_scale() const {
// Decomposes a Basis into a rotation-reflection matrix (an element of the group O(3)) and a positive scaling matrix as B = O.S.
// Returns the rotation-reflection matrix via reference argument, and scaling information is returned as a Vector3.
-// This (internal) function is too specıfıc and named too ugly to expose to users, and probably there's no need to do so.
+// This (internal) function is too specific and named too ugly to expose to users, and probably there's no need to do so.
Vector3 Basis::rotref_posscale_decomposition(Basis &rotref) const {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V(determinant() == 0, Vector3());
@@ -371,31 +371,30 @@ Vector3 Basis::get_euler_xyz() const {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V(is_rotation() == false, euler);
#endif
- euler.y = Math::asin(elements[0][2]);
- if (euler.y < Math_PI * 0.5) {
- if (euler.y > -Math_PI * 0.5) {
+ real_t sy = elements[0][2];
+ if (sy < 1.0) {
+ if (sy > -1.0) {
// is this a pure Y rotation?
if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[1][2] == 0 && elements[2][1] == 0 && elements[1][1] == 1) {
- // return the simplest form
+ // return the simplest form (human friendlier in editor and scripts)
euler.x = 0;
euler.y = atan2(elements[0][2], elements[0][0]);
euler.z = 0;
} else {
euler.x = Math::atan2(-elements[1][2], elements[2][2]);
+ euler.y = Math::asin(sy);
euler.z = Math::atan2(-elements[0][1], elements[0][0]);
}
-
} else {
- real_t r = Math::atan2(elements[1][0], elements[1][1]);
+ euler.x = -Math::atan2(elements[0][1], elements[1][1]);
+ euler.y = -Math_PI / 2.0;
euler.z = 0.0;
- euler.x = euler.z - r;
}
} else {
- real_t r = Math::atan2(elements[0][1], elements[1][1]);
- euler.z = 0;
- euler.x = r - euler.z;
+ euler.x = Math::atan2(elements[0][1], elements[1][1]);
+ euler.y = Math_PI / 2.0;
+ euler.z = 0.0;
}
-
return euler;
}
@@ -445,7 +444,7 @@ Vector3 Basis::get_euler_yxz() const {
if (m12 > -1) {
// is this a pure X rotation?
if (elements[1][0] == 0 && elements[0][1] == 0 && elements[0][2] == 0 && elements[2][0] == 0 && elements[0][0] == 1) {
- // return the simplest form
+ // return the simplest form (human friendlier in editor and scripts)
euler.x = atan2(-m12, elements[1][1]);
euler.y = 0;
euler.z = 0;
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index eb86491dec..0671ee408e 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -39,7 +39,7 @@ const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
const IID IID_IAudioClient = __uuidof(IAudioClient);
const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);
-Error AudioDriverWASAPI::init_device() {
+Error AudioDriverWASAPI::init_device(bool reinit) {
WAVEFORMATEX *pwfex;
IMMDeviceEnumerator *enumerator = NULL;
@@ -51,10 +51,24 @@ Error AudioDriverWASAPI::init_device() {
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, &device);
- ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
+ if (reinit) {
+ // In case we're trying to re-initialize the device prevent throwing this error on the console,
+ // otherwise if there is currently no devie available this will spam the console.
+ if (hr != S_OK) {
+ return ERR_CANT_OPEN;
+ }
+ } else {
+ ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
+ }
hr = device->Activate(IID_IAudioClient, CLSCTX_ALL, NULL, (void **)&audio_client);
- ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
+ if (reinit) {
+ if (hr != S_OK) {
+ return ERR_CANT_OPEN;
+ }
+ } else {
+ ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
+ }
hr = audio_client->GetMixFormat(&pwfex);
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
@@ -152,7 +166,9 @@ Error AudioDriverWASAPI::finish_device() {
Error AudioDriverWASAPI::init() {
Error err = init_device();
- ERR_FAIL_COND_V(err != OK, err);
+ if (err != OK) {
+ ERR_PRINT("WASAPI: init_device error");
+ }
active = false;
exit_thread = false;
@@ -209,7 +225,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
unsigned int left_frames = ad->buffer_frames;
unsigned int buffer_idx = 0;
- while (left_frames > 0) {
+ while (left_frames > 0 && ad->audio_client) {
WaitForSingleObject(ad->event, 1000);
UINT32 cur_frames;
@@ -271,9 +287,9 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
} else if (hr == AUDCLNT_E_DEVICE_INVALIDATED) {
// Device is not valid anymore, reopen it
- Error err = ad->reopen();
+ Error err = ad->finish_device();
if (err != OK) {
- ad->exit_thread = true;
+ ERR_PRINT("WASAPI: finish_device error");
} else {
// We reopened the device and samples_in may have resized, so invalidate the current left_frames
left_frames = 0;
@@ -285,9 +301,9 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
} else if (hr == AUDCLNT_E_DEVICE_INVALIDATED) {
// Device is not valid anymore, reopen it
- Error err = ad->reopen();
+ Error err = ad->finish_device();
if (err != OK) {
- ad->exit_thread = true;
+ ERR_PRINT("WASAPI: finish_device error");
} else {
// We reopened the device and samples_in may have resized, so invalidate the current left_frames
left_frames = 0;
@@ -296,6 +312,13 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
ERR_PRINT("WASAPI: GetCurrentPadding error");
}
}
+
+ if (!ad->audio_client) {
+ Error err = ad->init_device(true);
+ if (err == OK) {
+ ad->start();
+ }
+ }
}
ad->thread_exited = true;
@@ -303,11 +326,13 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
void AudioDriverWASAPI::start() {
- HRESULT hr = audio_client->Start();
- if (hr != S_OK) {
- ERR_PRINT("WASAPI: Start failed");
- } else {
- active = true;
+ if (audio_client) {
+ HRESULT hr = audio_client->Start();
+ if (hr != S_OK) {
+ ERR_PRINT("WASAPI: Start failed");
+ } else {
+ active = true;
+ }
}
}
diff --git a/drivers/wasapi/audio_driver_wasapi.h b/drivers/wasapi/audio_driver_wasapi.h
index fab8ab3250..87a2db724c 100644
--- a/drivers/wasapi/audio_driver_wasapi.h
+++ b/drivers/wasapi/audio_driver_wasapi.h
@@ -64,7 +64,7 @@ class AudioDriverWASAPI : public AudioDriver {
static void thread_func(void *p_udata);
- Error init_device();
+ Error init_device(bool reinit = false);
Error finish_device();
Error reopen();
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index dfd35fdd96..62d77f56bc 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -38,16 +38,12 @@
#include "project_settings.h"
#include "scene/main/viewport.h"
-bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir) {
+bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths) {
TreeItem *item = tree->create_item(p_parent);
String dname = p_dir->get_name();
if (dname == "")
dname = "res://";
- else {
- // collapse every tree item but the root folder
- item->set_collapsed(true);
- }
item->set_text(0, dname);
item->set_icon(0, get_icon("Folder", "EditorIcons"));
@@ -61,38 +57,78 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
item->select(0);
}
+ if ((path.begins_with(lpath) && path != lpath)) {
+ item->set_collapsed(false);
+ } else {
+ bool is_collapsed = true;
+ for (int i = 0; i < uncollapsed_paths.size(); i++) {
+ if (lpath == uncollapsed_paths[i]) {
+ is_collapsed = false;
+ break;
+ }
+ }
+ item->set_collapsed(is_collapsed);
+ }
+
for (int i = 0; i < p_dir->get_subdir_count(); i++)
- _create_tree(item, p_dir->get_subdir(i));
+ _create_tree(item, p_dir->get_subdir(i), uncollapsed_paths);
return true;
}
-void FileSystemDock::_update_tree() {
+void FileSystemDock::_update_tree(bool keep_collapse_state) {
+
+ Vector<String> uncollapsed_paths;
+ if (keep_collapse_state) {
+ TreeItem *root = tree->get_root();
+ if (root) {
+ TreeItem *resTree = root->get_children()->get_next();
+
+ Vector<TreeItem *> needs_check;
+ needs_check.push_back(resTree);
+
+ while (needs_check.size()) {
+ if (!needs_check[0]->is_collapsed()) {
+ uncollapsed_paths.push_back(needs_check[0]->get_metadata(0));
+ TreeItem *child = needs_check[0]->get_children();
+ while (child) {
+ needs_check.push_back(child);
+ child = child->get_next();
+ }
+ }
+ needs_check.remove(0);
+ }
+ }
+ }
tree->clear();
updating_tree = true;
+
TreeItem *root = tree->create_item();
TreeItem *favorites = tree->create_item(root);
favorites->set_icon(0, get_icon("Favorites", "EditorIcons"));
favorites->set_text(0, TTR("Favorites:"));
favorites->set_selectable(0, false);
- Vector<String> faves = EditorSettings::get_singleton()->get_favorite_dirs();
- for (int i = 0; i < faves.size(); i++) {
- if (!faves[i].begins_with("res://"))
+
+ Vector<String> favorite_paths = EditorSettings::get_singleton()->get_favorite_dirs();
+ String res_path = "res://";
+ Ref<Texture> folder_icon = get_icon("Folder", "EditorIcons");
+ for (int i = 0; i < favorite_paths.size(); i++) {
+ String fave = favorite_paths[i];
+ if (!fave.begins_with(res_path))
continue;
TreeItem *ti = tree->create_item(favorites);
- String fv = faves[i];
- if (fv == "res://")
+ if (fave == res_path)
ti->set_text(0, "/");
else
- ti->set_text(0, faves[i].get_file());
- ti->set_icon(0, get_icon("Folder", "EditorIcons"));
+ ti->set_text(0, fave.get_file());
+ ti->set_icon(0, folder_icon);
ti->set_selectable(0, true);
- ti->set_metadata(0, faves[i]);
+ ti->set_metadata(0, fave);
}
- _create_tree(root, EditorFileSystem::get_singleton()->get_filesystem());
+ _create_tree(root, EditorFileSystem::get_singleton()->get_filesystem(), uncollapsed_paths);
updating_tree = false;
}
@@ -104,26 +140,28 @@ void FileSystemDock::_notification(int p_what) {
bool new_mode = get_size().height < get_viewport_rect().size.height / 2;
- if (new_mode != split_mode) {
+ if (new_mode != low_height_mode) {
- split_mode = new_mode;
+ low_height_mode = new_mode;
- //print_line("SPLIT MODE? "+itos(split_mode));
- if (split_mode) {
+ if (low_height_mode) {
file_list_vb->hide();
- tree->set_custom_minimum_size(Size2(0, 0));
tree->set_v_size_flags(SIZE_EXPAND_FILL);
- button_back->show();
+ button_tree->show();
} else {
- tree->show();
- file_list_vb->show();
- tree->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
tree->set_v_size_flags(SIZE_FILL);
- button_back->hide();
- if (!EditorFileSystem::get_singleton()->is_scanning()) {
- _fs_changed();
+ if (!tree->is_visible()) {
+ tree->show();
+ button_favorite->show();
+ _update_tree(true);
+ }
+
+ if (!file_list_vb->is_visible()) {
+ file_list_vb->show();
+ button_tree->hide();
+ _update_files(true);
}
}
}
@@ -138,30 +176,32 @@ void FileSystemDock::_notification(int p_what) {
EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_fs_changed");
EditorResourcePreview::get_singleton()->connect("preview_invalidated", this, "_preview_invalidated");
- button_reload->set_icon(get_icon("Reload", "EditorIcons"));
- button_favorite->set_icon(get_icon("Favorites", "EditorIcons"));
- //button_instance->set_icon( get_icon("Add","EditorIcons"));
- //button_open->set_icon( get_icon("Folder","EditorIcons"));
- button_back->set_icon(get_icon("Filesystem", "EditorIcons"));
+ String ei = "EditorIcons";
+ button_reload->set_icon(get_icon("Reload", ei));
+ button_favorite->set_icon(get_icon("Favorites", ei));
+ //button_instance->set_icon(get_icon("Add", ei));
+ //button_open->set_icon(get_icon("Folder", ei));
+ button_tree->set_icon(get_icon("Filesystem", ei));
_update_file_display_toggle_button();
button_display_mode->connect("pressed", this, "_change_file_display");
- //file_options->set_icon( get_icon("Tools","EditorIcons"));
+ //file_options->set_icon( get_icon("Tools","ei"));
files->connect("item_activated", this, "_select_file");
button_hist_next->connect("pressed", this, "_fw_history");
button_hist_prev->connect("pressed", this, "_bw_history");
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->add_icon_override("right_icon", get_icon("Search", ei));
- button_hist_next->set_icon(get_icon("Forward", "EditorIcons"));
- button_hist_prev->set_icon(get_icon("Back", "EditorIcons"));
+ button_hist_next->set_icon(get_icon("Forward", ei));
+ button_hist_prev->set_icon(get_icon("Back", ei));
file_options->connect("id_pressed", this, "_file_option");
folder_options->connect("id_pressed", this, "_folder_option");
- button_back->connect("pressed", this, "_go_to_tree", varray(), CONNECT_DEFERRED);
- current_path->connect("text_entered", this, "_go_to_dir");
- _update_tree(); //maybe it finished already
+ button_tree->connect("pressed", this, "_go_to_tree", varray(), CONNECT_DEFERRED);
+ current_path->connect("text_entered", this, "navigate_to_path");
if (EditorFileSystem::get_singleton()->is_scanning()) {
_set_scanning_mode();
+ } else {
+ _update_tree(false);
}
} break;
@@ -179,8 +219,7 @@ void FileSystemDock::_notification(int p_what) {
if (tree->is_visible_in_tree() && dd.has("type")) {
if ((String(dd["type"]) == "files") || (String(dd["type"]) == "files_and_dirs") || (String(dd["type"]) == "resource")) {
tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
- }
- if ((String(dd["type"]) == "favorite")) {
+ } else if ((String(dd["type"]) == "favorite")) {
tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
}
}
@@ -193,52 +232,54 @@ void FileSystemDock::_notification(int p_what) {
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ String ei = "EditorIcons";
int new_mode = int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode"));
//_update_icons
- button_reload->set_icon(get_icon("Reload", "EditorIcons"));
- button_favorite->set_icon(get_icon("Favorites", "EditorIcons"));
- button_back->set_icon(get_icon("Filesystem", "EditorIcons"));
- _update_file_display_toggle_button();
-
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ button_reload->set_icon(get_icon("Reload", ei));
+ button_favorite->set_icon(get_icon("Favorites", ei));
+ button_tree->set_icon(get_icon("Filesystem", ei));
+ button_hist_next->set_icon(get_icon("Forward", ei));
+ button_hist_prev->set_icon(get_icon("Back", ei));
- button_hist_next->set_icon(get_icon("Forward", "EditorIcons"));
- button_hist_prev->set_icon(get_icon("Back", "EditorIcons"));
+ search_box->add_icon_override("right_icon", get_icon("Search", ei));
if (new_mode != display_mode) {
set_display_mode(new_mode);
} else {
+ _update_file_display_toggle_button();
_update_files(true);
}
- _update_tree();
-
+ _update_tree(true);
} break;
}
}
void FileSystemDock::_dir_selected() {
- TreeItem *ti = tree->get_selected();
- if (!ti)
+ TreeItem *sel = tree->get_selected();
+ if (!sel)
return;
- String dir = ti->get_metadata(0);
+ path = sel->get_metadata(0);
+
bool found = false;
Vector<String> favorites = EditorSettings::get_singleton()->get_favorite_dirs();
for (int i = 0; i < favorites.size(); i++) {
- if (favorites[i] == dir) {
+ if (favorites[i] == path) {
found = true;
break;
}
}
button_favorite->set_pressed(found);
+ current_path->set_text(path);
+ _push_to_history();
- if (!split_mode) {
- _open_pressed(); //go directly to dir
+ if (!low_height_mode) {
+ _update_files(false);
}
}
@@ -247,27 +288,25 @@ void FileSystemDock::_favorites_pressed() {
TreeItem *sel = tree->get_selected();
if (!sel)
return;
- String dir = sel->get_metadata(0);
+ path = sel->get_metadata(0);
int idx = -1;
Vector<String> favorites = EditorSettings::get_singleton()->get_favorite_dirs();
for (int i = 0; i < favorites.size(); i++) {
- if (favorites[i] == dir) {
+ if (favorites[i] == path) {
idx = i;
break;
}
}
- if (button_favorite->is_pressed() && idx == -1) {
- favorites.push_back(dir);
- EditorSettings::get_singleton()->set_favorite_dirs(favorites);
- _update_tree();
- } else if (!button_favorite->is_pressed() && idx != -1) {
+ if (idx == -1) {
+ favorites.push_back(path);
+ } else {
favorites.remove(idx);
- EditorSettings::get_singleton()->set_favorite_dirs(favorites);
- _update_tree();
}
+ EditorSettings::get_singleton()->set_favorite_dirs(favorites);
+ _update_tree(true);
}
String FileSystemDock::get_selected_path() const {
@@ -275,8 +314,8 @@ String FileSystemDock::get_selected_path() const {
TreeItem *sel = tree->get_selected();
if (!sel)
return "";
- String path = sel->get_metadata(0);
- return "res://" + path;
+
+ return sel->get_metadata(0);
}
String FileSystemDock::get_current_path() const {
@@ -286,27 +325,33 @@ String FileSystemDock::get_current_path() const {
void FileSystemDock::navigate_to_path(const String &p_path) {
// If the path is a file, do not only go to the directory in the tree, also select the file in the file list.
- String dir_path = "";
String file_name = "";
DirAccess *dirAccess = DirAccess::open("res://");
if (dirAccess->file_exists(p_path)) {
- dir_path = p_path.get_base_dir();
+ path = p_path.get_base_dir();
file_name = p_path.get_file();
} else if (dirAccess->dir_exists(p_path)) {
- dir_path = p_path;
+ path = p_path;
} else {
ERR_EXPLAIN(TTR("Cannot navigate to '" + p_path + "' as it has not been found in the file system!"));
ERR_FAIL();
}
- path = dir_path;
- _update_tree();
- tree->ensure_cursor_is_visible();
+ current_path->set_text(path);
+ _push_to_history();
- if (!file_name.empty()) {
- _open_pressed(); // Seems to be the only way to get into the file view. This also pushes to history.
+ if (!low_height_mode) {
+ _update_tree(true);
+ _update_files(false);
+ } else {
+ if (file_name.empty()) {
+ _go_to_tree();
+ } else {
+ _go_to_file_list();
+ }
+ }
- // Focus the given file.
+ if (!file_name.empty()) {
for (int i = 0; i < files->get_item_count(); i++) {
if (files->get_item_text(i) == file_name) {
files->select(i, true);
@@ -319,27 +364,13 @@ void FileSystemDock::navigate_to_path(const String &p_path) {
void FileSystemDock::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata) {
- bool valid = false;
-
- if (search_box->is_visible()) {
- valid = true;
- } else {
- valid = (path == p_path.get_base_dir());
- }
-
- if (p_preview.is_valid() && valid) {
+ if ((file_list_vb->is_visible_in_tree() || path == p_path.get_base_dir()) && p_preview.is_valid()) {
Array uarr = p_udata;
int idx = uarr[0];
String file = uarr[1];
- if (idx >= files->get_item_count())
- return;
- if (files->get_item_text(idx) != file)
- return;
- String fpath = files->get_item_metadata(idx);
- if (fpath != p_path)
- return;
- files->set_item_icon(idx, p_preview);
+ if (idx < files->get_item_count() && files->get_item_text(idx) == file && files->get_item_metadata(idx) == p_path)
+ files->set_item_icon(idx, p_preview);
}
}
@@ -416,6 +447,7 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
if (!efd)
return;
+ String ei = "EditorIcons";
int thumbnail_size = EditorSettings::get_singleton()->get("docks/filesystem/thumbnail_size");
thumbnail_size *= EDSCALE;
Ref<Texture> folder_thumbnail;
@@ -425,9 +457,9 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
bool always_show_folders = EditorSettings::get_singleton()->get("docks/filesystem/always_show_folders");
bool use_thumbnails = (display_mode == DISPLAY_THUMBNAILS);
- bool use_folders = search_box->get_text().length() == 0 && (split_mode || always_show_folders);
+ bool use_folders = search_box->get_text().length() == 0 && (low_height_mode || always_show_folders);
- if (use_thumbnails) { //thumbnails
+ if (use_thumbnails) {
files->set_max_columns(0);
files->set_icon_mode(ItemList::ICON_MODE_TOP);
@@ -436,13 +468,13 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
if (thumbnail_size < 64) {
- folder_thumbnail = get_icon("FolderMediumThumb", "EditorIcons");
- file_thumbnail = get_icon("FileMediumThumb", "EditorIcons");
- file_thumbnail_broken = get_icon("FileDeadMediumThumb", "EditorIcons");
+ folder_thumbnail = get_icon("FolderMediumThumb", ei);
+ file_thumbnail = get_icon("FileMediumThumb", ei);
+ file_thumbnail_broken = get_icon("FileDeadMediumThumb", ei);
} else {
- folder_thumbnail = get_icon("FolderBigThumb", "EditorIcons");
- file_thumbnail = get_icon("FileBigThumb", "EditorIcons");
- file_thumbnail_broken = get_icon("FileDeadBigThumb", "EditorIcons");
+ folder_thumbnail = get_icon("FolderBigThumb", ei);
+ file_thumbnail = get_icon("FileBigThumb", ei);
+ file_thumbnail_broken = get_icon("FileDeadBigThumb", ei);
}
} else {
@@ -454,14 +486,10 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
}
if (use_folders) {
+ Ref<Texture> folderIcon = (use_thumbnails) ? folder_thumbnail : get_icon("folder", "FileDialog");
if (path != "res://") {
-
- if (use_thumbnails) {
- files->add_item("..", folder_thumbnail, false);
- } else {
- files->add_item("..", get_icon("folder", "FileDialog"), false);
- }
+ files->add_item("..", folderIcon, false);
String bd = path.get_base_dir();
if (bd != "res://" && !bd.ends_with("/"))
@@ -474,12 +502,7 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
String dname = efd->get_subdir(i)->get_name();
- if (use_thumbnails) {
- files->add_item(dname, folder_thumbnail, true);
- } else {
- files->add_item(dname, get_icon("folder", "FileDialog"), true);
- }
-
+ files->add_item(dname, folderIcon, true);
files->set_item_metadata(files->get_item_count() - 1, path.plus_file(dname) + "/");
if (cselection.has(dname))
@@ -489,12 +512,9 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
List<FileInfo> filelist;
- if (search_box->get_text().length()) {
-
- if (search_box->get_text().length() > 1) {
- _search(EditorFileSystem::get_singleton()->get_filesystem(), &filelist, 128);
- }
+ if (search_box->get_text().length() > 0) {
+ _search(EditorFileSystem::get_singleton()->get_filesystem(), &filelist, 128);
filelist.sort();
} else {
@@ -511,68 +531,66 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
}
}
- StringName ei = "EditorIcons"; //make it faster..
- StringName oi = "Object";
+ String oi = "Object";
for (List<FileInfo>::Element *E = filelist.front(); E; E = E->next()) {
- String fname = E->get().name;
- String fp = E->get().path;
- StringName type = E->get().type;
+ FileInfo *finfo = &(E->get());
+ String fname = finfo->name;
+ String fpath = finfo->path;
+ String ftype = finfo->type;
Ref<Texture> type_icon;
- Ref<Texture> big_icon = file_thumbnail;
+ Ref<Texture> big_icon;
String tooltip = fname;
- if (!E->get().import_broken) {
-
- if (has_icon(type, ei)) {
- type_icon = get_icon(type, ei);
- } else {
- type_icon = get_icon(oi, ei);
- }
+ if (!finfo->import_broken) {
+ type_icon = (has_icon(ftype, ei)) ? get_icon(ftype, ei) : get_icon(oi, ei);
+ big_icon = file_thumbnail;
} else {
- type_icon = get_icon("ImportFail", "EditorIcons");
+ type_icon = get_icon("ImportFail", ei);
big_icon = file_thumbnail_broken;
tooltip += TTR("\nStatus: Import of file failed. Please fix file and reimport manually.");
}
- if (E->get().sources.size()) {
- for (int i = 0; i < E->get().sources.size(); i++) {
- tooltip += TTR("\nSource: ") + E->get().sources[i];
- }
- }
-
+ int item_index;
if (use_thumbnails) {
files->add_item(fname, big_icon, true);
- files->set_item_metadata(files->get_item_count() - 1, fp);
- files->set_item_tag_icon(files->get_item_count() - 1, type_icon);
- Array udata;
- udata.resize(2);
- udata[0] = files->get_item_count() - 1;
- udata[1] = fname;
- if (!E->get().import_broken) {
- EditorResourcePreview::get_singleton()->queue_resource_preview(fp, this, "_thumbnail_done", udata);
+ item_index = files->get_item_count() - 1;
+ files->set_item_metadata(item_index, fpath);
+ files->set_item_tag_icon(item_index, type_icon);
+ if (!finfo->import_broken) {
+ Array udata;
+ udata.resize(2);
+ udata[0] = item_index;
+ udata[1] = fname;
+ EditorResourcePreview::get_singleton()->queue_resource_preview(fpath, this, "_thumbnail_done", udata);
}
} else {
files->add_item(fname, type_icon, true);
- files->set_item_metadata(files->get_item_count() - 1, fp);
+ item_index = files->get_item_count() - 1;
+ files->set_item_metadata(item_index, fpath);
}
if (cselection.has(fname))
- files->select(files->get_item_count() - 1, false);
+ files->select(item_index, false);
- files->set_item_tooltip(files->get_item_count() - 1, tooltip);
+ if (finfo->sources.size()) {
+ for (int j = 0; j < finfo->sources.size(); j++) {
+ tooltip += "\nSource: " + finfo->sources[j];
+ }
+ }
+ files->set_item_tooltip(item_index, tooltip);
}
}
void FileSystemDock::_select_file(int p_idx) {
- String path = files->get_item_metadata(p_idx);
- if (path.ends_with("/")) {
- if (path != "res://") {
- path = path.substr(0, path.length() - 1);
+ String fpath = files->get_item_metadata(p_idx);
+ if (fpath.ends_with("/")) {
+ if (fpath != "res://") {
+ fpath = fpath.substr(0, fpath.length() - 1);
}
- this->path = path;
+ path = fpath;
_update_files(false);
current_path->set_text(path);
_push_to_history();
@@ -587,27 +605,19 @@ void FileSystemDock::_select_file(int p_idx) {
void FileSystemDock::_go_to_tree() {
- tree->show();
- file_list_vb->hide();
- _update_tree();
+ if (low_height_mode) {
+ tree->show();
+ button_favorite->show();
+ file_list_vb->hide();
+ }
+
+ _update_tree(true);
tree->grab_focus();
tree->ensure_cursor_is_visible();
- button_favorite->show();
//button_open->hide();
//file_options->hide();
}
-void FileSystemDock::_go_to_dir(const String &p_dir) {
-
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- if (da->change_dir(p_dir) == OK) {
- path = da->get_current_dir();
- _update_files(false);
- }
- current_path->set_text(path);
- memdelete(da);
-}
-
void FileSystemDock::_preview_invalidated(const String &p_path) {
if (display_mode == DISPLAY_THUMBNAILS && p_path.get_base_dir() == path && search_box->get_text() == String() && file_list_vb->is_visible_in_tree()) {
@@ -630,17 +640,15 @@ void FileSystemDock::_preview_invalidated(const String &p_path) {
void FileSystemDock::_fs_changed() {
button_hist_prev->set_disabled(history_pos == 0);
- button_hist_next->set_disabled(history_pos + 1 == history.size());
+ button_hist_next->set_disabled(history_pos == history.size() - 1);
scanning_vb->hide();
split_box->show();
if (tree->is_visible()) {
- button_favorite->show();
- _update_tree();
+ _update_tree(true);
}
if (file_list_vb->is_visible()) {
-
_update_files(true);
}
@@ -649,9 +657,9 @@ void FileSystemDock::_fs_changed() {
void FileSystemDock::_set_scanning_mode() {
- split_box->hide();
button_hist_prev->set_disabled(true);
button_hist_next->set_disabled(true);
+ split_box->hide();
scanning_vb->show();
set_process(true);
if (EditorFileSystem::get_singleton()->is_scanning()) {
@@ -666,55 +674,48 @@ void FileSystemDock::_fw_history() {
if (history_pos < history.size() - 1)
history_pos++;
- path = history[history_pos];
-
- if (tree->is_visible()) {
- _update_tree();
- tree->grab_focus();
- tree->ensure_cursor_is_visible();
- }
-
- if (file_list_vb->is_visible()) {
- _update_files(false);
- current_path->set_text(path);
- }
-
- button_hist_prev->set_disabled(history_pos == 0);
- button_hist_next->set_disabled(history_pos + 1 == history.size());
+ _update_history();
}
void FileSystemDock::_bw_history() {
-
if (history_pos > 0)
history_pos--;
+ _update_history();
+}
+
+void FileSystemDock::_update_history() {
path = history[history_pos];
+ current_path->set_text(path);
if (tree->is_visible()) {
- _update_tree();
+ _update_tree(true);
tree->grab_focus();
tree->ensure_cursor_is_visible();
}
if (file_list_vb->is_visible()) {
_update_files(false);
- current_path->set_text(path);
}
button_hist_prev->set_disabled(history_pos == 0);
- button_hist_next->set_disabled(history_pos + 1 == history.size());
+ button_hist_next->set_disabled(history_pos == history.size() - 1);
}
void FileSystemDock::_push_to_history() {
-
- history.resize(history_pos + 1);
if (history[history_pos] != path) {
+ history.resize(history_pos + 1);
history.push_back(path);
history_pos++;
+
+ if (history.size() > history_max_size) {
+ history.remove(0);
+ history_pos = history_max_size - 1;
+ }
}
button_hist_prev->set_disabled(history_pos == 0);
- button_hist_next->set_disabled(history_pos + 1 == history.size());
+ button_hist_next->set_disabled(history_pos == history.size() - 1);
}
void FileSystemDock::_get_all_files_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files) const {
@@ -903,9 +904,9 @@ void FileSystemDock::_file_option(int p_option) {
for (int i = 0; i < files->get_item_count(); i++) {
if (!files->is_selected(i))
continue;
- String path = files->get_item_metadata(i);
- if (EditorFileSystem::get_singleton()->get_file_type(path) == "PackedScene") {
- paths.push_back(path);
+ String fpath = files->get_item_metadata(i);
+ if (EditorFileSystem::get_singleton()->get_file_type(fpath) == "PackedScene") {
+ paths.push_back(fpath);
}
}
@@ -918,16 +919,16 @@ void FileSystemDock::_file_option(int p_option) {
int idx = files->get_current();
if (idx < 0 || idx >= files->get_item_count())
break;
- String path = files->get_item_metadata(idx);
- deps_editor->edit(path);
+ String fpath = files->get_item_metadata(idx);
+ deps_editor->edit(fpath);
} break;
case FILE_OWNERS: {
int idx = files->get_current();
if (idx < 0 || idx >= files->get_item_count())
break;
- String path = files->get_item_metadata(idx);
- owners_editor->show(path);
+ String fpath = files->get_item_metadata(idx);
+ owners_editor->show(fpath);
} break;
case FILE_MOVE: {
to_move.clear();
@@ -935,8 +936,8 @@ void FileSystemDock::_file_option(int p_option) {
if (!files->is_selected(i))
continue;
- String path = files->get_item_metadata(i);
- to_move.push_back(FileOrFolder(path, !path.ends_with("/")));
+ String fpath = files->get_item_metadata(i);
+ to_move.push_back(FileOrFolder(fpath, !fpath.ends_with("/")));
}
if (to_move.size() > 0) {
move_dialog->popup_centered_ratio();
@@ -968,12 +969,12 @@ void FileSystemDock::_file_option(int p_option) {
Vector<String> remove_folders;
for (int i = 0; i < files->get_item_count(); i++) {
- String path = files->get_item_metadata(i);
- if (files->is_selected(i) && path != "res://") {
- if (path.ends_with("/")) {
- remove_folders.push_back(path);
+ String fpath = files->get_item_metadata(i);
+ if (files->is_selected(i) && fpath != "res://") {
+ if (fpath.ends_with("/")) {
+ remove_folders.push_back(fpath);
} else {
- remove_files.push_back(path);
+ remove_files.push_back(fpath);
}
}
}
@@ -995,8 +996,8 @@ void FileSystemDock::_file_option(int p_option) {
if (!files->is_selected(i))
continue;
- String path = files->get_item_metadata(i);
- reimport.push_back(path);
+ String fpath = files->get_item_metadata(i);
+ reimport.push_back(fpath);
}
ERR_FAIL_COND(reimport.size() == 0);
@@ -1030,34 +1031,38 @@ void FileSystemDock::_file_option(int p_option) {
int idx = files->get_current();
if (idx < 0 || idx >= files->get_item_count())
break;
- String path = files->get_item_metadata(idx);
- OS::get_singleton()->set_clipboard(path);
+ String fpath = files->get_item_metadata(idx);
+ OS::get_singleton()->set_clipboard(fpath);
} break;
}
}
void FileSystemDock::_folder_option(int p_option) {
- TreeItem *item = tree->get_selected();
- TreeItem *child = item->get_children();
+ TreeItem *selected = tree->get_selected();
switch (p_option) {
- case FOLDER_EXPAND_ALL: {
- item->set_collapsed(false);
- while (child) {
- child->set_collapsed(false);
- child = child->get_next();
- }
- } break;
+ case FOLDER_EXPAND_ALL:
case FOLDER_COLLAPSE_ALL: {
- while (child) {
- child->set_collapsed(true);
- child = child->get_next();
+ bool is_collapsed = (p_option == FOLDER_COLLAPSE_ALL);
+ Vector<TreeItem *> needs_check;
+ needs_check.push_back(selected);
+
+ while (needs_check.size()) {
+ needs_check[0]->set_collapsed(is_collapsed);
+
+ TreeItem *child = needs_check[0]->get_children();
+ while (child) {
+ needs_check.push_back(child);
+ child = child->get_next();
+ }
+
+ needs_check.remove(0);
}
} break;
case FOLDER_MOVE: {
to_move.clear();
- String fpath = item->get_metadata(tree->get_selected_column());
+ String fpath = selected->get_metadata(tree->get_selected_column());
if (fpath != "res://") {
fpath = fpath.ends_with("/") ? fpath.substr(0, fpath.length() - 1) : fpath;
to_move.push_back(FileOrFolder(fpath, false));
@@ -1065,7 +1070,7 @@ void FileSystemDock::_folder_option(int p_option) {
}
} break;
case FOLDER_RENAME: {
- to_rename.path = item->get_metadata(tree->get_selected_column());
+ to_rename.path = selected->get_metadata(tree->get_selected_column());
to_rename.is_file = false;
if (to_rename.path != "res://") {
String name = to_rename.path.ends_with("/") ? to_rename.path.substr(0, to_rename.path.length() - 1).get_file() : to_rename.path.get_file();
@@ -1079,9 +1084,9 @@ void FileSystemDock::_folder_option(int p_option) {
case FOLDER_REMOVE: {
Vector<String> remove_folders;
Vector<String> remove_files;
- String path = item->get_metadata(tree->get_selected_column());
- if (path != "res://") {
- remove_folders.push_back(path);
+ String fpath = selected->get_metadata(tree->get_selected_column());
+ if (fpath != "res://") {
+ remove_folders.push_back(fpath);
remove_dialog->show(remove_folders, remove_files);
}
} break;
@@ -1092,31 +1097,20 @@ void FileSystemDock::_folder_option(int p_option) {
make_dir_dialog_text->grab_focus();
} break;
case FOLDER_COPY_PATH: {
- String path = item->get_metadata(tree->get_selected_column());
- OS::get_singleton()->set_clipboard(path);
+ String fpath = selected->get_metadata(tree->get_selected_column());
+ OS::get_singleton()->set_clipboard(fpath);
} break;
case FOLDER_SHOW_IN_EXPLORER: {
- String path = item->get_metadata(tree->get_selected_column());
- String dir = ProjectSettings::get_singleton()->globalize_path(path);
+ String fpath = selected->get_metadata(tree->get_selected_column());
+ String dir = ProjectSettings::get_singleton()->globalize_path(fpath);
OS::get_singleton()->shell_open(String("file://") + dir);
} break;
}
}
-void FileSystemDock::_open_pressed() {
-
- TreeItem *sel = tree->get_selected();
- if (!sel) {
- return;
- }
- path = sel->get_metadata(0);
- /*if (path!="res://" && path.ends_with("/")) {
- path=path.substr(0,path.length()-1);
- }*/
-
- //tree_mode=false;
+void FileSystemDock::_go_to_file_list() {
- if (split_mode) {
+ if (low_height_mode) {
tree->hide();
file_list_vb->show();
button_favorite->hide();
@@ -1125,8 +1119,6 @@ void FileSystemDock::_open_pressed() {
//file_options->show();
_update_files(false);
- current_path->set_text(path);
- _push_to_history();
//emit_signal("open",path);
}
@@ -1158,10 +1150,8 @@ void FileSystemDock::_dir_rmb_pressed(const Vector2 &p_pos) {
void FileSystemDock::_search_changed(const String &p_text) {
- if (!search_box->is_visible_in_tree())
- return; //wtf
-
- _update_files(false);
+ if (file_list_vb->is_visible())
+ _update_files(false);
}
void FileSystemDock::_rescan() {
@@ -1176,7 +1166,7 @@ void FileSystemDock::fix_dependencies(const String &p_for_file) {
void FileSystemDock::focus_on_filter() {
- if (!search_box->is_visible_in_tree()) {
+ if (low_height_mode && tree->is_visible()) {
// Tree mode, switch to files list with search box
tree->hide();
file_list_vb->show();
@@ -1203,13 +1193,13 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
if (!selected)
return Variant();
- String path = selected->get_metadata(0);
- if (path == String())
+ String fpath = selected->get_metadata(0);
+ if (fpath == String())
return Variant();
- if (!path.ends_with("/"))
- path = path + "/";
+ if (!fpath.ends_with("/"))
+ fpath = fpath + "/";
Vector<String> paths;
- paths.push_back(path);
+ paths.push_back(fpath);
Dictionary d = EditorNode::get_singleton()->drag_files(paths, p_from);
if (selected->get_parent() && tree->get_root()->get_children() == selected->get_parent()) {
@@ -1227,8 +1217,8 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
for (int i = 0; i < files->get_item_count(); i++) {
if (files->is_selected(i)) {
- String path = files->get_item_metadata(i);
- if (path.ends_with("/"))
+ String fpath = files->get_item_metadata(i);
+ if (fpath.ends_with("/"))
seldirs.push_back(i);
else
selfiles.push_back(i);
@@ -1249,22 +1239,20 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
}
}*/
- if (selfiles.size() > 0 && seldirs.size() == 0) {
- Vector<String> fnames;
- for (List<int>::Element *E = selfiles.front(); E; E = E->next()) {
- fnames.push_back(files->get_item_metadata(E->get()));
- }
- return EditorNode::get_singleton()->drag_files(fnames, p_from);
- }
-
+ Vector<String> fnames;
if (selfiles.size() > 0 || seldirs.size() > 0) {
- Vector<String> fnames;
- for (List<int>::Element *E = selfiles.front(); E; E = E->next()) {
- fnames.push_back(files->get_item_metadata(E->get()));
+ if (selfiles.size() > 0) {
+ for (List<int>::Element *E = selfiles.front(); E; E = E->next()) {
+ fnames.push_back(files->get_item_metadata(E->get()));
+ }
+ if (seldirs.size() == 0)
+ return EditorNode::get_singleton()->drag_files(fnames, p_from);
}
+
for (List<int>::Element *E = seldirs.front(); E; E = E->next()) {
fnames.push_back(files->get_item_metadata(E->get()));
}
+
return EditorNode::get_singleton()->drag_files_and_dirs(fnames, p_from);
}
}
@@ -1323,9 +1311,9 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da
TreeItem *ti = tree->get_item_at_position(p_point);
if (!ti)
return false;
- String path = ti->get_metadata(0);
- if (path == String())
+ String fpath = ti->get_metadata(0);
+ if (fpath == String())
return false;
return true;
@@ -1399,7 +1387,7 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
}
EditorSettings::get_singleton()->set_favorite_dirs(dirs);
- _update_tree();
+ _update_tree(true);
return;
}
@@ -1415,12 +1403,12 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
TreeItem *ti = tree->get_item_at_position(p_point);
if (!ti)
return;
- String path = ti->get_metadata(0);
- if (path == String())
+ String fpath = ti->get_metadata(0);
+ if (fpath == String())
return;
- EditorNode::get_singleton()->save_resource_as(res, path);
+ EditorNode::get_singleton()->save_resource_as(res, fpath);
return;
}
@@ -1495,14 +1483,14 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) {
continue;
}
- String path = files->get_item_metadata(i);
- if (path.ends_with("/")) {
- foldernames.push_back(path);
+ String fpath = files->get_item_metadata(i);
+ if (fpath.ends_with("/")) {
+ foldernames.push_back(fpath);
all_files = false;
} else {
- filenames.push_back(path);
+ filenames.push_back(fpath);
all_folders = false;
- all_files_scenes &= (EditorFileSystem::get_singleton()->get_file_type(path) == "PackedScene");
+ all_files_scenes &= (EditorFileSystem::get_singleton()->get_file_type(fpath) == "PackedScene");
}
}
@@ -1513,18 +1501,18 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) {
if (all_files_scenes) {
file_options->add_item(TTR("Instance"), FILE_INSTANCE);
}
- file_options->add_separator();
if (filenames.size() == 1) {
+ file_options->add_separator();
file_options->add_item(TTR("Edit Dependencies.."), FILE_DEPENDENCIES);
file_options->add_item(TTR("View Owners.."), FILE_OWNERS);
- file_options->add_separator();
}
} else if (all_folders && foldernames.size() > 0) {
file_options->add_item(TTR("Open"), FILE_OPEN);
- file_options->add_separator();
}
+ file_options->add_separator();
+
int num_items = filenames.size() + foldernames.size();
if (num_items >= 1) {
if (num_items == 1) {
@@ -1545,14 +1533,7 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) {
void FileSystemDock::select_file(const String &p_file) {
- _go_to_dir(p_file.get_base_dir());
- for (int i = 0; i < files->get_item_count(); i++) {
- if (files->get_item_metadata(i) == p_file) {
- files->select(i);
- files->ensure_current_is_visible();
- break;
- }
- }
+ navigate_to_path(p_file);
}
void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) {
@@ -1570,14 +1551,14 @@ void FileSystemDock::_file_selected() {
if (!files->is_selected(i))
continue;
- String p = files->get_item_metadata(i);
- if (!FileAccess::exists(p + ".import")) {
+ String fpath = files->get_item_metadata(i);
+ if (!FileAccess::exists(fpath + ".import")) {
imports.clear();
break;
}
Ref<ConfigFile> cf;
cf.instance();
- Error err = cf->load(p + ".import");
+ Error err = cf->load(fpath + ".import");
if (err != OK) {
imports.clear();
break;
@@ -1591,7 +1572,7 @@ void FileSystemDock::_file_selected() {
imports.clear();
break;
}
- imports.push_back(p);
+ imports.push_back(fpath);
}
if (imports.size() == 0) {
@@ -1609,13 +1590,13 @@ void FileSystemDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_rescan"), &FileSystemDock::_rescan);
ClassDB::bind_method(D_METHOD("_favorites_pressed"), &FileSystemDock::_favorites_pressed);
//ClassDB::bind_method(D_METHOD("_instance_pressed"),&ScenesDock::_instance_pressed);
- ClassDB::bind_method(D_METHOD("_open_pressed"), &FileSystemDock::_open_pressed);
+ ClassDB::bind_method(D_METHOD("_go_to_file_list"), &FileSystemDock::_go_to_file_list);
ClassDB::bind_method(D_METHOD("_dir_rmb_pressed"), &FileSystemDock::_dir_rmb_pressed);
ClassDB::bind_method(D_METHOD("_thumbnail_done"), &FileSystemDock::_thumbnail_done);
ClassDB::bind_method(D_METHOD("_select_file"), &FileSystemDock::_select_file);
ClassDB::bind_method(D_METHOD("_go_to_tree"), &FileSystemDock::_go_to_tree);
- ClassDB::bind_method(D_METHOD("_go_to_dir"), &FileSystemDock::_go_to_dir);
+ ClassDB::bind_method(D_METHOD("navigate_to_path"), &FileSystemDock::navigate_to_path);
ClassDB::bind_method(D_METHOD("_change_file_display"), &FileSystemDock::_change_file_display);
ClassDB::bind_method(D_METHOD("_fw_history"), &FileSystemDock::_fw_history);
ClassDB::bind_method(D_METHOD("_bw_history"), &FileSystemDock::_bw_history);
@@ -1645,21 +1626,22 @@ void FileSystemDock::_bind_methods() {
FileSystemDock::FileSystemDock(EditorNode *p_editor) {
editor = p_editor;
+ path = "res://";
HBoxContainer *toolbar_hbc = memnew(HBoxContainer);
add_child(toolbar_hbc);
button_hist_prev = memnew(ToolButton);
- toolbar_hbc->add_child(button_hist_prev);
button_hist_prev->set_disabled(true);
+ button_hist_prev->set_focus_mode(FOCUS_NONE);
button_hist_prev->set_tooltip(TTR("Previous Directory"));
+ toolbar_hbc->add_child(button_hist_prev);
button_hist_next = memnew(ToolButton);
- toolbar_hbc->add_child(button_hist_next);
button_hist_next->set_disabled(true);
- button_hist_prev->set_focus_mode(FOCUS_NONE);
button_hist_next->set_focus_mode(FOCUS_NONE);
button_hist_next->set_tooltip(TTR("Next Directory"));
+ toolbar_hbc->add_child(button_hist_next);
current_path = memnew(LineEdit);
current_path->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -1668,10 +1650,10 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
button_reload = memnew(Button);
button_reload->set_flat(true);
button_reload->connect("pressed", this, "_rescan");
- toolbar_hbc->add_child(button_reload);
button_reload->set_focus_mode(FOCUS_NONE);
button_reload->set_tooltip(TTR("Re-Scan Filesystem"));
button_reload->hide();
+ toolbar_hbc->add_child(button_reload);
//toolbar_hbc->add_spacer();
@@ -1679,17 +1661,16 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
button_favorite->set_flat(true);
button_favorite->set_toggle_mode(true);
button_favorite->connect("pressed", this, "_favorites_pressed");
- toolbar_hbc->add_child(button_favorite);
button_favorite->set_tooltip(TTR("Toggle folder status as Favorite"));
-
button_favorite->set_focus_mode(FOCUS_NONE);
+ toolbar_hbc->add_child(button_favorite);
//Control *spacer = memnew( Control);
/*
button_open = memnew( Button );
button_open->set_flat(true);
- button_open->connect("pressed",this,"_open_pressed");
+ button_open->connect("pressed",this,"_go_to_file_list");
toolbar_hbc->add_child(button_open);
button_open->hide();
button_open->set_focus_mode(FOCUS_NONE);
@@ -1712,62 +1693,63 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
add_child(folder_options);
split_box = memnew(VSplitContainer);
- add_child(split_box);
split_box->set_v_size_flags(SIZE_EXPAND_FILL);
+ add_child(split_box);
tree = memnew(Tree);
tree->set_hide_root(true);
- split_box->add_child(tree);
tree->set_drag_forwarding(this);
tree->set_allow_rmb_select(true);
+ tree->set_custom_minimum_size(Size2(0, 200 * EDSCALE));
+ split_box->add_child(tree);
- //tree->set_v_size_flags(SIZE_EXPAND_FILL);
tree->connect("item_edited", this, "_favorite_toggled");
- tree->connect("item_activated", this, "_open_pressed");
+ tree->connect("item_activated", this, "_go_to_file_list");
tree->connect("cell_selected", this, "_dir_selected");
tree->connect("item_rmb_selected", this, "_dir_rmb_pressed");
- files = memnew(ItemList);
- files->set_v_size_flags(SIZE_EXPAND_FILL);
- files->set_select_mode(ItemList::SELECT_MULTI);
- files->set_drag_forwarding(this);
- files->connect("item_rmb_selected", this, "_files_list_rmb_select");
- files->connect("item_selected", this, "_file_selected");
- files->connect("multi_selected", this, "_file_multi_selected");
- files->set_allow_rmb_select(true);
-
file_list_vb = memnew(VBoxContainer);
- split_box->add_child(file_list_vb);
file_list_vb->set_v_size_flags(SIZE_EXPAND_FILL);
+ split_box->add_child(file_list_vb);
path_hb = memnew(HBoxContainer);
file_list_vb->add_child(path_hb);
- button_back = memnew(ToolButton);
- path_hb->add_child(button_back);
- button_back->hide();
+ button_tree = memnew(ToolButton);
+ button_tree->hide();
+ path_hb->add_child(button_tree);
search_box = memnew(LineEdit);
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
- path_hb->add_child(search_box);
search_box->connect("text_changed", this, "_search_changed");
+ path_hb->add_child(search_box);
button_display_mode = memnew(ToolButton);
- path_hb->add_child(button_display_mode);
button_display_mode->set_toggle_mode(true);
+ path_hb->add_child(button_display_mode);
+ files = memnew(ItemList);
+ files->set_v_size_flags(SIZE_EXPAND_FILL);
+ files->set_select_mode(ItemList::SELECT_MULTI);
+ files->set_drag_forwarding(this);
+ files->connect("item_rmb_selected", this, "_files_list_rmb_select");
+ files->connect("item_selected", this, "_file_selected");
+ files->connect("multi_selected", this, "_file_multi_selected");
+ files->set_allow_rmb_select(true);
file_list_vb->add_child(files);
scanning_vb = memnew(VBoxContainer);
+ scanning_vb->hide();
+ add_child(scanning_vb);
+
Label *slabel = memnew(Label);
slabel->set_text(TTR("Scanning Files,\nPlease Wait.."));
slabel->set_align(Label::ALIGN_CENTER);
scanning_vb->add_child(slabel);
+
scanning_progress = memnew(ProgressBar);
scanning_vb->add_child(scanning_progress);
- add_child(scanning_vb);
- scanning_vb->hide();
deps_editor = memnew(DependencyEditor);
add_child(deps_editor);
@@ -1779,9 +1761,9 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
add_child(remove_dialog);
move_dialog = memnew(EditorDirDialog);
+ move_dialog->get_ok()->set_text(TTR("Move"));
add_child(move_dialog);
move_dialog->connect("dir_selected", this, "_move_operation_confirm");
- move_dialog->get_ok()->set_text(TTR("Move"));
rename_dialog = memnew(ConfirmationDialog);
VBoxContainer *rename_dialog_vb = memnew(VBoxContainer);
@@ -1808,13 +1790,12 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
updating_tree = false;
initialized = false;
- history.push_back("res://");
history_pos = 0;
+ history_max_size = 20;
+ history.push_back("res://");
- split_mode = false;
+ low_height_mode = false;
display_mode = DISPLAY_THUMBNAILS;
-
- path = "res://";
}
FileSystemDock::~FileSystemDock() {
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index 89b250e295..2cb0573a3d 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -98,7 +98,7 @@ private:
Button *button_reload;
Button *button_favorite;
- Button *button_back;
+ Button *button_tree;
Button *button_display_mode;
Button *button_hist_next;
Button *button_hist_prev;
@@ -107,7 +107,7 @@ private:
TextureRect *search_icon;
HBoxContainer *path_hb;
- bool split_mode;
+ bool low_height_mode;
DisplayMode display_mode;
PopupMenu *file_options;
@@ -138,6 +138,7 @@ private:
Vector<String> history;
int history_pos;
+ int history_max_size;
String path;
@@ -147,15 +148,22 @@ private:
Tree *tree; //directories
ItemList *files;
- void _file_multi_selected(int p_index, bool p_selected);
- void _file_selected();
+ bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths);
+ void _update_tree(bool keep_collapse_state);
+
+ void _update_files(bool p_keep_selection);
+ void _update_file_display_toggle_button();
+ void _change_file_display();
+ void _fs_changed();
void _go_to_tree();
- void _go_to_dir(const String &p_dir);
+ void _go_to_file_list();
+
void _select_file(int p_idx);
+ void _file_multi_selected(int p_index, bool p_selected);
- bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir);
- void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata);
+ void _file_selected();
+ void _dir_selected();
void _get_all_files_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files) const;
void _find_remaps(EditorFileSystemDirectory *efsd, const Map<String, String> &renames, Vector<String> &to_remaps) const;
@@ -168,25 +176,19 @@ private:
void _file_option(int p_option);
void _folder_option(int p_option);
- void _update_files(bool p_keep_selection);
- void _update_file_display_toggle_button();
- void _change_file_display();
- void _fs_changed();
void _fw_history();
void _bw_history();
+ void _update_history();
void _push_to_history();
- void _dir_selected();
- void _update_tree();
- void _rescan();
void _set_scanning_mode();
+ void _rescan();
void _favorites_pressed();
- void _open_pressed();
- void _dir_rmb_pressed(const Vector2 &p_pos);
void _search_changed(const String &p_text);
+ void _dir_rmb_pressed(const Vector2 &p_pos);
void _files_list_rmb_select(int p_item, const Vector2 &p_pos);
struct FileInfo {
@@ -209,6 +211,7 @@ private:
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
void _preview_invalidated(const String &p_path);
+ void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata);
protected:
void _notification(int p_what);
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 3f79d00f80..b21c176543 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -876,6 +876,7 @@ void ProjectSettingsEditor::_action_add() {
r->select(0);
input_editor->ensure_cursor_is_visible();
action_add_error->hide();
+ action_name->clear();
}
void ProjectSettingsEditor::_item_checked(const String &p_item, bool p_check) {
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index 34d01c6beb..b43ec409a1 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -83,6 +83,8 @@ const char *GDFunctions::get_func_name(Function p_func) {
"rad2deg",
"linear2db",
"db2linear",
+ "wrapi",
+ "wrapf",
"max",
"min",
"clamp",
@@ -405,6 +407,14 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
VALIDATE_ARG_NUM(0);
r_ret = Math::db2linear((double)*p_args[0]);
} break;
+ case MATH_WRAP: {
+ VALIDATE_ARG_COUNT(3);
+ r_ret = Math::wrapi((int64_t)*p_args[0], (int64_t)*p_args[1], (int64_t)*p_args[2]);
+ } break;
+ case MATH_WRAPF: {
+ VALIDATE_ARG_COUNT(3);
+ r_ret = Math::wrapf((double)*p_args[0], (double)*p_args[1], (double)*p_args[2]);
+ } break;
case LOGIC_MAX: {
VALIDATE_ARG_COUNT(2);
if (p_args[0]->get_type() == Variant::INT && p_args[1]->get_type() == Variant::INT) {
@@ -1285,6 +1295,8 @@ bool GDFunctions::is_deterministic(Function p_func) {
case MATH_RAD2DEG:
case MATH_LINEAR2DB:
case MATH_DB2LINEAR:
+ case MATH_WRAP:
+ case MATH_WRAPF:
case LOGIC_MAX:
case LOGIC_MIN:
case LOGIC_CLAMP:
@@ -1513,6 +1525,16 @@ MethodInfo GDFunctions::get_info(Function p_func) {
mi.return_val.type = Variant::REAL;
return mi;
} break;
+ case MATH_WRAP: {
+ MethodInfo mi("wrapi", PropertyInfo(Variant::INT, "value"), PropertyInfo(Variant::INT, "min"), PropertyInfo(Variant::INT, "max"));
+ mi.return_val.type = Variant::INT;
+ return mi;
+ } break;
+ case MATH_WRAPF: {
+ MethodInfo mi("wrapf", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "min"), PropertyInfo(Variant::REAL, "max"));
+ mi.return_val.type = Variant::REAL;
+ return mi;
+ } break;
case LOGIC_MAX: {
MethodInfo mi("max", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
mi.return_val.type = Variant::REAL;
diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h
index a568c8f1cf..0de09f2e71 100644
--- a/modules/gdscript/gd_functions.h
+++ b/modules/gdscript/gd_functions.h
@@ -75,6 +75,8 @@ public:
MATH_RAD2DEG,
MATH_LINEAR2DB,
MATH_DB2LINEAR,
+ MATH_WRAP,
+ MATH_WRAPF,
LOGIC_MAX,
LOGIC_MIN,
LOGIC_CLAMP,
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 3d91a6de6c..161e130a07 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -122,6 +122,9 @@ void CSharpLanguage::init() {
void CSharpLanguage::finish() {
+ // Release gchandle bindings before finalizing mono runtime
+ gchandle_bindings.clear();
+
if (gdmono) {
memdelete(gdmono);
gdmono = NULL;
@@ -297,6 +300,20 @@ Ref<Script> CSharpLanguage::get_template(const String &p_class_name, const Strin
return script;
}
+bool CSharpLanguage::is_using_templates() {
+
+ return true;
+}
+
+void CSharpLanguage::make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script) {
+
+ String src = p_script->get_source_code();
+ src = src.replace("%BASE%", p_base_class_name)
+ .replace("%CLASS%", p_class_name)
+ .replace("%TS%", _get_indentation());
+ p_script->set_source_code(src);
+}
+
Script *CSharpLanguage::create_script() const {
return memnew(CSharpScript);
@@ -396,6 +413,25 @@ String CSharpLanguage::make_function(const String &p_class, const String &p_name
#endif
}
+String CSharpLanguage::_get_indentation() const {
+#ifdef TOOLS_ENABLED
+ if (Engine::get_singleton()->is_editor_hint()) {
+ bool use_space_indentation = EDITOR_DEF("text_editor/indent/type", 0);
+
+ if (use_space_indentation) {
+ int indent_size = EDITOR_DEF("text_editor/indent/size", 4);
+
+ String space_indent = "";
+ for (int i = 0; i < indent_size; i++) {
+ space_indent += " ";
+ }
+ return space_indent;
+ }
+ }
+#endif
+ return "\t";
+}
+
void CSharpLanguage::frame() {
const Ref<MonoGCHandle> &task_scheduler_handle = GDMonoUtils::mono_cache.task_scheduler_handle;
@@ -794,6 +830,14 @@ void *CSharpLanguage::alloc_instance_binding_data(Object *p_object) {
void CSharpLanguage::free_instance_binding_data(void *p_data) {
+ if (GDMono::get_singleton() == NULL) {
+#ifdef DEBUG_ENABLED
+ CRASH_COND(!gchandle_bindings.empty());
+#endif
+ // Mono runtime finalized, all the gchandle bindings were already released
+ return;
+ }
+
#ifndef NO_THREADS
script_bind_lock->lock();
#endif
@@ -1411,6 +1455,34 @@ void CSharpScript::_resource_path_changed() {
}
}
+bool CSharpScript::_get(const StringName &p_name, Variant &r_ret) const {
+
+ if (p_name == CSharpLanguage::singleton->string_names._script_source) {
+
+ r_ret = get_source_code();
+ return true;
+ }
+
+ return false;
+}
+
+bool CSharpScript::_set(const StringName &p_name, const Variant &p_value) {
+
+ if (p_name == CSharpLanguage::singleton->string_names._script_source) {
+
+ set_source_code(p_value);
+ reload();
+ return true;
+ }
+
+ return false;
+}
+
+void CSharpScript::_get_property_list(List<PropertyInfo> *p_properties) const {
+
+ p_properties->push_back(PropertyInfo(Variant::STRING, CSharpLanguage::singleton->string_names._script_source, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+}
+
void CSharpScript::_bind_methods() {
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &CSharpScript::_new, MethodInfo(Variant::OBJECT, "new"));
@@ -1984,5 +2056,6 @@ CSharpLanguage::StringNameCache::StringNameCache() {
_set = StaticCString::create("_set");
_get = StaticCString::create("_get");
_notification = StaticCString::create("_notification");
+ _script_source = StaticCString::create("script/source");
dotctor = StaticCString::create(".ctor");
}
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index 65a6450da5..255665b495 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -116,6 +116,9 @@ protected:
Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
virtual void _resource_path_changed();
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ void _get_property_list(List<PropertyInfo> *p_properties) const;
public:
virtual bool can_instance() const;
@@ -228,16 +231,17 @@ class CSharpLanguage : public ScriptLanguage {
StringName _set;
StringName _get;
StringName _notification;
+ StringName _script_source;
StringName dotctor; // .ctor
StringNameCache();
};
- StringNameCache string_names;
-
int lang_idx;
public:
+ StringNameCache string_names;
+
_FORCE_INLINE_ int get_language_index() { return lang_idx; }
void set_language_index(int p_idx);
@@ -266,6 +270,8 @@ public:
virtual void get_comment_delimiters(List<String> *p_delimiters) const;
virtual void get_string_delimiters(List<String> *p_delimiters) const;
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
+ virtual bool is_using_templates();
+ virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script);
/* TODO */ virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const { return true; }
virtual Script *create_script() const;
virtual bool has_named_classes() const;
@@ -273,6 +279,7 @@ public:
/* TODO? */ virtual int find_function(const String &p_function, const String &p_code) const { return -1; }
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
/* TODO? */ Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint) { return ERR_UNAVAILABLE; }
+ virtual String _get_indentation() const;
/* TODO? */ virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {}
/* TODO */ virtual void add_global_constant(const StringName &p_variable, const Variant &p_value) {}
diff --git a/modules/mono/mono_gc_handle.cpp b/modules/mono/mono_gc_handle.cpp
index d3ad968135..e10e06df0e 100644
--- a/modules/mono/mono_gc_handle.cpp
+++ b/modules/mono/mono_gc_handle.cpp
@@ -59,6 +59,10 @@ Ref<MonoGCHandle> MonoGCHandle::create_weak(MonoObject *p_object) {
void MonoGCHandle::release() {
+#ifdef DEBUG_ENABLED
+ CRASH_COND(GDMono::get_singleton() == NULL);
+#endif
+
if (!released && GDMono::get_singleton()->is_runtime_initialized()) {
mono_gchandle_free(handle);
released = true;
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 904a8ae2c7..c997b0f000 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -705,7 +705,7 @@ bool _GodotSharp::is_domain_loaded() {
void _GodotSharp::queue_dispose(Object *p_object) {
- if (Thread::get_main_id() == Thread::get_caller_id() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) {
+ if (GDMonoUtils::is_main_thread() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) {
_dispose_object(p_object);
} else {
#ifndef NO_THREADS
@@ -722,7 +722,7 @@ void _GodotSharp::queue_dispose(Object *p_object) {
void _GodotSharp::queue_dispose(NodePath *p_node_path) {
- if (Thread::get_main_id() == Thread::get_caller_id() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) {
+ if (GDMonoUtils::is_main_thread() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) {
memdelete(p_node_path);
} else {
#ifndef NO_THREADS
@@ -739,7 +739,7 @@ void _GodotSharp::queue_dispose(NodePath *p_node_path) {
void _GodotSharp::queue_dispose(RID *p_rid) {
- if (Thread::get_main_id() == Thread::get_caller_id() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) {
+ if (GDMonoUtils::is_main_thread() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) {
memdelete(p_rid);
} else {
#ifndef NO_THREADS
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index 77a1ef3cb0..01392447f3 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -600,7 +600,7 @@ MonoArray *Array_to_mono_array(const Array &p_array) {
for (int i = 0; i < p_array.size(); i++) {
MonoObject *boxed = variant_to_mono_object(p_array[i]);
- mono_array_set(ret, MonoObject *, i, boxed);
+ mono_array_setref(ret, i, boxed);
}
return ret;
diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h
index e3af57e78a..ebb5d28e4d 100644
--- a/modules/mono/mono_gd/gd_mono_utils.h
+++ b/modules/mono/mono_gd/gd_mono_utils.h
@@ -149,6 +149,10 @@ void attach_current_thread();
void detach_current_thread();
MonoThread *get_current_thread();
+_FORCE_INLINE_ bool is_main_thread() {
+ return mono_domain_get() != NULL && mono_thread_get_main() == mono_thread_current();
+}
+
GDMonoClass *get_object_class(MonoObject *p_object);
GDMonoClass *type_get_proxy_class(const StringName &p_type);
GDMonoClass *get_class_native_base(GDMonoClass *p_class);
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 4b294325dc..7c9d306831 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -78,6 +78,8 @@ const char *VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX
"rad2deg",
"linear2db",
"db2linear",
+ "wrapi",
+ "wrapf",
"max",
"min",
"clamp",
@@ -198,6 +200,8 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) {
case MATH_LERP:
case MATH_INVERSE_LERP:
case MATH_DECTIME:
+ case MATH_WRAP:
+ case MATH_WRAPF:
case LOGIC_CLAMP:
return 3;
case MATH_RANGE_LERP:
@@ -364,6 +368,22 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
case MATH_DB2LINEAR: {
return PropertyInfo(Variant::REAL, "db");
} break;
+ case MATH_WRAP: {
+ if (p_idx == 0)
+ return PropertyInfo(Variant::INT, "value");
+ else if (p_idx == 1)
+ return PropertyInfo(Variant::INT, "min");
+ else
+ return PropertyInfo(Variant::INT, "max");
+ } break;
+ case MATH_WRAPF: {
+ if (p_idx == 0)
+ return PropertyInfo(Variant::REAL, "value");
+ else if (p_idx == 1)
+ return PropertyInfo(Variant::REAL, "min");
+ else
+ return PropertyInfo(Variant::REAL, "max");
+ } break;
case LOGIC_MAX: {
if (p_idx == 0)
return PropertyInfo(Variant::REAL, "a");
@@ -549,9 +569,13 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
case MATH_DEG2RAD:
case MATH_RAD2DEG:
case MATH_LINEAR2DB:
+ case MATH_WRAPF:
case MATH_DB2LINEAR: {
t = Variant::REAL;
} break;
+ case MATH_WRAP: {
+ t = Variant::INT;
+ } break;
case LOGIC_MAX:
case LOGIC_MIN:
case LOGIC_CLAMP: {
@@ -898,6 +922,18 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
VALIDATE_ARG_NUM(0);
*r_return = Math::db2linear((double)*p_inputs[0]);
} break;
+ case VisualScriptBuiltinFunc::MATH_WRAP: {
+ VALIDATE_ARG_NUM(0);
+ VALIDATE_ARG_NUM(1);
+ VALIDATE_ARG_NUM(2);
+ *r_return = Math::wrapi((int64_t)*p_inputs[0], (int64_t)*p_inputs[1], (int64_t)*p_inputs[2]);
+ } break;
+ case VisualScriptBuiltinFunc::MATH_WRAPF: {
+ VALIDATE_ARG_NUM(0);
+ VALIDATE_ARG_NUM(1);
+ VALIDATE_ARG_NUM(2);
+ *r_return = Math::wrapf((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
+ } break;
case VisualScriptBuiltinFunc::LOGIC_MAX: {
if (p_inputs[0]->get_type() == Variant::INT && p_inputs[1]->get_type() == Variant::INT) {
@@ -1258,6 +1294,8 @@ void VisualScriptBuiltinFunc::_bind_methods() {
BIND_ENUM_CONSTANT(MATH_RAD2DEG);
BIND_ENUM_CONSTANT(MATH_LINEAR2DB);
BIND_ENUM_CONSTANT(MATH_DB2LINEAR);
+ BIND_ENUM_CONSTANT(MATH_WRAP);
+ BIND_ENUM_CONSTANT(MATH_WRAPF);
BIND_ENUM_CONSTANT(LOGIC_MAX);
BIND_ENUM_CONSTANT(LOGIC_MIN);
BIND_ENUM_CONSTANT(LOGIC_CLAMP);
@@ -1343,6 +1381,8 @@ void register_visual_script_builtin_func_node() {
VisualScriptLanguage::singleton->add_register_func("functions/built_in/rad2deg", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RAD2DEG>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/linear2db", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LINEAR2DB>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/db2linear", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DB2LINEAR>);
+ VisualScriptLanguage::singleton->add_register_func("functions/built_in/wrapi", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_WRAP>);
+ VisualScriptLanguage::singleton->add_register_func("functions/built_in/wrapf", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_WRAPF>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/max", create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_MAX>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/min", create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_MIN>);
diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h
index 5758d23e8f..34a2825938 100644
--- a/modules/visual_script/visual_script_builtin_funcs.h
+++ b/modules/visual_script/visual_script_builtin_funcs.h
@@ -77,6 +77,8 @@ public:
MATH_RAD2DEG,
MATH_LINEAR2DB,
MATH_DB2LINEAR,
+ MATH_WRAP,
+ MATH_WRAPF,
LOGIC_MAX,
LOGIC_MIN,
LOGIC_CLAMP,
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 69bad1623f..b98cdcc365 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -33,19 +33,49 @@
#include "physics_body_2d.h"
#include "servers/physics_2d_server.h"
-void Joint2D::_update_joint() {
-
- if (!is_inside_tree())
- return;
+void Joint2D::_update_joint(bool p_only_free) {
if (joint.is_valid()) {
+ if (ba.is_valid() && bb.is_valid())
+ Physics2DServer::get_singleton()->body_remove_collision_exception(ba, bb);
+
Physics2DServer::get_singleton()->free(joint);
+ joint = RID();
+ ba = RID();
+ bb = RID();
}
- joint = RID();
+ if (p_only_free || !is_inside_tree())
+ return;
+
+ Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
+ Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
+
+ if (!node_a || !node_b)
+ return;
+
+ PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a);
+ PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b);
+
+ if (!body_a || !body_b)
+ return;
+
+ if (!body_a) {
+ SWAP(body_a, body_b);
+ }
+
+ joint = _configure_joint(body_a, body_b);
+
+ if (!joint.is_valid())
+ return;
- joint = _configure_joint();
Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint, Physics2DServer::JOINT_PARAM_BIAS, bias);
+
+ ba = body_a->get_rid();
+ bb = body_b->get_rid();
+
+ if (exclude_from_collision)
+ Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
}
void Joint2D::set_node_a(const NodePath &p_node_a) {
@@ -83,9 +113,7 @@ void Joint2D::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
if (joint.is_valid()) {
-
- Physics2DServer::get_singleton()->free(joint);
- joint = RID();
+ _update_joint(true);
}
} break;
}
@@ -164,29 +192,8 @@ void PinJoint2D::_notification(int p_what) {
}
}
-RID PinJoint2D::_configure_joint() {
-
- Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
- Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
-
- if (!node_a && !node_b)
- return RID();
+RID PinJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b) {
- PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a);
- PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b);
-
- if (!body_a && !body_b)
- return RID();
-
- if (!body_a) {
- SWAP(body_a, body_b);
- } else if (body_b) {
- //add a collision exception between both
- if (get_exclude_nodes_from_collision())
- Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
- else
- Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(), body_b->get_rid());
- }
RID pj = Physics2DServer::get_singleton()->pin_joint_create(get_global_transform().get_origin(), body_a->get_rid(), body_b ? body_b->get_rid() : RID());
Physics2DServer::get_singleton()->pin_joint_set_param(pj, Physics2DServer::PIN_JOINT_SOFTNESS, softness);
return pj;
@@ -241,24 +248,7 @@ void GrooveJoint2D::_notification(int p_what) {
}
}
-RID GrooveJoint2D::_configure_joint() {
-
- Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
- Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
-
- if (!node_a || !node_b)
- return RID();
-
- PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a);
- PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b);
-
- if (!body_a || !body_b)
- return RID();
-
- if (get_exclude_nodes_from_collision())
- Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
- else
- Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(), body_b->get_rid());
+RID GrooveJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b) {
Transform2D gt = get_global_transform();
Vector2 groove_A1 = gt.get_origin();
@@ -330,24 +320,7 @@ void DampedSpringJoint2D::_notification(int p_what) {
}
}
-RID DampedSpringJoint2D::_configure_joint() {
-
- Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
- Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
-
- if (!node_a || !node_b)
- return RID();
-
- PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a);
- PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b);
-
- if (!body_a || !body_b)
- return RID();
-
- if (get_exclude_nodes_from_collision())
- Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
- else
- Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(), body_b->get_rid());
+RID DampedSpringJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b) {
Transform2D gt = get_global_transform();
Vector2 anchor_A = gt.get_origin();
diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h
index 685299abc6..a6292be51c 100644
--- a/scene/2d/joints_2d.h
+++ b/scene/2d/joints_2d.h
@@ -32,11 +32,14 @@
#include "node_2d.h"
+class PhysicsBody2D;
+
class Joint2D : public Node2D {
GDCLASS(Joint2D, Node2D);
RID joint;
+ RID ba, bb;
NodePath a;
NodePath b;
@@ -45,10 +48,10 @@ class Joint2D : public Node2D {
bool exclude_from_collision;
protected:
- void _update_joint();
+ void _update_joint(bool p_only_free = false);
void _notification(int p_what);
- virtual RID _configure_joint() = 0;
+ virtual RID _configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b) = 0;
static void _bind_methods();
@@ -77,7 +80,7 @@ class PinJoint2D : public Joint2D {
protected:
void _notification(int p_what);
- virtual RID _configure_joint();
+ virtual RID _configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b);
static void _bind_methods();
public:
@@ -96,7 +99,7 @@ class GrooveJoint2D : public Joint2D {
protected:
void _notification(int p_what);
- virtual RID _configure_joint();
+ virtual RID _configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b);
static void _bind_methods();
public:
@@ -120,7 +123,7 @@ class DampedSpringJoint2D : public Joint2D {
protected:
void _notification(int p_what);
- virtual RID _configure_joint();
+ virtual RID _configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b);
static void _bind_methods();
public:
diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp
index aa127ab79f..1d779d31fe 100644
--- a/scene/3d/physics_joint.cpp
+++ b/scene/3d/physics_joint.cpp
@@ -32,13 +32,8 @@
void Joint::_update_joint(bool p_only_free) {
if (joint.is_valid()) {
- if (ba.is_valid() && bb.is_valid()) {
-
- if (exclude_from_collision)
- PhysicsServer::get_singleton()->body_add_collision_exception(ba, bb);
- else
- PhysicsServer::get_singleton()->body_remove_collision_exception(ba, bb);
- }
+ if (ba.is_valid() && bb.is_valid())
+ PhysicsServer::get_singleton()->body_remove_collision_exception(ba, bb);
PhysicsServer::get_singleton()->free(joint);
joint = RID();
@@ -52,33 +47,31 @@ void Joint::_update_joint(bool p_only_free) {
Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
- if (!node_a && !node_b)
+ if (!node_a || !node_b)
return;
PhysicsBody *body_a = Object::cast_to<PhysicsBody>(node_a);
PhysicsBody *body_b = Object::cast_to<PhysicsBody>(node_b);
- if (!body_a && !body_b)
+ if (!body_a || !body_b)
return;
if (!body_a) {
SWAP(body_a, body_b);
- } else if (body_b) {
- //add a collision exception between both
- PhysicsServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
}
joint = _configure_joint(body_a, body_b);
- if (joint.is_valid())
- PhysicsServer::get_singleton()->joint_set_solver_priority(joint, solver_priority);
+ if (!joint.is_valid())
+ return;
+
+ PhysicsServer::get_singleton()->joint_set_solver_priority(joint, solver_priority);
- if (body_b && joint.is_valid()) {
+ ba = body_a->get_rid();
+ bb = body_b->get_rid();
- ba = body_a->get_rid();
- bb = body_b->get_rid();
+ if (exclude_from_collision)
PhysicsServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
- }
}
void Joint::set_node_a(const NodePath &p_node_a) {
@@ -129,8 +122,6 @@ void Joint::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
if (joint.is_valid()) {
_update_joint(true);
- //PhysicsServer::get_singleton()->free(joint);
- joint = RID();
}
} break;
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 2d55c077f1..ee7762b668 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2188,7 +2188,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
}
-
+ begin_complex_operation();
bool first_line = false;
if (k->get_command()) {
if (k->get_shift()) {
@@ -2204,8 +2204,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
- _insert_text_at_cursor(ins);
- _push_current_op();
+ insert_text_at_cursor(ins);
if (first_line) {
cursor_set_line(0);
@@ -2213,7 +2212,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
cursor_set_line(cursor.line - 1);
cursor_set_column(text[cursor.line].length());
}
-
+ end_complex_operation();
} break;
case KEY_ESCAPE: {
if (completion_hint != "") {
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 18b7014595..697abead68 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -226,7 +226,7 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) {
static int total = 0;
ticks = OS::get_singleton()->get_ticks_msec();
- if ((ticks - first_ticks) > 10 * 1000) {
+ if ((ticks - first_ticks) > 10 * 1000 && count > 0) {
print_line("Audio Driver " + String(AudioDriver::get_singleton()->get_name()) + " average latency: " + itos(total / count) + "ms (frame=" + itos(p_frames) + ")");
first_ticks = ticks;
total = 0;
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp
index 46a5192e52..6ced004118 100644
--- a/servers/physics/body_sw.cpp
+++ b/servers/physics/body_sw.cpp
@@ -45,8 +45,9 @@ void BodySW::_update_transform_dependant() {
// update inertia tensor
Basis tb = principal_inertia_axes;
Basis tbt = tb.transposed();
- tb.scale(_inv_inertia);
- _inv_inertia_tensor = tb * tbt;
+ Basis diag;
+ diag.scale(_inv_inertia);
+ _inv_inertia_tensor = tb * diag * tbt;
}
void BodySW::update_inertias() {
diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics/joints/generic_6dof_joint_sw.cpp
index 70cc549e2d..1e323be36c 100644
--- a/servers/physics/joints/generic_6dof_joint_sw.cpp
+++ b/servers/physics/joints/generic_6dof_joint_sw.cpp
@@ -219,9 +219,9 @@ Generic6DOFJointSW::Generic6DOFJointSW(BodySW *rbA, BodySW *rbB, const Transform
}
void Generic6DOFJointSW::calculateAngleInfo() {
- Basis relative_frame = m_calculatedTransformA.basis.inverse() * m_calculatedTransformB.basis;
+ Basis relative_frame = m_calculatedTransformB.basis.inverse() * m_calculatedTransformA.basis;
- m_calculatedAxisAngleDiff = relative_frame.get_euler();
+ m_calculatedAxisAngleDiff = relative_frame.get_euler_xyz();
// in euler angle mode we do not actually constrain the angular velocity
// along the axes axis[0] and axis[2] (although we do use axis[1]) :
diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp
index a7c31cf16c..5ba935d47c 100644
--- a/servers/physics/physics_server_sw.cpp
+++ b/servers/physics/physics_server_sw.cpp
@@ -233,14 +233,7 @@ void PhysicsServerSW::area_set_space(RID p_area, RID p_space) {
if (area->get_space() == space)
return; //pointless
- for (Set<ConstraintSW *>::Element *E = area->get_constraints().front(); E; E = E->next()) {
- RID self = E->get()->get_self();
- if (!self.is_valid())
- continue;
- free(self);
- }
area->clear_constraints();
-
area->set_space(space);
};
@@ -494,14 +487,7 @@ void PhysicsServerSW::body_set_space(RID p_body, RID p_space) {
if (body->get_space() == space)
return; //pointless
- for (Map<ConstraintSW *, int>::Element *E = body->get_constraint_map().front(); E; E = E->next()) {
- RID self = E->key()->get_self();
- if (!self.is_valid())
- continue;
- free(self);
- }
body->clear_constraint_map();
-
body->set_space(space);
};
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index df3bf72a31..5d3305c82d 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -299,14 +299,7 @@ void Physics2DServerSW::area_set_space(RID p_area, RID p_space) {
if (area->get_space() == space)
return; //pointless
- for (Set<Constraint2DSW *>::Element *E = area->get_constraints().front(); E; E = E->next()) {
- RID self = E->get()->get_self();
- if (!self.is_valid())
- continue;
- free(self);
- }
area->clear_constraints();
-
area->set_space(space);
};
@@ -551,14 +544,7 @@ void Physics2DServerSW::body_set_space(RID p_body, RID p_space) {
if (body->get_space() == space)
return; //pointless
- for (Map<Constraint2DSW *, int>::Element *E = body->get_constraint_map().front(); E; E = E->next()) {
- RID self = E->key()->get_self();
- if (!self.is_valid())
- continue;
- free(self);
- }
body->clear_constraint_map();
-
body->set_space(space);
};