diff options
Diffstat (limited to 'modules')
41 files changed, 927 insertions, 360 deletions
diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h index 6ac71b6946..bb7c8be431 100644 --- a/modules/csg/csg_shape.h +++ b/modules/csg/csg_shape.h @@ -35,7 +35,7 @@ #include "scene/3d/path_3d.h" #include "scene/3d/visual_instance_3d.h" -#include "scene/resources/concave_polygon_shape_3d.h" +#include "scene/resources/3d/concave_polygon_shape_3d.h" #include "thirdparty/misc/mikktspace.h" diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 20d7fdb601..2d6c0c1d11 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1405,16 +1405,11 @@ String GDScript::debug_get_script_name(const Ref<Script> &p_script) { } #endif -bool GDScript::is_equal_gdscript_paths(const String &p_path_a, const String &p_path_b) { - String path_a = p_path_a; - if (path_a.get_extension() == "gdc") { - path_a = path_a.get_basename() + ".gd"; +String GDScript::canonicalize_path(const String &p_path) { + if (p_path.get_extension() == "gdc") { + return p_path.get_basename() + ".gd"; } - String path_b = p_path_b; - if (path_b.get_extension() == "gdc") { - path_b = path_b.get_basename() + ".gd"; - } - return path_a == path_b; + return p_path; } GDScript::UpdatableFuncPtr::UpdatableFuncPtr(GDScriptFunction *p_function) { diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index 981cbb3734..7c471c285b 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -230,7 +230,10 @@ public: static String debug_get_script_name(const Ref<Script> &p_script); #endif - static bool is_equal_gdscript_paths(const String &p_path_a, const String &p_path_b); + static String canonicalize_path(const String &p_path); + _FORCE_INLINE_ static bool is_canonically_equal_paths(const String &p_path_a, const String &p_path_b) { + return canonicalize_path(p_path_a) == canonicalize_path(p_path_b); + } _FORCE_INLINE_ StringName get_local_name() const { return local_name; } diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 6f45aca8b8..98d4a19a87 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -361,7 +361,7 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c push_error(vformat(R"(Class "%s" hides a built-in type.)", class_name), p_class->identifier); } else if (class_exists(class_name)) { push_error(vformat(R"(Class "%s" hides a native class.)", class_name), p_class->identifier); - } else if (ScriptServer::is_global_class(class_name) && (!GDScript::is_equal_gdscript_paths(ScriptServer::get_global_class_path(class_name), parser->script_path) || p_class != parser->head)) { + } else if (ScriptServer::is_global_class(class_name) && (!GDScript::is_canonically_equal_paths(ScriptServer::get_global_class_path(class_name), parser->script_path) || p_class != parser->head)) { push_error(vformat(R"(Class "%s" hides a global script class.)", class_name), p_class->identifier); } else if (ProjectSettings::get_singleton()->has_autoload(class_name) && ProjectSettings::get_singleton()->get_autoload(class_name).is_singleton) { push_error(vformat(R"(Class "%s" hides an autoload singleton.)", class_name), p_class->identifier); @@ -425,7 +425,7 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c if (ScriptServer::is_global_class(name)) { String base_path = ScriptServer::get_global_class_path(name); - if (GDScript::is_equal_gdscript_paths(base_path, parser->script_path)) { + if (GDScript::is_canonically_equal_paths(base_path, parser->script_path)) { base = parser->head->get_datatype(); } else { Ref<GDScriptParserRef> base_parser = get_parser_for(base_path); @@ -698,7 +698,7 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type result.builtin_type = Variant::OBJECT; result.native_type = first; } else if (ScriptServer::is_global_class(first)) { - if (GDScript::is_equal_gdscript_paths(parser->script_path, ScriptServer::get_global_class_path(first))) { + if (GDScript::is_canonically_equal_paths(parser->script_path, ScriptServer::get_global_class_path(first))) { result = parser->head->get_datatype(); } else { String path = ScriptServer::get_global_class_path(first); @@ -4219,8 +4219,8 @@ void GDScriptAnalyzer::reduce_preload(GDScriptParser::PreloadNode *p_preload) { } else { // TODO: Don't load if validating: use completion cache. - // Must load GDScript and PackedScenes separately to permit cyclic references - // as ResourceLoader::load() detect and reject those. + // Must load GDScript separately to permit cyclic references + // as ResourceLoader::load() detects and rejects those. if (ResourceLoader::get_resource_type(p_preload->resolved_path) == "GDScript") { Error err = OK; Ref<GDScript> res = GDScriptCache::get_shallow_script(p_preload->resolved_path, err, parser->script_path); @@ -4228,13 +4228,6 @@ void GDScriptAnalyzer::reduce_preload(GDScriptParser::PreloadNode *p_preload) { if (err != OK) { push_error(vformat(R"(Could not preload resource script "%s".)", p_preload->resolved_path), p_preload->path); } - } else if (ResourceLoader::get_resource_type(p_preload->resolved_path) == "PackedScene") { - Error err = OK; - Ref<PackedScene> res = GDScriptCache::get_packed_scene(p_preload->resolved_path, err, parser->script_path); - p_preload->resource = res; - if (err != OK) { - push_error(vformat(R"(Could not preload resource scene "%s".)", p_preload->resolved_path), p_preload->path); - } } else { p_preload->resource = ResourceLoader::load(p_preload->resolved_path); if (p_preload->resource.is_null()) { diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index ef783ab564..7c27127dce 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -37,7 +37,6 @@ #include "core/io/file_access.h" #include "core/templates/vector.h" -#include "scene/resources/packed_scene.h" bool GDScriptParserRef::is_valid() const { return parser != nullptr; @@ -144,13 +143,6 @@ void GDScriptCache::move_script(const String &p_from, const String &p_to) { return; } - for (KeyValue<String, HashSet<String>> &E : singleton->packed_scene_dependencies) { - if (E.value.has(p_from)) { - E.value.insert(p_to); - E.value.erase(p_from); - } - } - if (singleton->parser_map.has(p_from) && !p_from.is_empty()) { singleton->parser_map[p_to] = singleton->parser_map[p_from]; } @@ -178,15 +170,6 @@ void GDScriptCache::remove_script(const String &p_path) { return; } - for (KeyValue<String, HashSet<String>> &E : singleton->packed_scene_dependencies) { - if (!E.value.has(p_path)) { - continue; - } - E.value.erase(p_path); - } - - GDScriptCache::clear_unreferenced_packed_scenes(); - if (singleton->parser_map.has(p_path)) { singleton->parser_map[p_path]->clear(); singleton->parser_map.erase(p_path); @@ -400,62 +383,6 @@ void GDScriptCache::remove_static_script(const String &p_fqcn) { singleton->static_gdscript_cache.erase(p_fqcn); } -Ref<PackedScene> GDScriptCache::get_packed_scene(const String &p_path, Error &r_error, const String &p_owner) { - MutexLock lock(singleton->mutex); - - String path = p_path; - if (path.begins_with("uid://")) { - path = ResourceUID::get_singleton()->get_id_path(ResourceUID::get_singleton()->text_to_id(path)); - } - - if (singleton->packed_scene_cache.has(path)) { - singleton->packed_scene_dependencies[path].insert(p_owner); - return singleton->packed_scene_cache[path]; - } - - Ref<PackedScene> scene = ResourceCache::get_ref(path); - if (scene.is_valid()) { - singleton->packed_scene_cache[path] = scene; - singleton->packed_scene_dependencies[path].insert(p_owner); - return scene; - } - scene.instantiate(); - - r_error = OK; - if (path.is_empty()) { - r_error = ERR_FILE_BAD_PATH; - return scene; - } - - scene->set_path(path); - singleton->packed_scene_cache[path] = scene; - singleton->packed_scene_dependencies[path].insert(p_owner); - - scene->reload_from_file(); - return scene; -} - -void GDScriptCache::clear_unreferenced_packed_scenes() { - if (singleton == nullptr) { - return; - } - - MutexLock lock(singleton->mutex); - - if (singleton->cleared) { - return; - } - - for (KeyValue<String, HashSet<String>> &E : singleton->packed_scene_dependencies) { - if (E.value.size() > 0 || !ResourceLoader::is_imported(E.key)) { - continue; - } - - singleton->packed_scene_dependencies.erase(E.key); - singleton->packed_scene_cache.erase(E.key); - } -} - void GDScriptCache::clear() { if (singleton == nullptr) { return; @@ -478,16 +405,10 @@ void GDScriptCache::clear() { E->clear(); } - singleton->packed_scene_dependencies.clear(); - singleton->packed_scene_cache.clear(); - parser_map_refs.clear(); singleton->parser_map.clear(); singleton->shallow_gdscript_cache.clear(); singleton->full_gdscript_cache.clear(); - - singleton->packed_scene_cache.clear(); - singleton->packed_scene_dependencies.clear(); } GDScriptCache::GDScriptCache() { diff --git a/modules/gdscript/gdscript_cache.h b/modules/gdscript/gdscript_cache.h index 0754e9feb6..fc7abbd46e 100644 --- a/modules/gdscript/gdscript_cache.h +++ b/modules/gdscript/gdscript_cache.h @@ -37,7 +37,6 @@ #include "core/os/mutex.h" #include "core/templates/hash_map.h" #include "core/templates/hash_set.h" -#include "scene/resources/packed_scene.h" class GDScriptAnalyzer; class GDScriptParser; @@ -81,8 +80,6 @@ class GDScriptCache { HashMap<String, Ref<GDScript>> full_gdscript_cache; HashMap<String, Ref<GDScript>> static_gdscript_cache; HashMap<String, HashSet<String>> dependencies; - HashMap<String, Ref<PackedScene>> packed_scene_cache; - HashMap<String, HashSet<String>> packed_scene_dependencies; friend class GDScript; friend class GDScriptParserRef; @@ -107,9 +104,6 @@ public: static void add_static_script(Ref<GDScript> p_script); static void remove_static_script(const String &p_fqcn); - static Ref<PackedScene> get_packed_scene(const String &p_path, Error &r_error, const String &p_owner = ""); - static void clear_unreferenced_packed_scenes(); - static void clear(); GDScriptCache(); diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 4625855329..f63b2ce0ee 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -551,7 +551,7 @@ void GDScriptParser::end_statement(const String &p_context) { void GDScriptParser::parse_program() { head = alloc_node<ClassNode>(); - head->fqcn = script_path; + head->fqcn = GDScript::canonicalize_path(script_path); current_class = head; bool can_have_class_or_extends = true; @@ -709,7 +709,7 @@ GDScriptParser::ClassNode *GDScriptParser::parse_class(bool p_is_static) { if (n_class->outer) { String fqcn = n_class->outer->fqcn; if (fqcn.is_empty()) { - fqcn = script_path; + fqcn = GDScript::canonicalize_path(script_path); } n_class->fqcn = fqcn + "::" + n_class->identifier->name; } else { diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 979b7e8579..853a8e0f19 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -641,7 +641,7 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S while (!stack.is_empty()) { current = Object::cast_to<Node>(stack.pop_back()); Ref<GDScript> scr = current->get_script(); - if (scr.is_valid() && GDScript::is_equal_gdscript_paths(scr->get_path(), path)) { + if (scr.is_valid() && GDScript::is_canonically_equal_paths(scr->get_path(), path)) { break; } for (int i = 0; i < current->get_child_count(); ++i) { @@ -650,7 +650,7 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S } Ref<GDScript> scr = current->get_script(); - if (!scr.is_valid() || !GDScript::is_equal_gdscript_paths(scr->get_path(), path)) { + if (!scr.is_valid() || !GDScript::is_canonically_equal_paths(scr->get_path(), path)) { current = owner_scene_node; } } diff --git a/modules/gdscript/language_server/godot_lsp.h b/modules/gdscript/language_server/godot_lsp.h index e09adb74bd..284762018f 100644 --- a/modules/gdscript/language_server/godot_lsp.h +++ b/modules/gdscript/language_server/godot_lsp.h @@ -200,7 +200,7 @@ struct LocationLink { /** * The range that should be selected and revealed when this link is being followed, e.g the name of a function. - * Must be contained by the the `targetRange`. See also `DocumentSymbol#range` + * Must be contained by the `targetRange`. See also `DocumentSymbol#range` */ Range targetSelectionRange; }; diff --git a/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp b/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp index 2af716b867..1e64a6daa4 100644 --- a/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp +++ b/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp @@ -32,7 +32,7 @@ #include "scene/3d/importer_mesh_instance_3d.h" #include "scene/3d/mesh_instance_3d.h" -#include "scene/resources/importer_mesh.h" +#include "scene/resources/3d/importer_mesh.h" void GLTFDocumentExtensionConvertImporterMesh::_bind_methods() { } diff --git a/modules/gltf/extensions/physics/gltf_physics_shape.cpp b/modules/gltf/extensions/physics/gltf_physics_shape.cpp index af4ac10313..467499a03f 100644 --- a/modules/gltf/extensions/physics/gltf_physics_shape.cpp +++ b/modules/gltf/extensions/physics/gltf_physics_shape.cpp @@ -34,13 +34,13 @@ #include "core/math/convex_hull.h" #include "scene/3d/area_3d.h" -#include "scene/resources/box_shape_3d.h" -#include "scene/resources/capsule_shape_3d.h" -#include "scene/resources/concave_polygon_shape_3d.h" -#include "scene/resources/convex_polygon_shape_3d.h" -#include "scene/resources/cylinder_shape_3d.h" -#include "scene/resources/importer_mesh.h" -#include "scene/resources/sphere_shape_3d.h" +#include "scene/resources/3d/box_shape_3d.h" +#include "scene/resources/3d/capsule_shape_3d.h" +#include "scene/resources/3d/concave_polygon_shape_3d.h" +#include "scene/resources/3d/convex_polygon_shape_3d.h" +#include "scene/resources/3d/cylinder_shape_3d.h" +#include "scene/resources/3d/importer_mesh.h" +#include "scene/resources/3d/sphere_shape_3d.h" void GLTFPhysicsShape::_bind_methods() { ClassDB::bind_static_method("GLTFPhysicsShape", D_METHOD("from_node", "shape_node"), &GLTFPhysicsShape::from_node); diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index afb3659699..0ed2100041 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -50,9 +50,9 @@ #include "scene/3d/light_3d.h" #include "scene/3d/mesh_instance_3d.h" #include "scene/3d/multimesh_instance_3d.h" +#include "scene/resources/3d/skin.h" #include "scene/resources/image_texture.h" #include "scene/resources/portable_compressed_texture.h" -#include "scene/resources/skin.h" #include "scene/resources/surface_tool.h" #ifdef TOOLS_ENABLED @@ -2796,7 +2796,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> p_state) { Vector<Vector3> normals = array[Mesh::ARRAY_NORMAL]; for (int k = 0; k < vertex_num; k++) { - Vector3 tan = Vector3(0.0, 1.0, 0.0).cross(normals[k]); + Vector3 tan = Vector3(normals[i].z, -normals[i].x, normals[i].y).cross(normals[k].normalized()).normalized(); tangentsw[k * 4 + 0] = tan.x; tangentsw[k * 4 + 1] = tan.y; tangentsw[k * 4 + 2] = tan.z; @@ -2822,6 +2822,19 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> p_state) { } array = mesh_surface_tool->commit_to_arrays(); + if ((flags & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) && a.has("NORMAL") && (a.has("TANGENT") || generate_tangents)) { + // Compression is enabled, so let's validate that the normals and tangents are correct. + Vector<Vector3> normals = array[Mesh::ARRAY_NORMAL]; + Vector<float> tangents = array[Mesh::ARRAY_TANGENT]; + for (int vert = 0; vert < normals.size(); vert++) { + Vector3 tan = Vector3(tangents[vert * 4 + 0], tangents[vert * 4 + 1], tangents[vert * 4 + 2]); + if (abs(tan.dot(normals[vert])) > 0.0001) { + // Tangent is not perpendicular to the normal, so we can't use compression. + flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES; + } + } + } + Array morphs; //blend shapes if (p.has("targets")) { diff --git a/modules/gltf/structures/gltf_mesh.cpp b/modules/gltf/structures/gltf_mesh.cpp index d04d3fcd7f..9566cc2379 100644 --- a/modules/gltf/structures/gltf_mesh.cpp +++ b/modules/gltf/structures/gltf_mesh.cpp @@ -30,7 +30,7 @@ #include "gltf_mesh.h" -#include "scene/resources/importer_mesh.h" +#include "scene/resources/3d/importer_mesh.h" void GLTFMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("get_original_name"), &GLTFMesh::get_original_name); diff --git a/modules/gltf/structures/gltf_mesh.h b/modules/gltf/structures/gltf_mesh.h index c33e39df84..6983efeb2a 100644 --- a/modules/gltf/structures/gltf_mesh.h +++ b/modules/gltf/structures/gltf_mesh.h @@ -33,7 +33,7 @@ #include "../gltf_defines.h" -#include "scene/resources/importer_mesh.h" +#include "scene/resources/3d/importer_mesh.h" class GLTFMesh : public Resource { GDCLASS(GLTFMesh, Resource); diff --git a/modules/gltf/structures/gltf_skin.cpp b/modules/gltf/structures/gltf_skin.cpp index 8097c7b3d0..18aa90a628 100644 --- a/modules/gltf/structures/gltf_skin.cpp +++ b/modules/gltf/structures/gltf_skin.cpp @@ -33,7 +33,7 @@ #include "../gltf_template_convert.h" #include "core/variant/typed_array.h" -#include "scene/resources/skin.h" +#include "scene/resources/3d/skin.h" void GLTFSkin::_bind_methods() { ClassDB::bind_method(D_METHOD("get_skin_root"), &GLTFSkin::get_skin_root); diff --git a/modules/gltf/structures/gltf_skin.h b/modules/gltf/structures/gltf_skin.h index ce863da45d..4649a918e3 100644 --- a/modules/gltf/structures/gltf_skin.h +++ b/modules/gltf/structures/gltf_skin.h @@ -34,7 +34,7 @@ #include "../gltf_defines.h" #include "core/io/resource.h" -#include "scene/resources/skin.h" +#include "scene/resources/3d/skin.h" template <typename T> class TypedArray; diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index e3475b3959..fb449a67f8 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -33,9 +33,9 @@ #include "core/core_string_names.h" #include "core/io/marshalls.h" #include "scene/3d/light_3d.h" -#include "scene/resources/mesh_library.h" +#include "scene/resources/3d/mesh_library.h" +#include "scene/resources/3d/primitive_meshes.h" #include "scene/resources/physics_material.h" -#include "scene/resources/primitive_meshes.h" #include "scene/resources/surface_tool.h" #include "scene/scene_string_names.h" #include "servers/navigation_server_3d.h" diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 348ac5194c..7398a540de 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -32,7 +32,7 @@ #define GRID_MAP_H #include "scene/3d/node_3d.h" -#include "scene/resources/mesh_library.h" +#include "scene/resources/3d/mesh_library.h" #include "scene/resources/multimesh.h" //heh heh, godotsphir!! this shares no code and the design is completely different with previous projects i've done.. diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 0345eebef6..88fe82c6b8 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2851,7 +2851,22 @@ Ref<Resource> ResourceFormatLoaderCSharpScript::load(const String &p_path, const ERR_FAIL_COND_V_MSG(!scr->get_path().is_empty() && scr->get_path() != p_original_path, Ref<Resource>(), "The C# script path is different from the path it was registered in the C# dictionary."); - scr->set_path(p_original_path, true); + Ref<Resource> existing = ResourceCache::get_ref(p_path); + switch (p_cache_mode) { + case ResourceFormatLoader::CACHE_MODE_IGNORE: + break; + case ResourceFormatLoader::CACHE_MODE_REUSE: + if (existing.is_null()) { + scr->set_path(p_original_path); + } else { + scr = existing; + } + break; + case ResourceFormatLoader::CACHE_MODE_REPLACE: + scr->set_path(p_original_path, true); + break; + } + scr->reload(); if (r_error) { diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index b4adc94c64..bf6cab11c7 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -511,6 +511,7 @@ namespace GodotTools FocusMode = Control.FocusModeEnum.None, Shortcut = EditorDefShortcut("mono/build_solution", "Build Project".TTR(), (Key)KeyModifierMask.MaskAlt | Key.B), ShortcutInTooltip = true, + ThemeTypeVariation = "RunBarButton", }; EditorShortcutOverride("mono/build_solution", "macos", (Key)KeyModifierMask.MaskMeta | (Key)KeyModifierMask.MaskCtrl | Key.B); diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 675651ccf7..7960a1ad5b 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -150,8 +150,268 @@ static String fix_doc_description(const String &p_bbcode) { .strip_edges(); } +String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInterface *p_itype) { + // Based on the version in EditorHelp. + + if (p_bbcode.is_empty()) { + return String(); + } + + DocTools *doc = EditorHelp::get_doc_data(); + + String bbcode = p_bbcode; + + StringBuilder output; + + List<String> tag_stack; + bool code_tag = false; + + int pos = 0; + while (pos < bbcode.length()) { + int brk_pos = bbcode.find("[", pos); + + if (brk_pos < 0) { + brk_pos = bbcode.length(); + } + + if (brk_pos > pos) { + String text = bbcode.substr(pos, brk_pos - pos); + if (code_tag || tag_stack.size() > 0) { + output.append("'" + text + "'"); + } else { + output.append(text); + } + } + + if (brk_pos == bbcode.length()) { + // Nothing else to add. + break; + } + + int brk_end = bbcode.find("]", brk_pos + 1); + + if (brk_end == -1) { + String text = bbcode.substr(brk_pos, bbcode.length() - brk_pos); + if (code_tag || tag_stack.size() > 0) { + output.append("'" + text + "'"); + } + + break; + } + + String tag = bbcode.substr(brk_pos + 1, brk_end - brk_pos - 1); + + if (tag.begins_with("/")) { + bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length()); + + if (!tag_ok) { + output.append("]"); + pos = brk_pos + 1; + continue; + } + + tag_stack.pop_front(); + pos = brk_end + 1; + code_tag = false; + } else if (code_tag) { + output.append("["); + pos = brk_pos + 1; + } else if (tag.begins_with("method ") || tag.begins_with("constructor ") || tag.begins_with("operator ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ") || tag.begins_with("constant ") || tag.begins_with("theme_item ") || tag.begins_with("param ")) { + const int tag_end = tag.find(" "); + const String link_tag = tag.substr(0, tag_end); + const String link_target = tag.substr(tag_end + 1, tag.length()).lstrip(" "); + + const Vector<String> link_target_parts = link_target.split("."); + + if (link_target_parts.size() <= 0 || link_target_parts.size() > 2) { + ERR_PRINT("Invalid reference format: '" + tag + "'."); + + output.append(tag); + + pos = brk_end + 1; + continue; + } + + const TypeInterface *target_itype; + StringName target_cname; + + if (link_target_parts.size() == 2) { + target_itype = _get_type_or_null(TypeReference(link_target_parts[0])); + if (!target_itype) { + target_itype = _get_type_or_null(TypeReference("_" + link_target_parts[0])); + } + target_cname = link_target_parts[1]; + } else { + target_itype = p_itype; + target_cname = link_target_parts[0]; + } + + if (link_tag == "method") { + _append_text_method(output, target_itype, target_cname, link_target, link_target_parts); + } else if (link_tag == "constructor") { + // TODO: Support constructors? + _append_text_undeclared(output, link_target); + } else if (link_tag == "operator") { + // TODO: Support operators? + _append_text_undeclared(output, link_target); + } else if (link_tag == "member") { + _append_text_member(output, target_itype, target_cname, link_target, link_target_parts); + } else if (link_tag == "signal") { + _append_text_signal(output, target_itype, target_cname, link_target, link_target_parts); + } else if (link_tag == "enum") { + _append_text_enum(output, target_itype, target_cname, link_target, link_target_parts); + } else if (link_tag == "constant") { + _append_text_constant(output, target_itype, target_cname, link_target, link_target_parts); + } else if (link_tag == "param") { + _append_text_param(output, link_target); + } else if (link_tag == "theme_item") { + // We do not declare theme_items in any way in C#, so there is nothing to reference. + _append_text_undeclared(output, link_target); + } + + pos = brk_end + 1; + } else if (doc->class_list.has(tag)) { + if (tag == "Array" || tag == "Dictionary") { + output.append("'" BINDINGS_NAMESPACE_COLLECTIONS "."); + output.append(tag); + output.append("'"); + } else if (tag == "bool" || tag == "int") { + output.append(tag); + } else if (tag == "float") { + output.append( +#ifdef REAL_T_IS_DOUBLE + "double" +#else + "float" +#endif + ); + } else if (tag == "Variant") { + output.append("'Godot.Variant'"); + } else if (tag == "String") { + output.append("string"); + } else if (tag == "Nil") { + output.append("null"); + } else if (tag.begins_with("@")) { + // @GlobalScope, @GDScript, etc. + output.append("'" + tag + "'"); + } else if (tag == "PackedByteArray") { + output.append("byte[]"); + } else if (tag == "PackedInt32Array") { + output.append("int[]"); + } else if (tag == "PackedInt64Array") { + output.append("long[]"); + } else if (tag == "PackedFloat32Array") { + output.append("float[]"); + } else if (tag == "PackedFloat64Array") { + output.append("double[]"); + } else if (tag == "PackedStringArray") { + output.append("string[]"); + } else if (tag == "PackedVector2Array") { + output.append("'" BINDINGS_NAMESPACE ".Vector2[]'"); + } else if (tag == "PackedVector3Array") { + output.append("'" BINDINGS_NAMESPACE ".Vector3[]'"); + } else if (tag == "PackedColorArray") { + output.append("'" BINDINGS_NAMESPACE ".Color[]'"); + } else { + const TypeInterface *target_itype = _get_type_or_null(TypeReference(tag)); + + if (!target_itype) { + target_itype = _get_type_or_null(TypeReference("_" + tag)); + } + + if (target_itype) { + output.append("'" + target_itype->proxy_name + "'"); + } else { + ERR_PRINT("Cannot resolve type reference in documentation: '" + tag + "'."); + output.append("'" + tag + "'"); + } + } + + pos = brk_end + 1; + } else if (tag == "b") { + // Bold is not supported. + pos = brk_end + 1; + tag_stack.push_front(tag); + } else if (tag == "i") { + // Italic is not supported. + pos = brk_end + 1; + tag_stack.push_front(tag); + } else if (tag == "code" || tag.begins_with("code ")) { + code_tag = true; + pos = brk_end + 1; + tag_stack.push_front("code"); + } else if (tag == "kbd") { + // Keyboard combinations are not supported. + pos = brk_end + 1; + tag_stack.push_front(tag); + } else if (tag == "center") { + // Center alignment is not supported. + pos = brk_end + 1; + tag_stack.push_front(tag); + } else if (tag == "br") { + // Break is not supported. + pos = brk_end + 1; + tag_stack.push_front(tag); + } else if (tag == "u") { + // Underline is not supported. + pos = brk_end + 1; + tag_stack.push_front(tag); + } else if (tag == "s") { + // Strikethrough is not supported. + pos = brk_end + 1; + tag_stack.push_front(tag); + } else if (tag == "url") { + int end = bbcode.find("[", brk_end); + if (end == -1) { + end = bbcode.length(); + } + String url = bbcode.substr(brk_end + 1, end - brk_end - 1); + // Not supported. Just append the url. + output.append(url); + + pos = brk_end + 1; + tag_stack.push_front(tag); + } else if (tag.begins_with("url=")) { + String url = tag.substr(4, tag.length()); + // Not supported. Just append the url. + output.append(url); + + pos = brk_end + 1; + tag_stack.push_front("url"); + } else if (tag == "img") { + int end = bbcode.find("[", brk_end); + if (end == -1) { + end = bbcode.length(); + } + String image = bbcode.substr(brk_end + 1, end - brk_end - 1); + + // Not supported. Just append the bbcode. + output.append("[img]"); + output.append(image); + output.append("[/img]"); + + pos = end; + tag_stack.push_front(tag); + } else if (tag.begins_with("color=")) { + // Not supported. + pos = brk_end + 1; + tag_stack.push_front("color"); + } else if (tag.begins_with("font=")) { + // Not supported. + pos = brk_end + 1; + tag_stack.push_front("font"); + } else { + // Ignore unrecognized tag. + output.append("["); + pos = brk_pos + 1; + } + } + + return output.as_string(); +} + String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterface *p_itype, bool p_is_signal) { - // Based on the version in EditorHelp + // Based on the version in EditorHelp. if (p_bbcode.is_empty()) { return String(); @@ -200,7 +460,8 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf } if (brk_pos == bbcode.length()) { - break; // nothing else to add + // Nothing else to add. + break; } int brk_end = bbcode.find("]", brk_pos + 1); @@ -316,7 +577,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf } else if (link_tag == "param") { _append_xml_param(xml_output, link_target, p_is_signal); } else if (link_tag == "theme_item") { - // We do not declare theme_items in any way in C#, so there is nothing to reference + // We do not declare theme_items in any way in C#, so there is nothing to reference. _append_xml_undeclared(xml_output, link_target); } @@ -345,7 +606,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf } else if (tag == "Nil") { xml_output.append("<see langword=\"null\"/>"); } else if (tag.begins_with("@")) { - // @GlobalScope, @GDScript, etc + // @GlobalScope, @GDScript, etc. xml_output.append("<c>"); xml_output.append(tag); xml_output.append("</c>"); @@ -432,22 +693,22 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf pos = brk_end + 1; tag_stack.push_front("csharp"); } else if (tag == "kbd") { - // keyboard combinations are not supported in xml comments + // Keyboard combinations are not supported in xml comments. pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "center") { - // center alignment is not supported in xml comments + // Center alignment is not supported in xml comments. pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "br") { xml_output.append("\n"); // FIXME: Should use <para> instead. Luckily this tag isn't used for now. pos = brk_end + 1; } else if (tag == "u") { - // underline is not supported in Rider xml comments + // Underline is not supported in Rider xml comments. pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "s") { - // strikethrough is not supported in xml comments + // Strikethrough is not supported in xml comments. pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "url") { @@ -495,7 +756,8 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf tag_stack.push_front("font"); } else { if (!line_del) { - xml_output.append("["); // ignore + // Ignore unrecognized tag. + xml_output.append("["); } pos = brk_pos + 1; } @@ -506,6 +768,285 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf return xml_output.as_string(); } +void BindingsGenerator::_append_text_method(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts) { + if (p_link_target_parts[0] == name_cache.type_at_GlobalScope) { + if (OS::get_singleton()->is_stdout_verbose()) { + OS::get_singleton()->print("Cannot resolve @GlobalScope method reference in documentation: %s\n", p_link_target.utf8().get_data()); + } + + // TODO Map what we can + _append_text_undeclared(p_output, p_link_target); + } else if (!p_target_itype || !p_target_itype->is_object_type) { + if (OS::get_singleton()->is_stdout_verbose()) { + if (p_target_itype) { + OS::get_singleton()->print("Cannot resolve method reference for non-GodotObject type in documentation: %s\n", p_link_target.utf8().get_data()); + } else { + OS::get_singleton()->print("Cannot resolve type from method reference in documentation: %s\n", p_link_target.utf8().get_data()); + } + } + + // TODO Map what we can + _append_text_undeclared(p_output, p_link_target); + } else { + if (p_target_cname == "_init") { + // The _init method is not declared in C#, reference the constructor instead + p_output.append("'new " BINDINGS_NAMESPACE "."); + p_output.append(p_target_itype->proxy_name); + p_output.append("()'"); + } else { + const MethodInterface *target_imethod = p_target_itype->find_method_by_name(p_target_cname); + + if (target_imethod) { + p_output.append("'" BINDINGS_NAMESPACE "."); + p_output.append(p_target_itype->proxy_name); + p_output.append("."); + p_output.append(target_imethod->proxy_name); + p_output.append("("); + bool first_key = true; + for (const ArgumentInterface &iarg : target_imethod->arguments) { + const TypeInterface *arg_type = _get_type_or_null(iarg.type); + + if (first_key) { + first_key = false; + } else { + p_output.append(", "); + } + if (!arg_type) { + ERR_PRINT("Cannot resolve argument type in documentation: '" + p_link_target + "'."); + p_output.append(iarg.type.cname); + continue; + } + if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) { + p_output.append("Nullable<"); + } + String arg_cs_type = arg_type->cs_type + _get_generic_type_parameters(*arg_type, iarg.type.generic_type_parameters); + p_output.append(arg_cs_type.replacen("params ", "")); + if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) { + p_output.append(">"); + } + } + p_output.append(")'"); + } else { + if (!p_target_itype->is_intentionally_ignored(p_link_target)) { + ERR_PRINT("Cannot resolve method reference in documentation: '" + p_link_target + "'."); + } + + _append_text_undeclared(p_output, p_link_target); + } + } + } +} + +void BindingsGenerator::_append_text_member(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts) { + if (p_link_target.find("/") >= 0) { + // Properties with '/' (slash) in the name are not declared in C#, so there is nothing to reference. + _append_text_undeclared(p_output, p_link_target); + } else if (!p_target_itype || !p_target_itype->is_object_type) { + if (OS::get_singleton()->is_stdout_verbose()) { + if (p_target_itype) { + OS::get_singleton()->print("Cannot resolve member reference for non-GodotObject type in documentation: %s\n", p_link_target.utf8().get_data()); + } else { + OS::get_singleton()->print("Cannot resolve type from member reference in documentation: %s\n", p_link_target.utf8().get_data()); + } + } + + // TODO Map what we can + _append_text_undeclared(p_output, p_link_target); + } else { + const TypeInterface *current_itype = p_target_itype; + const PropertyInterface *target_iprop = nullptr; + + while (target_iprop == nullptr && current_itype != nullptr) { + target_iprop = current_itype->find_property_by_name(p_target_cname); + if (target_iprop == nullptr) { + current_itype = _get_type_or_null(TypeReference(current_itype->base_name)); + } + } + + if (target_iprop) { + p_output.append("'" BINDINGS_NAMESPACE "."); + p_output.append(current_itype->proxy_name); + p_output.append("."); + p_output.append(target_iprop->proxy_name); + p_output.append("'"); + } else { + if (!p_target_itype->is_intentionally_ignored(p_link_target)) { + ERR_PRINT("Cannot resolve member reference in documentation: '" + p_link_target + "'."); + } + + _append_text_undeclared(p_output, p_link_target); + } + } +} + +void BindingsGenerator::_append_text_signal(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts) { + if (!p_target_itype || !p_target_itype->is_object_type) { + if (OS::get_singleton()->is_stdout_verbose()) { + if (p_target_itype) { + OS::get_singleton()->print("Cannot resolve signal reference for non-GodotObject type in documentation: %s\n", p_link_target.utf8().get_data()); + } else { + OS::get_singleton()->print("Cannot resolve type from signal reference in documentation: %s\n", p_link_target.utf8().get_data()); + } + } + + // TODO Map what we can + _append_text_undeclared(p_output, p_link_target); + } else { + const SignalInterface *target_isignal = p_target_itype->find_signal_by_name(p_target_cname); + + if (target_isignal) { + p_output.append("'" BINDINGS_NAMESPACE "."); + p_output.append(p_target_itype->proxy_name); + p_output.append("."); + p_output.append(target_isignal->proxy_name); + p_output.append("'"); + } else { + if (!p_target_itype->is_intentionally_ignored(p_link_target)) { + ERR_PRINT("Cannot resolve signal reference in documentation: '" + p_link_target + "'."); + } + + _append_text_undeclared(p_output, p_link_target); + } + } +} + +void BindingsGenerator::_append_text_enum(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts) { + const StringName search_cname = !p_target_itype ? p_target_cname : StringName(p_target_itype->name + "." + (String)p_target_cname); + + HashMap<StringName, TypeInterface>::ConstIterator enum_match = enum_types.find(search_cname); + + if (!enum_match && search_cname != p_target_cname) { + enum_match = enum_types.find(p_target_cname); + } + + if (enum_match) { + const TypeInterface &target_enum_itype = enum_match->value; + + p_output.append("'" BINDINGS_NAMESPACE "."); + p_output.append(target_enum_itype.proxy_name); // Includes nesting class if any + p_output.append("'"); + } else { + if (!p_target_itype->is_intentionally_ignored(p_link_target)) { + ERR_PRINT("Cannot resolve enum reference in documentation: '" + p_link_target + "'."); + } + + _append_text_undeclared(p_output, p_link_target); + } +} + +void BindingsGenerator::_append_text_constant(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts) { + if (p_link_target_parts[0] == name_cache.type_at_GlobalScope) { + _append_text_constant_in_global_scope(p_output, p_target_cname, p_link_target); + } else if (!p_target_itype || !p_target_itype->is_object_type) { + // Search in @GlobalScope as a last resort if no class was specified + if (p_link_target_parts.size() == 1) { + _append_text_constant_in_global_scope(p_output, p_target_cname, p_link_target); + return; + } + + if (OS::get_singleton()->is_stdout_verbose()) { + if (p_target_itype) { + OS::get_singleton()->print("Cannot resolve constant reference for non-GodotObject type in documentation: %s\n", p_link_target.utf8().get_data()); + } else { + OS::get_singleton()->print("Cannot resolve type from constant reference in documentation: %s\n", p_link_target.utf8().get_data()); + } + } + + // TODO Map what we can + _append_text_undeclared(p_output, p_link_target); + } else { + // Try to find the constant in the current class + if (p_target_itype->is_singleton_instance) { + // Constants and enums are declared in the static singleton class. + p_target_itype = &obj_types[p_target_itype->cname]; + } + + const ConstantInterface *target_iconst = find_constant_by_name(p_target_cname, p_target_itype->constants); + + if (target_iconst) { + // Found constant in current class + p_output.append("'" BINDINGS_NAMESPACE "."); + p_output.append(p_target_itype->proxy_name); + p_output.append("."); + p_output.append(target_iconst->proxy_name); + p_output.append("'"); + } else { + // Try to find as enum constant in the current class + const EnumInterface *target_ienum = nullptr; + + for (const EnumInterface &ienum : p_target_itype->enums) { + target_ienum = &ienum; + target_iconst = find_constant_by_name(p_target_cname, target_ienum->constants); + if (target_iconst) { + break; + } + } + + if (target_iconst) { + p_output.append("'" BINDINGS_NAMESPACE "."); + p_output.append(p_target_itype->proxy_name); + p_output.append("."); + p_output.append(target_ienum->proxy_name); + p_output.append("."); + p_output.append(target_iconst->proxy_name); + p_output.append("'"); + } else if (p_link_target_parts.size() == 1) { + // Also search in @GlobalScope as a last resort if no class was specified + _append_text_constant_in_global_scope(p_output, p_target_cname, p_link_target); + } else { + if (!p_target_itype->is_intentionally_ignored(p_link_target)) { + ERR_PRINT("Cannot resolve constant reference in documentation: '" + p_link_target + "'."); + } + + _append_xml_undeclared(p_output, p_link_target); + } + } + } +} + +void BindingsGenerator::_append_text_constant_in_global_scope(StringBuilder &p_output, const String &p_target_cname, const String &p_link_target) { + // Try to find as a global constant + const ConstantInterface *target_iconst = find_constant_by_name(p_target_cname, global_constants); + + if (target_iconst) { + // Found global constant + p_output.append("'" BINDINGS_NAMESPACE "." BINDINGS_GLOBAL_SCOPE_CLASS "."); + p_output.append(target_iconst->proxy_name); + p_output.append("'"); + } else { + // Try to find as global enum constant + const EnumInterface *target_ienum = nullptr; + + for (const EnumInterface &ienum : global_enums) { + target_ienum = &ienum; + target_iconst = find_constant_by_name(p_target_cname, target_ienum->constants); + if (target_iconst) { + break; + } + } + + if (target_iconst) { + p_output.append("'" BINDINGS_NAMESPACE "."); + p_output.append(target_ienum->proxy_name); + p_output.append("."); + p_output.append(target_iconst->proxy_name); + p_output.append("'"); + } else { + ERR_PRINT("Cannot resolve global constant reference in documentation: '" + p_link_target + "'."); + _append_text_undeclared(p_output, p_link_target); + } + } +} + +void BindingsGenerator::_append_text_param(StringBuilder &p_output, const String &p_link_target) { + const String link_target = snake_to_camel_case(p_link_target); + p_output.append("'" + link_target + "'"); +} + +void BindingsGenerator::_append_text_undeclared(StringBuilder &p_output, const String &p_link_target) { + p_output.append("'" + p_link_target + "'"); +} + void BindingsGenerator::_append_xml_method(StringBuilder &p_xml_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts) { if (p_link_target_parts[0] == name_cache.type_at_GlobalScope) { if (OS::get_singleton()->is_stdout_verbose()) { @@ -1429,10 +1970,12 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str output.append("/// </summary>\n"); } + } - if (class_doc->is_deprecated) { - output.append("[Obsolete(\"This class is deprecated.\")]\n"); - } + if (itype.is_deprecated) { + output.append("[Obsolete(\""); + output.append(bbcode_to_text(itype.deprecation_message, &itype)); + output.append("\")]\n"); } // We generate a `GodotClassName` attribute if the engine class name is not the same as the @@ -1489,10 +2032,12 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str output.append(INDENT1 "/// </summary>"); } + } - if (iconstant.const_doc->is_deprecated) { - output.append(MEMBER_BEGIN "[Obsolete(\"This constant is deprecated.\")]"); - } + if (iconstant.is_deprecated) { + output.append(MEMBER_BEGIN "[Obsolete(\""); + output.append(bbcode_to_text(iconstant.deprecation_message, &itype)); + output.append("\")]"); } output.append(MEMBER_BEGIN "public const long "); @@ -1537,10 +2082,12 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str output.append(INDENT2 "/// </summary>\n"); } + } - if (iconstant.const_doc->is_deprecated) { - output.append(INDENT2 "[Obsolete(\"This enum member is deprecated.\")]\n"); - } + if (iconstant.is_deprecated) { + output.append(INDENT2 "[Obsolete(\""); + output.append(bbcode_to_text(iconstant.deprecation_message, &itype)); + output.append("\")]\n"); } output.append(INDENT2); @@ -1992,10 +2539,12 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte p_output.append(INDENT1 "/// </summary>"); } + } - if (p_iprop.prop_doc->is_deprecated) { - p_output.append(MEMBER_BEGIN "[Obsolete(\"This property is deprecated.\")]"); - } + if (p_iprop.is_deprecated) { + p_output.append(MEMBER_BEGIN "[Obsolete(\""); + p_output.append(bbcode_to_text(p_iprop.deprecation_message, &p_itype)); + p_output.append("\")]"); } p_output.append(MEMBER_BEGIN "public "); @@ -2248,15 +2797,9 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf } if (p_imethod.is_deprecated) { - if (p_imethod.deprecation_message.is_empty()) { - WARN_PRINT("An empty deprecation message is discouraged. Method: '" + p_imethod.proxy_name + "'."); - } - p_output.append(MEMBER_BEGIN "[Obsolete(\""); - p_output.append(p_imethod.deprecation_message); + p_output.append(bbcode_to_text(p_imethod.deprecation_message, &p_itype)); p_output.append("\")]"); - } else if (p_imethod.method_doc && p_imethod.method_doc->is_deprecated) { - p_output.append(MEMBER_BEGIN "[Obsolete(\"This method is deprecated.\")]"); } if (p_imethod.is_compat) { @@ -2401,12 +2944,8 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf p_output.append(INDENT1 "/// </summary>"); if (p_isignal.is_deprecated) { - if (p_isignal.deprecation_message.is_empty()) { - WARN_PRINT("An empty deprecation message is discouraged. Signal: '" + p_isignal.proxy_name + "'."); - } - p_output.append(MEMBER_BEGIN "[Obsolete(\""); - p_output.append(p_isignal.deprecation_message); + p_output.append(bbcode_to_text(p_isignal.deprecation_message, &p_itype)); p_output.append("\")]"); } @@ -2459,15 +2998,11 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf p_output.append(INDENT1 "/// </summary>"); } - - if (p_isignal.method_doc->is_deprecated) { - p_output.append(MEMBER_BEGIN "[Obsolete(\"This signal is deprecated.\")]"); - } } if (p_isignal.is_deprecated) { p_output.append(MEMBER_BEGIN "[Obsolete(\""); - p_output.append(p_isignal.deprecation_message); + p_output.append(bbcode_to_text(p_isignal.deprecation_message, &p_itype)); p_output.append("\")]"); } @@ -3029,6 +3564,16 @@ bool BindingsGenerator::_populate_object_type_interfaces() { itype.is_ref_counted = ClassDB::is_parent_class(type_cname, name_cache.type_RefCounted); itype.memory_own = itype.is_ref_counted; + if (itype.class_doc) { + itype.is_deprecated = itype.class_doc->is_deprecated; + itype.deprecation_message = itype.class_doc->deprecated_message; + + if (itype.deprecation_message.is_empty()) { + WARN_PRINT("An empty deprecation message is discouraged. Type: '" + itype.proxy_name + "'."); + itype.deprecation_message = "This class is deprecated."; + } + } + if (itype.is_singleton && compat_singletons.has(itype.cname)) { itype.is_singleton = false; itype.is_compat_singleton = true; @@ -3103,6 +3648,16 @@ bool BindingsGenerator::_populate_object_type_interfaces() { } } + if (iprop.prop_doc) { + iprop.is_deprecated = iprop.prop_doc->is_deprecated; + iprop.deprecation_message = iprop.prop_doc->deprecated_message; + + if (iprop.deprecation_message.is_empty()) { + WARN_PRINT("An empty deprecation message is discouraged. Property: '" + itype.proxy_name + "." + iprop.proxy_name + "'."); + iprop.deprecation_message = "This property is deprecated."; + } + } + itype.properties.push_back(iprop); } @@ -3282,6 +3837,16 @@ bool BindingsGenerator::_populate_object_type_interfaces() { } } + if (imethod.method_doc) { + imethod.is_deprecated = imethod.method_doc->is_deprecated; + imethod.deprecation_message = imethod.method_doc->deprecated_message; + + if (imethod.deprecation_message.is_empty()) { + WARN_PRINT("An empty deprecation message is discouraged. Method: '" + itype.proxy_name + "." + imethod.proxy_name + "'."); + imethod.deprecation_message = "This method is deprecated."; + } + } + ERR_FAIL_COND_V_MSG(itype.find_property_by_name(imethod.cname), false, "Method name conflicts with property: '" + itype.name + "." + imethod.name + "'."); @@ -3388,6 +3953,16 @@ bool BindingsGenerator::_populate_object_type_interfaces() { } } + if (isignal.method_doc) { + isignal.is_deprecated = isignal.method_doc->is_deprecated; + isignal.deprecation_message = isignal.method_doc->deprecated_message; + + if (isignal.deprecation_message.is_empty()) { + WARN_PRINT("An empty deprecation message is discouraged. Signal: '" + itype.proxy_name + "." + isignal.proxy_name + "'."); + isignal.deprecation_message = "This signal is deprecated."; + } + } + itype.signals_.push_back(isignal); } @@ -3428,6 +4003,16 @@ bool BindingsGenerator::_populate_object_type_interfaces() { } } + if (iconstant.const_doc) { + iconstant.is_deprecated = iconstant.const_doc->is_deprecated; + iconstant.deprecation_message = iconstant.const_doc->deprecated_message; + + if (iconstant.deprecation_message.is_empty()) { + WARN_PRINT("An empty deprecation message is discouraged. Enum member: '" + itype.proxy_name + "." + ienum.proxy_name + "." + iconstant.proxy_name + "'."); + iconstant.deprecation_message = "This enum member is deprecated."; + } + } + ienum.constants.push_back(iconstant); } @@ -3470,6 +4055,16 @@ bool BindingsGenerator::_populate_object_type_interfaces() { } } + if (iconstant.const_doc) { + iconstant.is_deprecated = iconstant.const_doc->is_deprecated; + iconstant.deprecation_message = iconstant.const_doc->deprecated_message; + + if (iconstant.deprecation_message.is_empty()) { + WARN_PRINT("An empty deprecation message is discouraged. Constant: '" + itype.proxy_name + "." + iconstant.proxy_name + "'."); + iconstant.deprecation_message = "This constant is deprecated."; + } + } + itype.constants.push_back(iconstant); } diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index aa4e5ea093..bb0ba0cb00 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -47,7 +47,10 @@ class BindingsGenerator { String name; String proxy_name; int64_t value = 0; - const DocData::ConstantDoc *const_doc; + const DocData::ConstantDoc *const_doc = nullptr; + + bool is_deprecated = false; + String deprecation_message; ConstantInterface() {} @@ -86,6 +89,9 @@ class BindingsGenerator { StringName getter; const DocData::PropertyDoc *prop_doc; + + bool is_deprecated = false; + String deprecation_message; }; struct TypeReference { @@ -427,6 +433,9 @@ class BindingsGenerator { const DocData::ClassDoc *class_doc = nullptr; + bool is_deprecated = false; + String deprecation_message; + List<ConstantInterface> constants; List<EnumInterface> enums; List<PropertyInterface> properties; @@ -765,8 +774,18 @@ class BindingsGenerator { return p_type->name; } + String bbcode_to_text(const String &p_bbcode, const TypeInterface *p_itype); String bbcode_to_xml(const String &p_bbcode, const TypeInterface *p_itype, bool p_is_signal = false); + void _append_text_method(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts); + void _append_text_member(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts); + void _append_text_signal(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts); + void _append_text_enum(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts); + void _append_text_constant(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts); + void _append_text_constant_in_global_scope(StringBuilder &p_output, const String &p_target_cname, const String &p_link_target); + void _append_text_param(StringBuilder &p_output, const String &p_link_target); + void _append_text_undeclared(StringBuilder &p_output, const String &p_link_target); + void _append_xml_method(StringBuilder &p_xml_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts); void _append_xml_member(StringBuilder &p_xml_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts); void _append_xml_signal(StringBuilder &p_xml_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index bd92e48bce..8f1bc109c0 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -492,7 +492,10 @@ namespace Godot } /// <summary> - /// Returns this vector projected onto another vector <paramref name="onNormal"/>. + /// Returns a new vector resulting from projecting this vector onto the given vector <paramref name="onNormal"/>. + /// The resulting new vector is parallel to <paramref name="onNormal"/>. + /// See also <see cref="Slide(Vector2)"/>. + /// Note: If the vector <paramref name="onNormal"/> is a zero vector, the components of the resulting new vector will be <see cref="real_t.NaN"/>. /// </summary> /// <param name="onNormal">The vector to project onto.</param> /// <returns>The projected vector.</returns> @@ -583,9 +586,12 @@ namespace Godot } /// <summary> - /// Returns this vector slid along a plane defined by the given <paramref name="normal"/>. + /// Returns a new vector resulting from sliding this vector along a line with normal <paramref name="normal"/>. + /// The resulting new vector is perpendicular to <paramref name="normal"/>, and is equivalent to this vector minus its projection on <paramref name="normal"/>. + /// See also <see cref="Project(Vector2)"/>. + /// Note: The vector <paramref name="normal"/> must be normalized. See also <see cref="Normalized()"/>. /// </summary> - /// <param name="normal">The normal vector defining the plane to slide on.</param> + /// <param name="normal">The normal vector of the plane to slide on.</param> /// <returns>The slid vector.</returns> public readonly Vector2 Slide(Vector2 normal) { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index 6e77512fc8..74c1616e3d 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -514,7 +514,10 @@ namespace Godot } /// <summary> - /// Returns this vector projected onto another vector <paramref name="onNormal"/>. + /// Returns a new vector resulting from projecting this vector onto the given vector <paramref name="onNormal"/>. + /// The resulting new vector is parallel to <paramref name="onNormal"/>. + /// See also <see cref="Slide(Vector3)"/>. + /// Note: If the vector <paramref name="onNormal"/> is a zero vector, the components of the resulting new vector will be <see cref="real_t.NaN"/>. /// </summary> /// <param name="onNormal">The vector to project onto.</param> /// <returns>The projected vector.</returns> @@ -626,9 +629,12 @@ namespace Godot } /// <summary> - /// Returns this vector slid along a plane defined by the given <paramref name="normal"/>. + /// Returns a new vector resulting from sliding this vector along a plane with normal <paramref name="normal"/>. + /// The resulting new vector is perpendicular to <paramref name="normal"/>, and is equivalent to this vector minus its projection on <paramref name="normal"/>. + /// See also <see cref="Project(Vector3)"/>. + /// Note: The vector <paramref name="normal"/> must be normalized. See also <see cref="Normalized()"/>. /// </summary> - /// <param name="normal">The normal vector defining the plane to slide on.</param> + /// <param name="normal">The normal vector of the plane to slide on.</param> /// <returns>The slid vector.</returns> public readonly Vector3 Slide(Vector3 normal) { diff --git a/modules/multiplayer/editor/replication_editor.cpp b/modules/multiplayer/editor/replication_editor.cpp index 51974e7767..f6df212d35 100644 --- a/modules/multiplayer/editor/replication_editor.cpp +++ b/modules/multiplayer/editor/replication_editor.cpp @@ -292,7 +292,7 @@ ReplicationEditor::ReplicationEditor() { vb->add_child(tree); drop_label = memnew(Label); - drop_label->set_text(TTR("Add properties using the options above, or\ndrag them them from the inspector and drop them here.")); + drop_label->set_text(TTR("Add properties using the options above, or\ndrag them from the inspector and drop them here.")); drop_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); drop_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER); tree->add_child(drop_label); diff --git a/modules/multiplayer/scene_multiplayer.cpp b/modules/multiplayer/scene_multiplayer.cpp index 6f7a3493a1..99aba680cc 100644 --- a/modules/multiplayer/scene_multiplayer.cpp +++ b/modules/multiplayer/scene_multiplayer.cpp @@ -428,7 +428,7 @@ void SceneMultiplayer::disconnect_peer(int p_id) { if (pending_peers.has(p_id)) { pending_peers.erase(p_id); } else if (connected_peers.has(p_id)) { - connected_peers.has(p_id); + connected_peers.erase(p_id); } multiplayer_peer->disconnect_peer(p_id); } diff --git a/modules/multiplayer/scene_replication_interface.cpp b/modules/multiplayer/scene_replication_interface.cpp index b61cf0bf1d..bb32eed1a9 100644 --- a/modules/multiplayer/scene_replication_interface.cpp +++ b/modules/multiplayer/scene_replication_interface.cpp @@ -421,7 +421,7 @@ Error SceneReplicationInterface::_update_spawn_visibility(int p_peer, const Obje // Check visibility for each peers. for (const KeyValue<int, PeerInfo> &E : peers_info) { if (is_visible) { - // This is fast, since the the object is visible to everyone, we don't need to check each peer. + // This is fast, since the object is visible to everyone, we don't need to check each peer. if (E.value.spawn_nodes.has(p_oid)) { // Already spawned. continue; diff --git a/modules/navigation/godot_navigation_server_2d.cpp b/modules/navigation/2d/godot_navigation_server_2d.cpp index 28bcd16310..28bcd16310 100644 --- a/modules/navigation/godot_navigation_server_2d.cpp +++ b/modules/navigation/2d/godot_navigation_server_2d.cpp diff --git a/modules/navigation/godot_navigation_server_2d.h b/modules/navigation/2d/godot_navigation_server_2d.h index 225fd8f3a6..a148887a65 100644 --- a/modules/navigation/godot_navigation_server_2d.h +++ b/modules/navigation/2d/godot_navigation_server_2d.h @@ -31,11 +31,11 @@ #ifndef GODOT_NAVIGATION_SERVER_2D_H #define GODOT_NAVIGATION_SERVER_2D_H -#include "nav_agent.h" -#include "nav_link.h" -#include "nav_map.h" -#include "nav_obstacle.h" -#include "nav_region.h" +#include "../nav_agent.h" +#include "../nav_link.h" +#include "../nav_map.h" +#include "../nav_obstacle.h" +#include "../nav_region.h" #include "servers/navigation_server_2d.h" diff --git a/modules/navigation/nav_mesh_generator_2d.cpp b/modules/navigation/2d/nav_mesh_generator_2d.cpp index 836dee8178..9fdfb20842 100644 --- a/modules/navigation/nav_mesh_generator_2d.cpp +++ b/modules/navigation/2d/nav_mesh_generator_2d.cpp @@ -38,13 +38,13 @@ #include "scene/2d/physics_body_2d.h" #include "scene/2d/polygon_2d.h" #include "scene/2d/tile_map.h" -#include "scene/resources/capsule_shape_2d.h" -#include "scene/resources/circle_shape_2d.h" -#include "scene/resources/concave_polygon_shape_2d.h" -#include "scene/resources/convex_polygon_shape_2d.h" +#include "scene/resources/2d/capsule_shape_2d.h" +#include "scene/resources/2d/circle_shape_2d.h" +#include "scene/resources/2d/concave_polygon_shape_2d.h" +#include "scene/resources/2d/convex_polygon_shape_2d.h" +#include "scene/resources/2d/rectangle_shape_2d.h" #include "scene/resources/navigation_mesh_source_geometry_data_2d.h" #include "scene/resources/navigation_polygon.h" -#include "scene/resources/rectangle_shape_2d.h" #include "thirdparty/clipper2/include/clipper2/clipper.h" #include "thirdparty/misc/polypartition.h" diff --git a/modules/navigation/nav_mesh_generator_2d.h b/modules/navigation/2d/nav_mesh_generator_2d.h index b606f3f6fc..b606f3f6fc 100644 --- a/modules/navigation/nav_mesh_generator_2d.h +++ b/modules/navigation/2d/nav_mesh_generator_2d.h diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/3d/godot_navigation_server_3d.cpp index a3b23da6b6..d293b9edbe 100644 --- a/modules/navigation/godot_navigation_server.cpp +++ b/modules/navigation/3d/godot_navigation_server_3d.cpp @@ -1,5 +1,5 @@ /**************************************************************************/ -/* godot_navigation_server.cpp */ +/* godot_navigation_server_3d.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#include "godot_navigation_server.h" +#include "godot_navigation_server_3d.h" #ifndef _3D_DISABLED #include "nav_mesh_generator_3d.h" @@ -42,58 +42,58 @@ using namespace NavigationUtilities; /// an instance of that struct with the submitted parameters. /// Then, that struct is stored in an array; the `sync` function consume that array. -#define COMMAND_1(F_NAME, T_0, D_0) \ - struct MERGE(F_NAME, _command) : public SetCommand { \ - T_0 d_0; \ - MERGE(F_NAME, _command) \ - (T_0 p_d_0) : \ - d_0(p_d_0) {} \ - virtual void exec(GodotNavigationServer *server) override { \ - server->MERGE(_cmd_, F_NAME)(d_0); \ - } \ - }; \ - void GodotNavigationServer::F_NAME(T_0 D_0) { \ - auto cmd = memnew(MERGE(F_NAME, _command)( \ - D_0)); \ - add_command(cmd); \ - } \ - void GodotNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0) - -#define COMMAND_2(F_NAME, T_0, D_0, T_1, D_1) \ - struct MERGE(F_NAME, _command) : public SetCommand { \ - T_0 d_0; \ - T_1 d_1; \ - MERGE(F_NAME, _command) \ - ( \ - T_0 p_d_0, \ - T_1 p_d_1) : \ - d_0(p_d_0), \ - d_1(p_d_1) {} \ - virtual void exec(GodotNavigationServer *server) override { \ - server->MERGE(_cmd_, F_NAME)(d_0, d_1); \ - } \ - }; \ - void GodotNavigationServer::F_NAME(T_0 D_0, T_1 D_1) { \ - auto cmd = memnew(MERGE(F_NAME, _command)( \ - D_0, \ - D_1)); \ - add_command(cmd); \ - } \ - void GodotNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1) - -GodotNavigationServer::GodotNavigationServer() {} - -GodotNavigationServer::~GodotNavigationServer() { +#define COMMAND_1(F_NAME, T_0, D_0) \ + struct MERGE(F_NAME, _command) : public SetCommand { \ + T_0 d_0; \ + MERGE(F_NAME, _command) \ + (T_0 p_d_0) : \ + d_0(p_d_0) {} \ + virtual void exec(GodotNavigationServer3D *server) override { \ + server->MERGE(_cmd_, F_NAME)(d_0); \ + } \ + }; \ + void GodotNavigationServer3D::F_NAME(T_0 D_0) { \ + auto cmd = memnew(MERGE(F_NAME, _command)( \ + D_0)); \ + add_command(cmd); \ + } \ + void GodotNavigationServer3D::MERGE(_cmd_, F_NAME)(T_0 D_0) + +#define COMMAND_2(F_NAME, T_0, D_0, T_1, D_1) \ + struct MERGE(F_NAME, _command) : public SetCommand { \ + T_0 d_0; \ + T_1 d_1; \ + MERGE(F_NAME, _command) \ + ( \ + T_0 p_d_0, \ + T_1 p_d_1) : \ + d_0(p_d_0), \ + d_1(p_d_1) {} \ + virtual void exec(GodotNavigationServer3D *server) override { \ + server->MERGE(_cmd_, F_NAME)(d_0, d_1); \ + } \ + }; \ + void GodotNavigationServer3D::F_NAME(T_0 D_0, T_1 D_1) { \ + auto cmd = memnew(MERGE(F_NAME, _command)( \ + D_0, \ + D_1)); \ + add_command(cmd); \ + } \ + void GodotNavigationServer3D::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1) + +GodotNavigationServer3D::GodotNavigationServer3D() {} + +GodotNavigationServer3D::~GodotNavigationServer3D() { flush_queries(); } -void GodotNavigationServer::add_command(SetCommand *command) { +void GodotNavigationServer3D::add_command(SetCommand *command) { MutexLock lock(commands_mutex); commands.push_back(command); } -TypedArray<RID> GodotNavigationServer::get_maps() const { +TypedArray<RID> GodotNavigationServer3D::get_maps() const { TypedArray<RID> all_map_rids; List<RID> maps_owned; map_owner.get_owned_list(&maps_owned); @@ -105,7 +105,7 @@ TypedArray<RID> GodotNavigationServer::get_maps() const { return all_map_rids; } -RID GodotNavigationServer::map_create() { +RID GodotNavigationServer3D::map_create() { MutexLock lock(operations_mutex); RID rid = map_owner.make_rid(); @@ -131,7 +131,7 @@ COMMAND_2(map_set_active, RID, p_map, bool, p_active) { } } -bool GodotNavigationServer::map_is_active(RID p_map) const { +bool GodotNavigationServer3D::map_is_active(RID p_map) const { NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, false); @@ -145,7 +145,7 @@ COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) { map->set_up(p_up); } -Vector3 GodotNavigationServer::map_get_up(RID p_map) const { +Vector3 GodotNavigationServer3D::map_get_up(RID p_map) const { const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, Vector3()); @@ -159,7 +159,7 @@ COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size) { map->set_cell_size(p_cell_size); } -real_t GodotNavigationServer::map_get_cell_size(RID p_map) const { +real_t GodotNavigationServer3D::map_get_cell_size(RID p_map) const { const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, 0); @@ -173,7 +173,7 @@ COMMAND_2(map_set_cell_height, RID, p_map, real_t, p_cell_height) { map->set_cell_height(p_cell_height); } -real_t GodotNavigationServer::map_get_cell_height(RID p_map) const { +real_t GodotNavigationServer3D::map_get_cell_height(RID p_map) const { const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, 0); @@ -187,7 +187,7 @@ COMMAND_2(map_set_merge_rasterizer_cell_scale, RID, p_map, float, p_value) { map->set_merge_rasterizer_cell_scale(p_value); } -float GodotNavigationServer::map_get_merge_rasterizer_cell_scale(RID p_map) const { +float GodotNavigationServer3D::map_get_merge_rasterizer_cell_scale(RID p_map) const { NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, false); @@ -201,7 +201,7 @@ COMMAND_2(map_set_use_edge_connections, RID, p_map, bool, p_enabled) { map->set_use_edge_connections(p_enabled); } -bool GodotNavigationServer::map_get_use_edge_connections(RID p_map) const { +bool GodotNavigationServer3D::map_get_use_edge_connections(RID p_map) const { NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, false); @@ -215,7 +215,7 @@ COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margi map->set_edge_connection_margin(p_connection_margin); } -real_t GodotNavigationServer::map_get_edge_connection_margin(RID p_map) const { +real_t GodotNavigationServer3D::map_get_edge_connection_margin(RID p_map) const { const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, 0); @@ -229,49 +229,49 @@ COMMAND_2(map_set_link_connection_radius, RID, p_map, real_t, p_connection_radiu map->set_link_connection_radius(p_connection_radius); } -real_t GodotNavigationServer::map_get_link_connection_radius(RID p_map) const { +real_t GodotNavigationServer3D::map_get_link_connection_radius(RID p_map) const { const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, 0); return map->get_link_connection_radius(); } -Vector<Vector3> GodotNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize, uint32_t p_navigation_layers) const { +Vector<Vector3> GodotNavigationServer3D::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize, uint32_t p_navigation_layers) const { const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, Vector<Vector3>()); return map->get_path(p_origin, p_destination, p_optimize, p_navigation_layers, nullptr, nullptr, nullptr); } -Vector3 GodotNavigationServer::map_get_closest_point_to_segment(RID p_map, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const { +Vector3 GodotNavigationServer3D::map_get_closest_point_to_segment(RID p_map, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const { const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, Vector3()); return map->get_closest_point_to_segment(p_from, p_to, p_use_collision); } -Vector3 GodotNavigationServer::map_get_closest_point(RID p_map, const Vector3 &p_point) const { +Vector3 GodotNavigationServer3D::map_get_closest_point(RID p_map, const Vector3 &p_point) const { const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, Vector3()); return map->get_closest_point(p_point); } -Vector3 GodotNavigationServer::map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const { +Vector3 GodotNavigationServer3D::map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const { const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, Vector3()); return map->get_closest_point_normal(p_point); } -RID GodotNavigationServer::map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const { +RID GodotNavigationServer3D::map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const { const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, RID()); return map->get_closest_point_owner(p_point); } -TypedArray<RID> GodotNavigationServer::map_get_links(RID p_map) const { +TypedArray<RID> GodotNavigationServer3D::map_get_links(RID p_map) const { TypedArray<RID> link_rids; const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, link_rids); @@ -285,7 +285,7 @@ TypedArray<RID> GodotNavigationServer::map_get_links(RID p_map) const { return link_rids; } -TypedArray<RID> GodotNavigationServer::map_get_regions(RID p_map) const { +TypedArray<RID> GodotNavigationServer3D::map_get_regions(RID p_map) const { TypedArray<RID> regions_rids; const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, regions_rids); @@ -299,7 +299,7 @@ TypedArray<RID> GodotNavigationServer::map_get_regions(RID p_map) const { return regions_rids; } -TypedArray<RID> GodotNavigationServer::map_get_agents(RID p_map) const { +TypedArray<RID> GodotNavigationServer3D::map_get_agents(RID p_map) const { TypedArray<RID> agents_rids; const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, agents_rids); @@ -313,7 +313,7 @@ TypedArray<RID> GodotNavigationServer::map_get_agents(RID p_map) const { return agents_rids; } -TypedArray<RID> GodotNavigationServer::map_get_obstacles(RID p_map) const { +TypedArray<RID> GodotNavigationServer3D::map_get_obstacles(RID p_map) const { TypedArray<RID> obstacles_rids; const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, obstacles_rids); @@ -325,7 +325,7 @@ TypedArray<RID> GodotNavigationServer::map_get_obstacles(RID p_map) const { return obstacles_rids; } -RID GodotNavigationServer::region_get_map(RID p_region) const { +RID GodotNavigationServer3D::region_get_map(RID p_region) const { NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, RID()); @@ -335,7 +335,7 @@ RID GodotNavigationServer::region_get_map(RID p_region) const { return RID(); } -RID GodotNavigationServer::agent_get_map(RID p_agent) const { +RID GodotNavigationServer3D::agent_get_map(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, RID()); @@ -345,14 +345,14 @@ RID GodotNavigationServer::agent_get_map(RID p_agent) const { return RID(); } -Vector3 GodotNavigationServer::map_get_random_point(RID p_map, uint32_t p_navigation_layers, bool p_uniformly) const { +Vector3 GodotNavigationServer3D::map_get_random_point(RID p_map, uint32_t p_navigation_layers, bool p_uniformly) const { const NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, Vector3()); return map->get_random_point(p_navigation_layers, p_uniformly); } -RID GodotNavigationServer::region_create() { +RID GodotNavigationServer3D::region_create() { MutexLock lock(operations_mutex); RID rid = region_owner.make_rid(); @@ -368,7 +368,7 @@ COMMAND_2(region_set_enabled, RID, p_region, bool, p_enabled) { region->set_enabled(p_enabled); } -bool GodotNavigationServer::region_get_enabled(RID p_region) const { +bool GodotNavigationServer3D::region_get_enabled(RID p_region) const { const NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, false); @@ -382,7 +382,7 @@ COMMAND_2(region_set_use_edge_connections, RID, p_region, bool, p_enabled) { region->set_use_edge_connections(p_enabled); } -bool GodotNavigationServer::region_get_use_edge_connections(RID p_region) const { +bool GodotNavigationServer3D::region_get_use_edge_connections(RID p_region) const { NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, false); @@ -405,7 +405,7 @@ COMMAND_2(region_set_transform, RID, p_region, Transform3D, p_transform) { region->set_transform(p_transform); } -Transform3D GodotNavigationServer::region_get_transform(RID p_region) const { +Transform3D GodotNavigationServer3D::region_get_transform(RID p_region) const { NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, Transform3D()); @@ -420,7 +420,7 @@ COMMAND_2(region_set_enter_cost, RID, p_region, real_t, p_enter_cost) { region->set_enter_cost(p_enter_cost); } -real_t GodotNavigationServer::region_get_enter_cost(RID p_region) const { +real_t GodotNavigationServer3D::region_get_enter_cost(RID p_region) const { NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, 0); @@ -435,7 +435,7 @@ COMMAND_2(region_set_travel_cost, RID, p_region, real_t, p_travel_cost) { region->set_travel_cost(p_travel_cost); } -real_t GodotNavigationServer::region_get_travel_cost(RID p_region) const { +real_t GodotNavigationServer3D::region_get_travel_cost(RID p_region) const { NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, 0); @@ -449,14 +449,14 @@ COMMAND_2(region_set_owner_id, RID, p_region, ObjectID, p_owner_id) { region->set_owner_id(p_owner_id); } -ObjectID GodotNavigationServer::region_get_owner_id(RID p_region) const { +ObjectID GodotNavigationServer3D::region_get_owner_id(RID p_region) const { const NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, ObjectID()); return region->get_owner_id(); } -bool GodotNavigationServer::region_owns_point(RID p_region, const Vector3 &p_point) const { +bool GodotNavigationServer3D::region_owns_point(RID p_region, const Vector3 &p_point) const { const NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, false); @@ -474,7 +474,7 @@ COMMAND_2(region_set_navigation_layers, RID, p_region, uint32_t, p_navigation_la region->set_navigation_layers(p_navigation_layers); } -uint32_t GodotNavigationServer::region_get_navigation_layers(RID p_region) const { +uint32_t GodotNavigationServer3D::region_get_navigation_layers(RID p_region) const { NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, 0); @@ -489,7 +489,7 @@ COMMAND_2(region_set_navigation_mesh, RID, p_region, Ref<NavigationMesh>, p_navi } #ifndef DISABLE_DEPRECATED -void GodotNavigationServer::region_bake_navigation_mesh(Ref<NavigationMesh> p_navigation_mesh, Node *p_root_node) { +void GodotNavigationServer3D::region_bake_navigation_mesh(Ref<NavigationMesh> p_navigation_mesh, Node *p_root_node) { ERR_FAIL_COND(p_navigation_mesh.is_null()); ERR_FAIL_NULL(p_root_node); @@ -505,35 +505,35 @@ void GodotNavigationServer::region_bake_navigation_mesh(Ref<NavigationMesh> p_na } #endif // DISABLE_DEPRECATED -int GodotNavigationServer::region_get_connections_count(RID p_region) const { +int GodotNavigationServer3D::region_get_connections_count(RID p_region) const { NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, 0); return region->get_connections_count(); } -Vector3 GodotNavigationServer::region_get_connection_pathway_start(RID p_region, int p_connection_id) const { +Vector3 GodotNavigationServer3D::region_get_connection_pathway_start(RID p_region, int p_connection_id) const { NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, Vector3()); return region->get_connection_pathway_start(p_connection_id); } -Vector3 GodotNavigationServer::region_get_connection_pathway_end(RID p_region, int p_connection_id) const { +Vector3 GodotNavigationServer3D::region_get_connection_pathway_end(RID p_region, int p_connection_id) const { NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, Vector3()); return region->get_connection_pathway_end(p_connection_id); } -Vector3 GodotNavigationServer::region_get_random_point(RID p_region, uint32_t p_navigation_layers, bool p_uniformly) const { +Vector3 GodotNavigationServer3D::region_get_random_point(RID p_region, uint32_t p_navigation_layers, bool p_uniformly) const { const NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_NULL_V(region, Vector3()); return region->get_random_point(p_navigation_layers, p_uniformly); } -RID GodotNavigationServer::link_create() { +RID GodotNavigationServer3D::link_create() { MutexLock lock(operations_mutex); RID rid = link_owner.make_rid(); @@ -551,7 +551,7 @@ COMMAND_2(link_set_map, RID, p_link, RID, p_map) { link->set_map(map); } -RID GodotNavigationServer::link_get_map(const RID p_link) const { +RID GodotNavigationServer3D::link_get_map(const RID p_link) const { const NavLink *link = link_owner.get_or_null(p_link); ERR_FAIL_NULL_V(link, RID()); @@ -568,7 +568,7 @@ COMMAND_2(link_set_enabled, RID, p_link, bool, p_enabled) { link->set_enabled(p_enabled); } -bool GodotNavigationServer::link_get_enabled(RID p_link) const { +bool GodotNavigationServer3D::link_get_enabled(RID p_link) const { const NavLink *link = link_owner.get_or_null(p_link); ERR_FAIL_NULL_V(link, false); @@ -582,7 +582,7 @@ COMMAND_2(link_set_bidirectional, RID, p_link, bool, p_bidirectional) { link->set_bidirectional(p_bidirectional); } -bool GodotNavigationServer::link_is_bidirectional(RID p_link) const { +bool GodotNavigationServer3D::link_is_bidirectional(RID p_link) const { const NavLink *link = link_owner.get_or_null(p_link); ERR_FAIL_NULL_V(link, false); @@ -596,7 +596,7 @@ COMMAND_2(link_set_navigation_layers, RID, p_link, uint32_t, p_navigation_layers link->set_navigation_layers(p_navigation_layers); } -uint32_t GodotNavigationServer::link_get_navigation_layers(const RID p_link) const { +uint32_t GodotNavigationServer3D::link_get_navigation_layers(const RID p_link) const { const NavLink *link = link_owner.get_or_null(p_link); ERR_FAIL_NULL_V(link, 0); @@ -610,7 +610,7 @@ COMMAND_2(link_set_start_position, RID, p_link, Vector3, p_position) { link->set_start_position(p_position); } -Vector3 GodotNavigationServer::link_get_start_position(RID p_link) const { +Vector3 GodotNavigationServer3D::link_get_start_position(RID p_link) const { const NavLink *link = link_owner.get_or_null(p_link); ERR_FAIL_NULL_V(link, Vector3()); @@ -624,7 +624,7 @@ COMMAND_2(link_set_end_position, RID, p_link, Vector3, p_position) { link->set_end_position(p_position); } -Vector3 GodotNavigationServer::link_get_end_position(RID p_link) const { +Vector3 GodotNavigationServer3D::link_get_end_position(RID p_link) const { const NavLink *link = link_owner.get_or_null(p_link); ERR_FAIL_NULL_V(link, Vector3()); @@ -638,7 +638,7 @@ COMMAND_2(link_set_enter_cost, RID, p_link, real_t, p_enter_cost) { link->set_enter_cost(p_enter_cost); } -real_t GodotNavigationServer::link_get_enter_cost(const RID p_link) const { +real_t GodotNavigationServer3D::link_get_enter_cost(const RID p_link) const { const NavLink *link = link_owner.get_or_null(p_link); ERR_FAIL_NULL_V(link, 0); @@ -652,7 +652,7 @@ COMMAND_2(link_set_travel_cost, RID, p_link, real_t, p_travel_cost) { link->set_travel_cost(p_travel_cost); } -real_t GodotNavigationServer::link_get_travel_cost(const RID p_link) const { +real_t GodotNavigationServer3D::link_get_travel_cost(const RID p_link) const { const NavLink *link = link_owner.get_or_null(p_link); ERR_FAIL_NULL_V(link, 0); @@ -666,14 +666,14 @@ COMMAND_2(link_set_owner_id, RID, p_link, ObjectID, p_owner_id) { link->set_owner_id(p_owner_id); } -ObjectID GodotNavigationServer::link_get_owner_id(RID p_link) const { +ObjectID GodotNavigationServer3D::link_get_owner_id(RID p_link) const { const NavLink *link = link_owner.get_or_null(p_link); ERR_FAIL_NULL_V(link, ObjectID()); return link->get_owner_id(); } -RID GodotNavigationServer::agent_create() { +RID GodotNavigationServer3D::agent_create() { MutexLock lock(operations_mutex); RID rid = agent_owner.make_rid(); @@ -689,7 +689,7 @@ COMMAND_2(agent_set_avoidance_enabled, RID, p_agent, bool, p_enabled) { agent->set_avoidance_enabled(p_enabled); } -bool GodotNavigationServer::agent_get_avoidance_enabled(RID p_agent) const { +bool GodotNavigationServer3D::agent_get_avoidance_enabled(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, false); @@ -703,7 +703,7 @@ COMMAND_2(agent_set_use_3d_avoidance, RID, p_agent, bool, p_enabled) { agent->set_use_3d_avoidance(p_enabled); } -bool GodotNavigationServer::agent_get_use_3d_avoidance(RID p_agent) const { +bool GodotNavigationServer3D::agent_get_use_3d_avoidance(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, false); @@ -726,7 +726,7 @@ COMMAND_2(agent_set_paused, RID, p_agent, bool, p_paused) { agent->set_paused(p_paused); } -bool GodotNavigationServer::agent_get_paused(RID p_agent) const { +bool GodotNavigationServer3D::agent_get_paused(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, false); @@ -740,7 +740,7 @@ COMMAND_2(agent_set_neighbor_distance, RID, p_agent, real_t, p_distance) { agent->set_neighbor_distance(p_distance); } -real_t GodotNavigationServer::agent_get_neighbor_distance(RID p_agent) const { +real_t GodotNavigationServer3D::agent_get_neighbor_distance(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, 0); @@ -754,7 +754,7 @@ COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) { agent->set_max_neighbors(p_count); } -int GodotNavigationServer::agent_get_max_neighbors(RID p_agent) const { +int GodotNavigationServer3D::agent_get_max_neighbors(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, 0); @@ -769,7 +769,7 @@ COMMAND_2(agent_set_time_horizon_agents, RID, p_agent, real_t, p_time_horizon) { agent->set_time_horizon_agents(p_time_horizon); } -real_t GodotNavigationServer::agent_get_time_horizon_agents(RID p_agent) const { +real_t GodotNavigationServer3D::agent_get_time_horizon_agents(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, 0); @@ -784,7 +784,7 @@ COMMAND_2(agent_set_time_horizon_obstacles, RID, p_agent, real_t, p_time_horizon agent->set_time_horizon_obstacles(p_time_horizon); } -real_t GodotNavigationServer::agent_get_time_horizon_obstacles(RID p_agent) const { +real_t GodotNavigationServer3D::agent_get_time_horizon_obstacles(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, 0); @@ -799,7 +799,7 @@ COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) { agent->set_radius(p_radius); } -real_t GodotNavigationServer::agent_get_radius(RID p_agent) const { +real_t GodotNavigationServer3D::agent_get_radius(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, 0); @@ -814,7 +814,7 @@ COMMAND_2(agent_set_height, RID, p_agent, real_t, p_height) { agent->set_height(p_height); } -real_t GodotNavigationServer::agent_get_height(RID p_agent) const { +real_t GodotNavigationServer3D::agent_get_height(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, 0); @@ -829,7 +829,7 @@ COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) { agent->set_max_speed(p_max_speed); } -real_t GodotNavigationServer::agent_get_max_speed(RID p_agent) const { +real_t GodotNavigationServer3D::agent_get_max_speed(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, 0); @@ -843,7 +843,7 @@ COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) { agent->set_velocity(p_velocity); } -Vector3 GodotNavigationServer::agent_get_velocity(RID p_agent) const { +Vector3 GodotNavigationServer3D::agent_get_velocity(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, Vector3()); @@ -864,14 +864,14 @@ COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position) { agent->set_position(p_position); } -Vector3 GodotNavigationServer::agent_get_position(RID p_agent) const { +Vector3 GodotNavigationServer3D::agent_get_position(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, Vector3()); return agent->get_position(); } -bool GodotNavigationServer::agent_is_map_changed(RID p_agent) const { +bool GodotNavigationServer3D::agent_is_map_changed(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, false); @@ -893,7 +893,7 @@ COMMAND_2(agent_set_avoidance_callback, RID, p_agent, Callable, p_callback) { } } -bool GodotNavigationServer::agent_has_avoidance_callback(RID p_agent) const { +bool GodotNavigationServer3D::agent_has_avoidance_callback(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, false); @@ -906,7 +906,7 @@ COMMAND_2(agent_set_avoidance_layers, RID, p_agent, uint32_t, p_layers) { agent->set_avoidance_layers(p_layers); } -uint32_t GodotNavigationServer::agent_get_avoidance_layers(RID p_agent) const { +uint32_t GodotNavigationServer3D::agent_get_avoidance_layers(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, 0); @@ -919,7 +919,7 @@ COMMAND_2(agent_set_avoidance_mask, RID, p_agent, uint32_t, p_mask) { agent->set_avoidance_mask(p_mask); } -uint32_t GodotNavigationServer::agent_get_avoidance_mask(RID p_agent) const { +uint32_t GodotNavigationServer3D::agent_get_avoidance_mask(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, 0); @@ -934,14 +934,14 @@ COMMAND_2(agent_set_avoidance_priority, RID, p_agent, real_t, p_priority) { agent->set_avoidance_priority(p_priority); } -real_t GodotNavigationServer::agent_get_avoidance_priority(RID p_agent) const { +real_t GodotNavigationServer3D::agent_get_avoidance_priority(RID p_agent) const { NavAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_NULL_V(agent, 0); return agent->get_avoidance_priority(); } -RID GodotNavigationServer::obstacle_create() { +RID GodotNavigationServer3D::obstacle_create() { MutexLock lock(operations_mutex); RID rid = obstacle_owner.make_rid(); @@ -964,7 +964,7 @@ COMMAND_2(obstacle_set_avoidance_enabled, RID, p_obstacle, bool, p_enabled) { obstacle->set_avoidance_enabled(p_enabled); } -bool GodotNavigationServer::obstacle_get_avoidance_enabled(RID p_obstacle) const { +bool GodotNavigationServer3D::obstacle_get_avoidance_enabled(RID p_obstacle) const { NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle); ERR_FAIL_NULL_V(obstacle, false); @@ -978,7 +978,7 @@ COMMAND_2(obstacle_set_use_3d_avoidance, RID, p_obstacle, bool, p_enabled) { obstacle->set_use_3d_avoidance(p_enabled); } -bool GodotNavigationServer::obstacle_get_use_3d_avoidance(RID p_obstacle) const { +bool GodotNavigationServer3D::obstacle_get_use_3d_avoidance(RID p_obstacle) const { NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle); ERR_FAIL_NULL_V(obstacle, false); @@ -994,7 +994,7 @@ COMMAND_2(obstacle_set_map, RID, p_obstacle, RID, p_map) { obstacle->set_map(map); } -RID GodotNavigationServer::obstacle_get_map(RID p_obstacle) const { +RID GodotNavigationServer3D::obstacle_get_map(RID p_obstacle) const { NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle); ERR_FAIL_NULL_V(obstacle, RID()); if (obstacle->get_map()) { @@ -1010,7 +1010,7 @@ COMMAND_2(obstacle_set_paused, RID, p_obstacle, bool, p_paused) { obstacle->set_paused(p_paused); } -bool GodotNavigationServer::obstacle_get_paused(RID p_obstacle) const { +bool GodotNavigationServer3D::obstacle_get_paused(RID p_obstacle) const { NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle); ERR_FAIL_NULL_V(obstacle, false); @@ -1025,7 +1025,7 @@ COMMAND_2(obstacle_set_radius, RID, p_obstacle, real_t, p_radius) { obstacle->set_radius(p_radius); } -real_t GodotNavigationServer::obstacle_get_radius(RID p_obstacle) const { +real_t GodotNavigationServer3D::obstacle_get_radius(RID p_obstacle) const { NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle); ERR_FAIL_NULL_V(obstacle, 0); @@ -1038,7 +1038,7 @@ COMMAND_2(obstacle_set_height, RID, p_obstacle, real_t, p_height) { obstacle->set_height(p_height); } -real_t GodotNavigationServer::obstacle_get_height(RID p_obstacle) const { +real_t GodotNavigationServer3D::obstacle_get_height(RID p_obstacle) const { NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle); ERR_FAIL_NULL_V(obstacle, 0); @@ -1052,7 +1052,7 @@ COMMAND_2(obstacle_set_velocity, RID, p_obstacle, Vector3, p_velocity) { obstacle->set_velocity(p_velocity); } -Vector3 GodotNavigationServer::obstacle_get_velocity(RID p_obstacle) const { +Vector3 GodotNavigationServer3D::obstacle_get_velocity(RID p_obstacle) const { NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle); ERR_FAIL_NULL_V(obstacle, Vector3()); @@ -1065,20 +1065,20 @@ COMMAND_2(obstacle_set_position, RID, p_obstacle, Vector3, p_position) { obstacle->set_position(p_position); } -Vector3 GodotNavigationServer::obstacle_get_position(RID p_obstacle) const { +Vector3 GodotNavigationServer3D::obstacle_get_position(RID p_obstacle) const { NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle); ERR_FAIL_NULL_V(obstacle, Vector3()); return obstacle->get_position(); } -void GodotNavigationServer::obstacle_set_vertices(RID p_obstacle, const Vector<Vector3> &p_vertices) { +void GodotNavigationServer3D::obstacle_set_vertices(RID p_obstacle, const Vector<Vector3> &p_vertices) { NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle); ERR_FAIL_NULL(obstacle); obstacle->set_vertices(p_vertices); } -Vector<Vector3> GodotNavigationServer::obstacle_get_vertices(RID p_obstacle) const { +Vector<Vector3> GodotNavigationServer3D::obstacle_get_vertices(RID p_obstacle) const { NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle); ERR_FAIL_NULL_V(obstacle, Vector<Vector3>()); @@ -1091,14 +1091,14 @@ COMMAND_2(obstacle_set_avoidance_layers, RID, p_obstacle, uint32_t, p_layers) { obstacle->set_avoidance_layers(p_layers); } -uint32_t GodotNavigationServer::obstacle_get_avoidance_layers(RID p_obstacle) const { +uint32_t GodotNavigationServer3D::obstacle_get_avoidance_layers(RID p_obstacle) const { NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle); ERR_FAIL_NULL_V(obstacle, 0); return obstacle->get_avoidance_layers(); } -void GodotNavigationServer::parse_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, Node *p_root_node, const Callable &p_callback) { +void GodotNavigationServer3D::parse_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, Node *p_root_node, const Callable &p_callback) { #ifndef _3D_DISABLED ERR_FAIL_COND_MSG(!Thread::is_main_thread(), "The SceneTree can only be parsed on the main thread. Call this function from the main thread or use call_deferred()."); ERR_FAIL_COND_MSG(!p_navigation_mesh.is_valid(), "Invalid navigation mesh."); @@ -1110,7 +1110,7 @@ void GodotNavigationServer::parse_source_geometry_data(const Ref<NavigationMesh> #endif // _3D_DISABLED } -void GodotNavigationServer::bake_from_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, const Callable &p_callback) { +void GodotNavigationServer3D::bake_from_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, const Callable &p_callback) { #ifndef _3D_DISABLED ERR_FAIL_COND_MSG(!p_navigation_mesh.is_valid(), "Invalid navigation mesh."); ERR_FAIL_COND_MSG(!p_source_geometry_data.is_valid(), "Invalid NavigationMeshSourceGeometryData3D."); @@ -1120,7 +1120,7 @@ void GodotNavigationServer::bake_from_source_geometry_data(const Ref<NavigationM #endif // _3D_DISABLED } -void GodotNavigationServer::bake_from_source_geometry_data_async(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, const Callable &p_callback) { +void GodotNavigationServer3D::bake_from_source_geometry_data_async(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, const Callable &p_callback) { #ifndef _3D_DISABLED ERR_FAIL_COND_MSG(!p_navigation_mesh.is_valid(), "Invalid navigation mesh."); ERR_FAIL_COND_MSG(!p_source_geometry_data.is_valid(), "Invalid NavigationMeshSourceGeometryData3D."); @@ -1130,7 +1130,7 @@ void GodotNavigationServer::bake_from_source_geometry_data_async(const Ref<Navig #endif // _3D_DISABLED } -bool GodotNavigationServer::is_baking_navigation_mesh(Ref<NavigationMesh> p_navigation_mesh) const { +bool GodotNavigationServer3D::is_baking_navigation_mesh(Ref<NavigationMesh> p_navigation_mesh) const { #ifdef _3D_DISABLED return false; #else @@ -1206,7 +1206,7 @@ COMMAND_1(free, RID, p_object) { } } -void GodotNavigationServer::internal_free_agent(RID p_object) { +void GodotNavigationServer3D::internal_free_agent(RID p_object) { NavAgent *agent = agent_owner.get_or_null(p_object); if (agent) { if (agent->get_map() != nullptr) { @@ -1217,7 +1217,7 @@ void GodotNavigationServer::internal_free_agent(RID p_object) { } } -void GodotNavigationServer::internal_free_obstacle(RID p_object) { +void GodotNavigationServer3D::internal_free_obstacle(RID p_object) { NavObstacle *obstacle = obstacle_owner.get_or_null(p_object); if (obstacle) { NavAgent *obstacle_agent = obstacle->get_agent(); @@ -1234,13 +1234,13 @@ void GodotNavigationServer::internal_free_obstacle(RID p_object) { } } -void GodotNavigationServer::set_active(bool p_active) { +void GodotNavigationServer3D::set_active(bool p_active) { MutexLock lock(operations_mutex); active = p_active; } -void GodotNavigationServer::flush_queries() { +void GodotNavigationServer3D::flush_queries() { // In c++ we can't be sure that this is performed in the main thread // even with mutable functions. MutexLock lock(commands_mutex); @@ -1253,7 +1253,7 @@ void GodotNavigationServer::flush_queries() { commands.clear(); } -void GodotNavigationServer::map_force_update(RID p_map) { +void GodotNavigationServer3D::map_force_update(RID p_map) { NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL(map); @@ -1262,14 +1262,14 @@ void GodotNavigationServer::map_force_update(RID p_map) { map->sync(); } -uint32_t GodotNavigationServer::map_get_iteration_id(RID p_map) const { +uint32_t GodotNavigationServer3D::map_get_iteration_id(RID p_map) const { NavMap *map = map_owner.get_or_null(p_map); ERR_FAIL_NULL_V(map, 0); return map->get_iteration_id(); } -void GodotNavigationServer::sync() { +void GodotNavigationServer3D::sync() { #ifndef _3D_DISABLED if (navmesh_generator_3d) { navmesh_generator_3d->sync(); @@ -1277,7 +1277,7 @@ void GodotNavigationServer::sync() { #endif // _3D_DISABLED } -void GodotNavigationServer::process(real_t p_delta_time) { +void GodotNavigationServer3D::process(real_t p_delta_time) { flush_queries(); if (!active) { @@ -1328,13 +1328,13 @@ void GodotNavigationServer::process(real_t p_delta_time) { pm_edge_free_count = _new_pm_edge_free_count; } -void GodotNavigationServer::init() { +void GodotNavigationServer3D::init() { #ifndef _3D_DISABLED navmesh_generator_3d = memnew(NavMeshGenerator3D); #endif // _3D_DISABLED } -void GodotNavigationServer::finish() { +void GodotNavigationServer3D::finish() { flush_queries(); #ifndef _3D_DISABLED if (navmesh_generator_3d) { @@ -1345,7 +1345,7 @@ void GodotNavigationServer::finish() { #endif // _3D_DISABLED } -PathQueryResult GodotNavigationServer::_query_path(const PathQueryParameters &p_parameters) const { +PathQueryResult GodotNavigationServer3D::_query_path(const PathQueryParameters &p_parameters) const { PathQueryResult r_query_result; const NavMap *map = map_owner.get_or_null(p_parameters.map); @@ -1385,7 +1385,7 @@ PathQueryResult GodotNavigationServer::_query_path(const PathQueryParameters &p_ return r_query_result; } -int GodotNavigationServer::get_process_info(ProcessInfo p_info) const { +int GodotNavigationServer3D::get_process_info(ProcessInfo p_info) const { switch (p_info) { case INFO_ACTIVE_MAPS: { return active_maps.size(); diff --git a/modules/navigation/godot_navigation_server.h b/modules/navigation/3d/godot_navigation_server_3d.h index 8af0eb1874..f7d991d47a 100644 --- a/modules/navigation/godot_navigation_server.h +++ b/modules/navigation/3d/godot_navigation_server_3d.h @@ -1,5 +1,5 @@ /**************************************************************************/ -/* godot_navigation_server.h */ +/* godot_navigation_server_3d.h */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,14 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#ifndef GODOT_NAVIGATION_SERVER_H -#define GODOT_NAVIGATION_SERVER_H +#ifndef GODOT_NAVIGATION_SERVER_3D_H +#define GODOT_NAVIGATION_SERVER_3D_H -#include "nav_agent.h" -#include "nav_link.h" -#include "nav_map.h" -#include "nav_obstacle.h" -#include "nav_region.h" +#include "../nav_agent.h" +#include "../nav_link.h" +#include "../nav_map.h" +#include "../nav_obstacle.h" +#include "../nav_region.h" #include "core/templates/local_vector.h" #include "core/templates/rid.h" @@ -55,17 +55,17 @@ virtual void F_NAME(T_0 D_0, T_1 D_1) override; \ void MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1) -class GodotNavigationServer; +class GodotNavigationServer3D; #ifndef _3D_DISABLED class NavMeshGenerator3D; #endif // _3D_DISABLED struct SetCommand { virtual ~SetCommand() {} - virtual void exec(GodotNavigationServer *server) = 0; + virtual void exec(GodotNavigationServer3D *server) = 0; }; -class GodotNavigationServer : public NavigationServer3D { +class GodotNavigationServer3D : public NavigationServer3D { Mutex commands_mutex; /// Mutex used to make any operation threadsafe. Mutex operations_mutex; @@ -97,8 +97,8 @@ class GodotNavigationServer : public NavigationServer3D { int pm_edge_free_count = 0; public: - GodotNavigationServer(); - virtual ~GodotNavigationServer(); + GodotNavigationServer3D(); + virtual ~GodotNavigationServer3D(); void add_command(SetCommand *command); @@ -286,4 +286,4 @@ private: #undef COMMAND_1 #undef COMMAND_2 -#endif // GODOT_NAVIGATION_SERVER_H +#endif // GODOT_NAVIGATION_SERVER_3D_H diff --git a/modules/navigation/nav_mesh_generator_3d.cpp b/modules/navigation/3d/nav_mesh_generator_3d.cpp index 95854f29e7..4cd4f60edc 100644 --- a/modules/navigation/nav_mesh_generator_3d.cpp +++ b/modules/navigation/3d/nav_mesh_generator_3d.cpp @@ -38,18 +38,18 @@ #include "scene/3d/mesh_instance_3d.h" #include "scene/3d/multimesh_instance_3d.h" #include "scene/3d/physics_body_3d.h" -#include "scene/resources/box_shape_3d.h" -#include "scene/resources/capsule_shape_3d.h" -#include "scene/resources/concave_polygon_shape_3d.h" -#include "scene/resources/convex_polygon_shape_3d.h" -#include "scene/resources/cylinder_shape_3d.h" -#include "scene/resources/height_map_shape_3d.h" +#include "scene/resources/3d/box_shape_3d.h" +#include "scene/resources/3d/capsule_shape_3d.h" +#include "scene/resources/3d/concave_polygon_shape_3d.h" +#include "scene/resources/3d/convex_polygon_shape_3d.h" +#include "scene/resources/3d/cylinder_shape_3d.h" +#include "scene/resources/3d/height_map_shape_3d.h" +#include "scene/resources/3d/primitive_meshes.h" +#include "scene/resources/3d/shape_3d.h" +#include "scene/resources/3d/sphere_shape_3d.h" +#include "scene/resources/3d/world_boundary_shape_3d.h" #include "scene/resources/navigation_mesh.h" #include "scene/resources/navigation_mesh_source_geometry_data_3d.h" -#include "scene/resources/primitive_meshes.h" -#include "scene/resources/shape_3d.h" -#include "scene/resources/sphere_shape_3d.h" -#include "scene/resources/world_boundary_shape_3d.h" #include "modules/modules_enabled.gen.h" // For csg, gridmap. diff --git a/modules/navigation/nav_mesh_generator_3d.h b/modules/navigation/3d/nav_mesh_generator_3d.h index 0251b02235..0251b02235 100644 --- a/modules/navigation/nav_mesh_generator_3d.h +++ b/modules/navigation/3d/nav_mesh_generator_3d.h diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/3d/navigation_mesh_generator.cpp index 8393896db1..8393896db1 100644 --- a/modules/navigation/navigation_mesh_generator.cpp +++ b/modules/navigation/3d/navigation_mesh_generator.cpp diff --git a/modules/navigation/navigation_mesh_generator.h b/modules/navigation/3d/navigation_mesh_generator.h index 08fe9f9142..08fe9f9142 100644 --- a/modules/navigation/navigation_mesh_generator.h +++ b/modules/navigation/3d/navigation_mesh_generator.h diff --git a/modules/navigation/SCsub b/modules/navigation/SCsub index 46bcb0fba4..02d3b7487e 100644 --- a/modules/navigation/SCsub +++ b/modules/navigation/SCsub @@ -74,6 +74,9 @@ env.modules_sources += thirdparty_obj module_obj = [] env_navigation.add_source_files(module_obj, "*.cpp") +env_navigation.add_source_files(module_obj, "2d/*.cpp") +if not env["disable_3d"]: + env_navigation.add_source_files(module_obj, "3d/*.cpp") if env.editor_build: env_navigation.add_source_files(module_obj, "editor/*.cpp") env.modules_sources += module_obj diff --git a/modules/navigation/register_types.cpp b/modules/navigation/register_types.cpp index 525fe71134..dbc9e53035 100644 --- a/modules/navigation/register_types.cpp +++ b/modules/navigation/register_types.cpp @@ -30,12 +30,12 @@ #include "register_types.h" -#include "godot_navigation_server.h" -#include "godot_navigation_server_2d.h" +#include "2d/godot_navigation_server_2d.h" +#include "3d/godot_navigation_server_3d.h" #ifndef DISABLE_DEPRECATED #ifndef _3D_DISABLED -#include "navigation_mesh_generator.h" +#include "3d/navigation_mesh_generator.h" #endif #endif // DISABLE_DEPRECATED @@ -53,8 +53,8 @@ NavigationMeshGenerator *_nav_mesh_generator = nullptr; #endif #endif // DISABLE_DEPRECATED -NavigationServer3D *new_server() { - return memnew(GodotNavigationServer); +NavigationServer3D *new_navigation_server_3d() { + return memnew(GodotNavigationServer3D); } NavigationServer2D *new_navigation_server_2d() { @@ -63,7 +63,7 @@ NavigationServer2D *new_navigation_server_2d() { void initialize_navigation_module(ModuleInitializationLevel p_level) { if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) { - NavigationServer3DManager::set_default_server(new_server); + NavigationServer3DManager::set_default_server(new_navigation_server_3d); NavigationServer2DManager::set_default_server(new_navigation_server_2d); #ifndef DISABLE_DEPRECATED diff --git a/modules/openxr/extensions/openxr_eye_gaze_interaction.cpp b/modules/openxr/extensions/openxr_eye_gaze_interaction.cpp index e57491e7c6..477a1c2609 100644 --- a/modules/openxr/extensions/openxr_eye_gaze_interaction.cpp +++ b/modules/openxr/extensions/openxr_eye_gaze_interaction.cpp @@ -30,6 +30,7 @@ #include "openxr_eye_gaze_interaction.h" +#include "core/config/project_settings.h" #include "core/os/os.h" #include "../action_map/openxr_interaction_profile_metadata.h" @@ -52,7 +53,11 @@ OpenXREyeGazeInteractionExtension::~OpenXREyeGazeInteractionExtension() { HashMap<String, bool *> OpenXREyeGazeInteractionExtension::get_requested_extensions() { HashMap<String, bool *> request_extensions; - request_extensions[XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME] = &available; + // Only enable this extension when requested. + // We still register our meta data or the action map editor will fail. + if (GLOBAL_GET("xr/openxr/extensions/eye_gaze_interaction") && (!OS::get_singleton()->has_feature("mobile") || OS::get_singleton()->has_feature(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME))) { + request_extensions[XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME] = &available; + } return request_extensions; } diff --git a/modules/openxr/register_types.cpp b/modules/openxr/register_types.cpp index a0a93c8694..3d34b27407 100644 --- a/modules/openxr/register_types.cpp +++ b/modules/openxr/register_types.cpp @@ -117,11 +117,9 @@ void initialize_openxr_module(ModuleInitializationLevel p_level) { OpenXRAPI::register_extension_wrapper(memnew(OpenXRWMRControllerExtension)); OpenXRAPI::register_extension_wrapper(memnew(OpenXRML2ControllerExtension)); OpenXRAPI::register_extension_wrapper(memnew(OpenXRMetaControllerExtension)); + OpenXRAPI::register_extension_wrapper(memnew(OpenXREyeGazeInteractionExtension)); // register gated extensions - if (GLOBAL_GET("xr/openxr/extensions/eye_gaze_interaction") && (!OS::get_singleton()->has_feature("mobile") || OS::get_singleton()->has_feature(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME))) { - OpenXRAPI::register_extension_wrapper(memnew(OpenXREyeGazeInteractionExtension)); - } if (GLOBAL_GET("xr/openxr/extensions/hand_tracking")) { OpenXRAPI::register_extension_wrapper(memnew(OpenXRHandTrackingExtension)); } |