diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdnative/include/gdnative/variant.h | 14 | ||||
-rw-r--r-- | modules/gdnavigation/gd_navigation_server.cpp | 23 | ||||
-rw-r--r-- | modules/gdnavigation/gd_navigation_server.h | 4 | ||||
-rw-r--r-- | modules/gdnavigation/nav_map.cpp | 7 | ||||
-rw-r--r-- | modules/gdscript/language_server/gdscript_workspace.cpp | 49 | ||||
-rw-r--r-- | modules/gdscript/language_server/gdscript_workspace.h | 5 |
6 files changed, 85 insertions, 17 deletions
diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h index 4d70f1143c..934e856fbf 100644 --- a/modules/gdnative/include/gdnative/variant.h +++ b/modules/gdnative/include/gdnative/variant.h @@ -56,31 +56,33 @@ typedef enum godot_variant_type { GODOT_VARIANT_TYPE_STRING, // math types - - GODOT_VARIANT_TYPE_VECTOR2, // 5 + GODOT_VARIANT_TYPE_VECTOR2, + GODOT_VARIANT_TYPE_VECTOR2I, GODOT_VARIANT_TYPE_RECT2, + GODOT_VARIANT_TYPE_RECT2I, GODOT_VARIANT_TYPE_VECTOR3, + GODOT_VARIANT_TYPE_VECTOR3I, GODOT_VARIANT_TYPE_TRANSFORM2D, GODOT_VARIANT_TYPE_PLANE, - GODOT_VARIANT_TYPE_QUAT, // 10 + GODOT_VARIANT_TYPE_QUAT, GODOT_VARIANT_TYPE_AABB, GODOT_VARIANT_TYPE_BASIS, GODOT_VARIANT_TYPE_TRANSFORM, // misc types GODOT_VARIANT_TYPE_COLOR, - GODOT_VARIANT_TYPE_NODE_PATH, // 15 + GODOT_VARIANT_TYPE_NODE_PATH, GODOT_VARIANT_TYPE_RID, GODOT_VARIANT_TYPE_OBJECT, GODOT_VARIANT_TYPE_DICTIONARY, - GODOT_VARIANT_TYPE_ARRAY, // 20 + GODOT_VARIANT_TYPE_ARRAY, // arrays GODOT_VARIANT_TYPE_PACKED_BYTE_ARRAY, GODOT_VARIANT_TYPE_PACKED_INT_ARRAY, GODOT_VARIANT_TYPE_PACKED_REAL_ARRAY, GODOT_VARIANT_TYPE_PACKED_STRING_ARRAY, - GODOT_VARIANT_TYPE_PACKED_VECTOR2_ARRAY, // 25 + GODOT_VARIANT_TYPE_PACKED_VECTOR2_ARRAY, GODOT_VARIANT_TYPE_PACKED_VECTOR3_ARRAY, GODOT_VARIANT_TYPE_PACKED_COLOR_ARRAY, } godot_variant_type; diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp index 1f1783802d..4129d1f65a 100644 --- a/modules/gdnavigation/gd_navigation_server.cpp +++ b/modules/gdnavigation/gd_navigation_server.cpp @@ -121,6 +121,7 @@ GdNavigationServer::GdNavigationServer() : } GdNavigationServer::~GdNavigationServer() { + flush_queries(); memdelete(operations_mutex); memdelete(commands_mutex); } @@ -474,12 +475,9 @@ void GdNavigationServer::set_active(bool p_active) const { mut_this->operations_mutex->unlock(); } -void GdNavigationServer::step(real_t p_delta_time) { - if (!active) { - return; - } - - // With c++ we can't be 100% sure this is called in single thread so use the mutex. +void GdNavigationServer::flush_queries() { + // In c++ we can't be sure that this is performed in the main thread + // even with mutable functions. commands_mutex->lock(); operations_mutex->lock(); for (size_t i(0); i < commands.size(); i++) { @@ -489,13 +487,24 @@ void GdNavigationServer::step(real_t p_delta_time) { commands.clear(); operations_mutex->unlock(); commands_mutex->unlock(); +} + +void GdNavigationServer::process(real_t p_delta_time) { + flush_queries(); - // These are internal operations so don't need to be shielded. + if (!active) { + return; + } + + // In c++ we can't be sure that this is performed in the main thread + // even with mutable functions. + operations_mutex->lock(); for (int i(0); i < active_maps.size(); i++) { active_maps[i]->sync(); active_maps[i]->step(p_delta_time); active_maps[i]->dispatch_callbacks(); } + operations_mutex->unlock(); } #undef COMMAND_1 diff --git a/modules/gdnavigation/gd_navigation_server.h b/modules/gdnavigation/gd_navigation_server.h index 7fa5979c31..0400acf1a3 100644 --- a/modules/gdnavigation/gd_navigation_server.h +++ b/modules/gdnavigation/gd_navigation_server.h @@ -131,7 +131,9 @@ public: COMMAND_1(free, RID, p_object); virtual void set_active(bool p_active) const; - virtual void step(real_t p_delta_time); + + void flush_queries(); + virtual void process(real_t p_delta_time); }; #undef COMMAND_1 diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp index d3e2f8f388..c3880f89b6 100644 --- a/modules/gdnavigation/nav_map.cpp +++ b/modules/gdnavigation/nav_map.cpp @@ -545,8 +545,11 @@ void NavMap::add_region(NavRegion *p_region) { } void NavMap::remove_region(NavRegion *p_region) { - regions.push_back(p_region); - regenerate_links = true; + std::vector<NavRegion *>::iterator it = std::find(regions.begin(), regions.end(), p_region); + if (it != regions.end()) { + regions.erase(it); + regenerate_links = true; + } } bool NavMap::has_agent(RvoAgent *agent) const { diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 1c0590cff1..ea54784f96 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -33,8 +33,11 @@ #include "../gdscript_parser.h" #include "core/project_settings.h" #include "core/script_language.h" +#include "editor/editor_file_system.h" #include "editor/editor_help.h" +#include "editor/editor_node.h" #include "gdscript_language_protocol.h" +#include "scene/resources/packed_scene.h" void GDScriptWorkspace::_bind_methods() { ClassDB::bind_method(D_METHOD("symbol"), &GDScriptWorkspace::symbol); @@ -373,6 +376,46 @@ void GDScriptWorkspace::publish_diagnostics(const String &p_path) { GDScriptLanguageProtocol::get_singleton()->notify_client("textDocument/publishDiagnostics", params); } +void GDScriptWorkspace::_get_owners(EditorFileSystemDirectory *efsd, String p_path, List<String> &owners) { + if (!efsd) + return; + + for (int i = 0; i < efsd->get_subdir_count(); i++) { + _get_owners(efsd->get_subdir(i), p_path, owners); + } + + for (int i = 0; i < efsd->get_file_count(); i++) { + + Vector<String> deps = efsd->get_file_deps(i); + bool found = false; + for (int j = 0; j < deps.size(); j++) { + if (deps[j] == p_path) { + found = true; + break; + } + } + if (!found) + continue; + + owners.push_back(efsd->get_file_path(i)); + } +} + +Node *GDScriptWorkspace::_get_owner_node(String p_path) { + Node *owner_node = NULL; + List<String> owners; + + _get_owners(EditorFileSystem::get_singleton()->get_filesystem(), p_path, owners); + + if (owners.size() > 0) { + NodePath owner_path = owners[0]; + Ref<PackedScene> owner_res = ResourceLoader::load(owner_path); + owner_node = owner_res->instance(PackedScene::GEN_EDIT_STATE_DISABLED); + } + + return owner_node; +} + void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options) { String path = get_file_path(p_params.textDocument.uri); @@ -380,8 +423,12 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S bool forced = false; if (const ExtendGDScriptParser *parser = get_parse_result(path)) { + Node *owner_node = _get_owner_node(path); String code = parser->get_text_for_completion(p_params.position); - GDScriptLanguage::get_singleton()->complete_code(code, path, NULL, r_options, forced, call_hint); + GDScriptLanguage::get_singleton()->complete_code(code, path, owner_node, r_options, forced, call_hint); + if (owner_node) { + memdelete(owner_node); + } } } diff --git a/modules/gdscript/language_server/gdscript_workspace.h b/modules/gdscript/language_server/gdscript_workspace.h index 146a5cb7c9..8b46d345d9 100644 --- a/modules/gdscript/language_server/gdscript_workspace.h +++ b/modules/gdscript/language_server/gdscript_workspace.h @@ -33,12 +33,17 @@ #include "../gdscript_parser.h" #include "core/variant.h" +#include "editor/editor_file_system.h" #include "gdscript_extend_parser.h" #include "lsp.hpp" class GDScriptWorkspace : public Reference { GDCLASS(GDScriptWorkspace, Reference); +private: + void _get_owners(EditorFileSystemDirectory *efsd, String p_path, List<String> &owners); + Node *_get_owner_node(String p_path); + protected: static void _bind_methods(); void remove_cache_parser(const String &p_path); |