summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/gdscript.cpp22
-rw-r--r--modules/gdscript/gdscript.h3
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp119
-rw-r--r--modules/gdscript/gdscript_analyzer.h2
-rw-r--r--modules/gdscript/gdscript_byte_codegen.cpp2
-rw-r--r--modules/gdscript/gdscript_cache.cpp22
-rw-r--r--modules/gdscript/gdscript_cache.h9
-rw-r--r--modules/gdscript/gdscript_compiler.cpp4
-rw-r--r--modules/gdscript/gdscript_utility_functions.cpp5
-rw-r--r--modules/gdscript/gdscript_vm.cpp2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.gd14
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.out7
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_a.notest.gd2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_b.notest.gd0
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_base.notest.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_c.notest.gd3
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_extend.notest.gd23
-rw-r--r--modules/gltf/doc_classes/GLTFDocumentExtension.xml6
-rw-r--r--modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp8
-rw-r--r--modules/gltf/editor/editor_scene_importer_blend.cpp3
-rw-r--r--modules/gltf/editor/editor_scene_importer_fbx.cpp3
-rw-r--r--modules/gltf/editor/editor_scene_importer_gltf.cpp3
-rw-r--r--modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp4
-rw-r--r--modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.h4
-rw-r--r--modules/gltf/extensions/gltf_light.cpp2
-rw-r--r--modules/gltf/extensions/gltf_light.h4
-rw-r--r--modules/gltf/extensions/gltf_spec_gloss.cpp2
-rw-r--r--modules/gltf/extensions/gltf_spec_gloss.h3
-rw-r--r--modules/gltf/gltf_defines.h3
-rw-r--r--modules/gltf/gltf_document.cpp18
-rw-r--r--modules/gltf/gltf_document.h7
-rw-r--r--modules/gltf/gltf_state.cpp2
-rw-r--r--modules/gltf/gltf_state.h20
-rw-r--r--modules/gltf/register_types.cpp16
-rw-r--r--modules/gltf/structures/gltf_accessor.h3
-rw-r--r--modules/gltf/structures/gltf_animation.h2
-rw-r--r--modules/gltf/structures/gltf_camera.cpp2
-rw-r--r--modules/gltf/structures/gltf_camera.h3
-rw-r--r--modules/gltf/structures/gltf_mesh.h4
-rw-r--r--modules/gltf/structures/gltf_texture_sampler.h1
-rw-r--r--modules/gridmap/grid_map.cpp2
-rw-r--r--modules/navigation/godot_navigation_server.cpp28
-rw-r--r--modules/navigation/godot_navigation_server.h5
-rw-r--r--modules/navigation/nav_base.h4
44 files changed, 233 insertions, 172 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index c8195de640..b7feedaeaa 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -478,7 +478,7 @@ void GDScript::_clear_doc() {
void GDScript::_update_doc() {
_clear_doc();
- doc.script_path = "\"" + get_path().get_slice("://", 1) + "\"";
+ doc.script_path = vformat(R"("%s")", get_script_path().get_slice("://", 1));
if (!name.is_empty()) {
doc.name = name;
} else {
@@ -801,9 +801,9 @@ void GDScript::update_exports() {
String GDScript::_get_debug_path() const {
if (is_built_in() && !get_name().is_empty()) {
- return get_name() + " (" + get_path() + ")";
+ return vformat("%s(%s)", get_name(), get_script_path());
} else {
- return get_path();
+ return get_script_path();
}
}
@@ -904,7 +904,7 @@ Error GDScript::reload(bool p_keep_state) {
for (const GDScriptWarning &warning : parser.get_warnings()) {
if (EngineDebugger::is_active()) {
Vector<ScriptLanguage::StackInfo> si;
- EngineDebugger::get_script_debugger()->send_error("", get_path(), warning.start_line, warning.get_name(), warning.get_message(), false, ERR_HANDLER_WARNING, si);
+ EngineDebugger::get_script_debugger()->send_error("", get_script_path(), warning.start_line, warning.get_name(), warning.get_message(), false, ERR_HANDLER_WARNING, si);
}
}
#endif
@@ -1027,6 +1027,10 @@ void GDScript::set_path(const String &p_path, bool p_take_over) {
}
}
+String GDScript::get_script_path() const {
+ return path;
+}
+
Error GDScript::load_source_code(const String &p_path) {
if (p_path.is_empty() || ResourceLoader::get_resource_type(p_path.get_slice("::", 0)) == "PackedScene") {
return OK;
@@ -1347,13 +1351,11 @@ void GDScript::_get_dependencies(RBSet<GDScript *> &p_dependencies, const GDScri
GDScript::GDScript() :
script_list(this) {
-#ifdef DEBUG_ENABLED
{
MutexLock lock(GDScriptLanguage::get_singleton()->mutex);
GDScriptLanguage::get_singleton()->script_list.add(&script_list);
}
-#endif
}
void GDScript::_save_orphaned_subclasses() {
@@ -1487,13 +1489,11 @@ GDScript::~GDScript() {
}
}
-#ifdef DEBUG_ENABLED
{
MutexLock lock(GDScriptLanguage::get_singleton()->mutex);
GDScriptLanguage::get_singleton()->script_list.remove(&script_list);
}
-#endif
if (GDScriptCache::singleton) { // Cache may have been already destroyed at engine shutdown.
GDScriptCache::remove_script(get_path());
@@ -2164,7 +2164,8 @@ void GDScriptLanguage::reload_all_scripts() {
SelfList<GDScript> *elem = script_list.first();
while (elem) {
- if (elem->self()->get_path().is_resource_file()) {
+ // Scripts will reload all subclasses, so only reload root scripts.
+ if (elem->self()->is_root_script() && elem->self()->get_path().is_resource_file()) {
print_verbose("GDScript: Found: " + elem->self()->get_path());
scripts.push_back(Ref<GDScript>(elem->self())); //cast to gdscript to avoid being erased by accident
}
@@ -2193,7 +2194,8 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
SelfList<GDScript> *elem = script_list.first();
while (elem) {
- if (elem->self()->get_path().is_resource_file()) {
+ // Scripts will reload all subclasses, so only reload root scripts.
+ if (elem->self()->is_root_script() && elem->self()->get_path().is_resource_file()) {
scripts.push_back(Ref<GDScript>(elem->self())); //cast to gdscript to avoid being erased by accident
}
elem = elem->next();
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 2df89d812c..7911ea47ec 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -240,6 +240,7 @@ public:
virtual Error reload(bool p_keep_state = false) override;
virtual void set_path(const String &p_path, bool p_take_over = false) override;
+ String get_script_path() const;
Error load_source_code(const String &p_path);
Error load_byte_code(const String &p_path);
@@ -432,7 +433,7 @@ public:
csi.write[_debug_call_stack_pos - i - 1].line = _call_stack[i].line ? *_call_stack[i].line : 0;
if (_call_stack[i].function) {
csi.write[_debug_call_stack_pos - i - 1].func = _call_stack[i].function->get_name();
- csi.write[_debug_call_stack_pos - i - 1].file = _call_stack[i].function->get_script()->get_path();
+ csi.write[_debug_call_stack_pos - i - 1].file = _call_stack[i].function->get_script()->get_script_path();
}
}
return csi;
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index ad37fe7ec0..2892ae3f4e 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -219,6 +219,22 @@ Error GDScriptAnalyzer::check_class_member_name_conflict(const GDScriptParser::C
return OK;
}
+void GDScriptAnalyzer::get_class_node_current_scope_classes(GDScriptParser::ClassNode *p_node, List<GDScriptParser::ClassNode *> *p_list) {
+ if (p_list->find(p_node) != nullptr) {
+ return;
+ }
+ p_list->push_back(p_node);
+
+ // Prioritize node base type over its outer class
+ if (p_node->base_type.class_type != nullptr) {
+ get_class_node_current_scope_classes(p_node->base_type.class_type, p_list);
+ }
+
+ if (p_node->outer != nullptr) {
+ get_class_node_current_scope_classes(p_node->outer, p_list);
+ }
+}
+
Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class, bool p_recursive) {
if (p_class->base_type.is_set()) {
// Already resolved
@@ -327,9 +343,10 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class,
base.native_type = name;
} else {
// Look for other classes in script.
- GDScriptParser::ClassNode *look_class = p_class;
bool found = false;
- while (look_class != nullptr) {
+ List<GDScriptParser::ClassNode *> script_classes;
+ get_class_node_current_scope_classes(p_class, &script_classes);
+ for (GDScriptParser::ClassNode *look_class : script_classes) {
if (look_class->identifier && look_class->identifier->name == name) {
if (!look_class->get_datatype().is_set()) {
Error err = resolve_inheritance(look_class, false);
@@ -353,7 +370,6 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class,
found = true;
break;
}
- look_class = look_class->outer;
}
if (!found) {
@@ -517,12 +533,11 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type
result = make_native_enum_type(parser->current_class->base_type.native_type, first);
} else {
// Classes in current scope.
- GDScriptParser::ClassNode *script_class = parser->current_class;
- bool found = false;
- while (!found && script_class != nullptr) {
+ List<GDScriptParser::ClassNode *> script_classes;
+ get_class_node_current_scope_classes(parser->current_class, &script_classes);
+ for (GDScriptParser::ClassNode *script_class : script_classes) {
if (script_class->identifier && script_class->identifier->name == first) {
result = script_class->get_datatype();
- found = true;
break;
}
if (script_class->members_indices.has(first)) {
@@ -530,24 +545,21 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type
switch (member.type) {
case GDScriptParser::ClassNode::Member::CLASS:
result = member.m_class->get_datatype();
- found = true;
break;
case GDScriptParser::ClassNode::Member::ENUM:
result = member.m_enum->get_datatype();
- found = true;
break;
case GDScriptParser::ClassNode::Member::CONSTANT:
if (member.constant->get_datatype().is_meta_type) {
result = member.constant->get_datatype();
result.is_meta_type = false;
- found = true;
break;
} else if (Ref<Script>(member.constant->initializer->reduced_value).is_valid()) {
Ref<GDScript> gdscript = member.constant->initializer->reduced_value;
if (gdscript.is_valid()) {
- Ref<GDScriptParserRef> ref = get_parser_for(gdscript->get_path());
+ Ref<GDScriptParserRef> ref = get_parser_for(gdscript->get_script_path());
if (ref->raise_status(GDScriptParserRef::INTERFACE_SOLVED) != OK) {
- push_error(vformat(R"(Could not parse script from "%s".)", gdscript->get_path()), p_type);
+ push_error(vformat(R"(Could not parse script from "%s".)", gdscript->get_script_path()), p_type);
return GDScriptParser::DataType();
}
result = ref->get_parser()->head->get_datatype();
@@ -569,7 +581,6 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type
return GDScriptParser::DataType();
}
}
- script_class = script_class->outer;
}
}
if (!result.is_set()) {
@@ -2891,41 +2902,43 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
}
// Check outer constants.
// TODO: Allow outer static functions.
- GDScriptParser::ClassNode *outer = base_class->outer;
- while (outer != nullptr) {
- if (outer->has_member(name)) {
- const GDScriptParser::ClassNode::Member &member = outer->get_member(name);
- switch (member.type) {
- case GDScriptParser::ClassNode::Member::CONSTANT: {
- // TODO: Make sure loops won't cause problem. And make special error message for those.
- // For out-of-order resolution:
- reduce_expression(member.constant->initializer);
- p_identifier->set_datatype(member.get_datatype());
- p_identifier->is_constant = true;
- p_identifier->reduced_value = member.constant->initializer->reduced_value;
- return;
- } break;
- case GDScriptParser::ClassNode::Member::ENUM_VALUE: {
- p_identifier->set_datatype(member.get_datatype());
- p_identifier->is_constant = true;
- p_identifier->reduced_value = member.enum_value.value;
- return;
- } break;
- case GDScriptParser::ClassNode::Member::ENUM: {
- p_identifier->set_datatype(member.get_datatype());
- p_identifier->is_constant = false;
- return;
- } break;
- case GDScriptParser::ClassNode::Member::CLASS: {
- resolve_class_interface(member.m_class);
- p_identifier->set_datatype(member.m_class->get_datatype());
- return;
- } break;
- default:
- break;
+ if (base_class->outer != nullptr) {
+ List<GDScriptParser::ClassNode *> script_classes;
+ get_class_node_current_scope_classes(parser->current_class, &script_classes);
+ for (GDScriptParser::ClassNode *script_class : script_classes) {
+ if (script_class->has_member(name)) {
+ const GDScriptParser::ClassNode::Member &member = script_class->get_member(name);
+ switch (member.type) {
+ case GDScriptParser::ClassNode::Member::CONSTANT: {
+ // TODO: Make sure loops won't cause problem. And make special error message for those.
+ // For out-of-order resolution:
+ reduce_expression(member.constant->initializer);
+ p_identifier->set_datatype(member.get_datatype());
+ p_identifier->is_constant = true;
+ p_identifier->reduced_value = member.constant->initializer->reduced_value;
+ return;
+ } break;
+ case GDScriptParser::ClassNode::Member::ENUM_VALUE: {
+ p_identifier->set_datatype(member.get_datatype());
+ p_identifier->is_constant = true;
+ p_identifier->reduced_value = member.enum_value.value;
+ return;
+ } break;
+ case GDScriptParser::ClassNode::Member::ENUM: {
+ p_identifier->set_datatype(member.get_datatype());
+ p_identifier->is_constant = false;
+ return;
+ } break;
+ case GDScriptParser::ClassNode::Member::CLASS: {
+ resolve_class_interface(member.m_class);
+ p_identifier->set_datatype(member.m_class->get_datatype());
+ return;
+ } break;
+ default:
+ break;
+ }
}
}
- outer = outer->outer;
}
base_class = base_class->base_type.class_type;
@@ -3136,9 +3149,9 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
Variant constant = GDScriptLanguage::get_singleton()->get_named_globals_map()[name];
Node *node = Object::cast_to<Node>(constant);
if (node != nullptr) {
- Ref<Script> scr = node->get_script();
+ Ref<GDScript> scr = node->get_script();
if (scr.is_valid()) {
- Ref<GDScriptParserRef> singl_parser = get_parser_for(scr->get_path());
+ Ref<GDScriptParserRef> singl_parser = get_parser_for(scr->get_script_path());
if (singl_parser.is_valid()) {
Error err = singl_parser->raise_status(GDScriptParserRef::INTERFACE_SOLVED);
if (err == OK) {
@@ -3341,7 +3354,7 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri
Ref<GDScript> gdscr = Ref<GDScript>(p_subscript->base->reduced_value);
if (!valid && gdscr.is_valid()) {
Error err = OK;
- GDScriptCache::get_full_script(gdscr->get_path(), err);
+ GDScriptCache::get_full_script(gdscr->get_script_path(), err);
if (err == OK) {
value = p_subscript->base->reduced_value.get_named(p_subscript->attribute->name, valid);
}
@@ -3714,7 +3727,13 @@ GDScriptParser::DataType GDScriptAnalyzer::type_from_variant(const Variant &p_va
result.builtin_type = p_value.get_type();
result.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT; // Constant has explicit type.
- if (p_value.get_type() == Variant::OBJECT) {
+ if (p_value.get_type() == Variant::NIL) {
+ // A null value is a variant, not void.
+ result.kind = GDScriptParser::DataType::VARIANT;
+ } else if (p_value.get_type() == Variant::OBJECT) {
+ // Object is treated as a native type, not a builtin type.
+ result.kind = GDScriptParser::DataType::NATIVE;
+
Object *obj = p_value;
if (!obj) {
return GDScriptParser::DataType();
diff --git a/modules/gdscript/gdscript_analyzer.h b/modules/gdscript/gdscript_analyzer.h
index 23a3ad39a5..44ca1593ed 100644
--- a/modules/gdscript/gdscript_analyzer.h
+++ b/modules/gdscript/gdscript_analyzer.h
@@ -50,6 +50,8 @@ class GDScriptAnalyzer {
Error check_native_member_name_conflict(const StringName &p_member_name, const GDScriptParser::Node *p_member_node, const StringName &p_native_type_string);
Error check_class_member_name_conflict(const GDScriptParser::ClassNode *p_class_node, const StringName &p_member_name, const GDScriptParser::Node *p_member_node);
+ void get_class_node_current_scope_classes(GDScriptParser::ClassNode *p_node, List<GDScriptParser::ClassNode *> *p_list);
+
Error resolve_inheritance(GDScriptParser::ClassNode *p_class, bool p_recursive = true);
GDScriptParser::DataType resolve_datatype(GDScriptParser::TypeNode *p_type);
diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp
index fa158591fd..1bc83fbbb5 100644
--- a/modules/gdscript/gdscript_byte_codegen.cpp
+++ b/modules/gdscript/gdscript_byte_codegen.cpp
@@ -164,7 +164,7 @@ void GDScriptByteCodeGenerator::write_start(GDScript *p_script, const StringName
function->name = p_function_name;
function->_script = p_script;
- function->source = p_script->get_path();
+ function->source = p_script->get_script_path();
#ifdef DEBUG_ENABLED
function->func_cname = (String(function->source) + " - " + String(p_function_name)).utf8();
diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp
index 1df7757082..1dc5e335a0 100644
--- a/modules/gdscript/gdscript_cache.cpp
+++ b/modules/gdscript/gdscript_cache.cpp
@@ -128,6 +128,10 @@ void GDScriptCache::move_script(const String &p_from, const String &p_to) {
MutexLock lock(singleton->mutex);
+ if (singleton->cleared) {
+ return;
+ }
+
for (KeyValue<String, HashSet<String>> &E : singleton->packed_scene_dependencies) {
if (E.value.has(p_from)) {
E.value.insert(p_to);
@@ -158,6 +162,10 @@ void GDScriptCache::remove_script(const String &p_path) {
MutexLock lock(singleton->mutex);
+ if (singleton->cleared) {
+ return;
+ }
+
for (KeyValue<String, HashSet<String>> &E : singleton->packed_scene_dependencies) {
if (!E.value.has(p_path)) {
continue;
@@ -371,6 +379,10 @@ void GDScriptCache::clear_unreferenced_packed_scenes() {
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;
@@ -388,6 +400,11 @@ void GDScriptCache::clear() {
MutexLock lock(singleton->mutex);
+ if (singleton->cleared) {
+ return;
+ }
+ singleton->cleared = true;
+
RBSet<Ref<GDScriptParserRef>> parser_map_refs;
for (KeyValue<String, GDScriptParserRef *> &E : singleton->parser_map) {
parser_map_refs.insert(E.value);
@@ -417,7 +434,8 @@ GDScriptCache::GDScriptCache() {
}
GDScriptCache::~GDScriptCache() {
- destructing = true;
- clear();
+ if (!cleared) {
+ clear();
+ }
singleton = nullptr;
}
diff --git a/modules/gdscript/gdscript_cache.h b/modules/gdscript/gdscript_cache.h
index e7e1901d5d..0ee269f96c 100644
--- a/modules/gdscript/gdscript_cache.h
+++ b/modules/gdscript/gdscript_cache.h
@@ -87,7 +87,7 @@ class GDScriptCache {
static GDScriptCache *singleton;
- bool destructing = false;
+ bool cleared = false;
Mutex mutex;
@@ -104,13 +104,6 @@ public:
static Ref<PackedScene> get_packed_scene(const String &p_path, Error &r_error, const String &p_owner = "");
static void clear_unreferenced_packed_scenes();
- static bool is_destructing() {
- if (singleton == nullptr) {
- return true;
- }
- return singleton->destructing;
- };
-
static void clear();
GDScriptCache();
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index d3260d90a6..c0539c7e45 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -2117,8 +2117,8 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
if (EngineDebugger::is_active()) {
String signature;
// Path.
- if (!p_script->get_path().is_empty()) {
- signature += p_script->get_path();
+ if (!p_script->get_script_path().is_empty()) {
+ signature += p_script->get_script_path();
}
// Location.
if (p_func) {
diff --git a/modules/gdscript/gdscript_utility_functions.cpp b/modules/gdscript/gdscript_utility_functions.cpp
index bcbe8b8d2b..27b6792e84 100644
--- a/modules/gdscript/gdscript_utility_functions.cpp
+++ b/modules/gdscript/gdscript_utility_functions.cpp
@@ -294,6 +294,7 @@ struct GDScriptUtilityFunctionsDefinitions {
}
GDScript *p = base.ptr();
+ String path = p->get_script_path();
Vector<StringName> sname;
while (p->_owner) {
@@ -302,7 +303,7 @@ struct GDScriptUtilityFunctionsDefinitions {
}
sname.reverse();
- if (!p->path.is_resource_file()) {
+ if (!path.is_resource_file()) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::DICTIONARY;
@@ -317,7 +318,7 @@ struct GDScriptUtilityFunctionsDefinitions {
Dictionary d;
d["@subpath"] = cp;
- d["@path"] = p->get_path();
+ d["@path"] = path;
for (const KeyValue<StringName, GDScript::MemberInfo> &E : base->member_indices) {
if (!d.has(E.key)) {
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp
index c73ba798aa..fdcc0625d7 100644
--- a/modules/gdscript/gdscript_vm.cpp
+++ b/modules/gdscript/gdscript_vm.cpp
@@ -2227,7 +2227,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
#ifdef DEBUG_ENABLED
gdfs->state.function_name = name;
- gdfs->state.script_path = _script->get_path();
+ gdfs->state.script_path = _script->get_script_path();
#endif
gdfs->state.defarg = defarg;
gdfs->function = this;
diff --git a/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.gd b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.gd
new file mode 100644
index 0000000000..7881a0feb6
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.gd
@@ -0,0 +1,14 @@
+const A: = preload("base_outer_resolution_a.notest.gd")
+const B: = preload("base_outer_resolution_b.notest.gd")
+const C: = preload("base_outer_resolution_c.notest.gd")
+
+const Extend: = preload("base_outer_resolution_extend.notest.gd")
+
+func test() -> void:
+ Extend.test_a(A.new())
+ Extend.test_b(B.new())
+ Extend.InnerClass.test_c(C.new())
+ Extend.InnerClass.InnerInnerClass.test_a_b_c(A.new(), B.new(), C.new())
+ Extend.InnerClass.InnerInnerClass.test_enum(C.TestEnum.HELLO_WORLD)
+ Extend.InnerClass.InnerInnerClass.test_a_prime(A.APrime.new())
+
diff --git a/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.out b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.out
new file mode 100644
index 0000000000..bd27bd31f6
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.out
@@ -0,0 +1,7 @@
+GDTEST_OK
+true
+true
+true
+true
+true
+true
diff --git a/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_a.notest.gd b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_a.notest.gd
new file mode 100644
index 0000000000..966c8bfc8f
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_a.notest.gd
@@ -0,0 +1,2 @@
+class APrime:
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_b.notest.gd b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_b.notest.gd
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_b.notest.gd
diff --git a/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_base.notest.gd b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_base.notest.gd
new file mode 100644
index 0000000000..666b147ced
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_base.notest.gd
@@ -0,0 +1,4 @@
+const A: = preload("base_outer_resolution_a.notest.gd")
+
+class InnerClassInBase:
+ const C: = preload("base_outer_resolution_c.notest.gd")
diff --git a/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_c.notest.gd b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_c.notest.gd
new file mode 100644
index 0000000000..814be35314
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_c.notest.gd
@@ -0,0 +1,3 @@
+enum TestEnum {
+ HELLO_WORLD
+}
diff --git a/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_extend.notest.gd b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_extend.notest.gd
new file mode 100644
index 0000000000..fbd28779d4
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution_extend.notest.gd
@@ -0,0 +1,23 @@
+extends "base_outer_resolution_base.notest.gd"
+
+const B: = preload("base_outer_resolution_b.notest.gd")
+
+static func test_a(a: A) -> void:
+ print(a is A)
+
+static func test_b(b: B) -> void:
+ print(b is B)
+
+class InnerClass extends InnerClassInBase:
+ static func test_c(c: C) -> void:
+ print(c is C)
+
+ class InnerInnerClass:
+ static func test_a_b_c(a: A, b: B, c: C) -> void:
+ print(a is A and b is B and c is C)
+
+ static func test_enum(test_enum: C.TestEnum) -> void:
+ print(test_enum == C.TestEnum.HELLO_WORLD)
+
+ static func test_a_prime(a_prime: A.APrime) -> void:
+ print(a_prime is A.APrime)
diff --git a/modules/gltf/doc_classes/GLTFDocumentExtension.xml b/modules/gltf/doc_classes/GLTFDocumentExtension.xml
index 87d3d9bcb0..ac638a8962 100644
--- a/modules/gltf/doc_classes/GLTFDocumentExtension.xml
+++ b/modules/gltf/doc_classes/GLTFDocumentExtension.xml
@@ -45,7 +45,7 @@
<param index="0" name="root" type="Node" />
<description>
Part of the export process. This method is run first, before all other parts of the export process.
- The return value is used to determine if this GLTFDocumentExtension class should be used for exporting a given GLTF file. If [constant OK], the export will use this GLTFDocumentExtension class. If not overridden, [constant OK] is returned.
+ The return value is used to determine if this [GLTFDocumentExtension] instance should be used for exporting a given GLTF file. If [constant OK], the export will use this [GLTFDocumentExtension] instance. If not overridden, [constant OK] is returned.
</description>
</method>
<method name="_generate_scene_node" qualifiers="virtual">
@@ -99,7 +99,7 @@
<param index="1" name="extensions" type="PackedStringArray" />
<description>
Part of the import process. This method is run first, before all other parts of the import process.
- The return value is used to determine if this GLTFDocumentExtension class should be used for importing a given GLTF file. If [constant OK], the import will use this GLTFDocumentExtension class. If not overridden, [constant OK] is returned.
+ The return value is used to determine if this [GLTFDocumentExtension] instance should be used for importing a given GLTF file. If [constant OK], the import will use this [GLTFDocumentExtension] instance. If not overridden, [constant OK] is returned.
</description>
</method>
<method name="_parse_node_extensions" qualifiers="virtual">
@@ -109,7 +109,7 @@
<param index="2" name="extensions" type="Dictionary" />
<description>
Part of the import process. This method is run after [method _get_supported_extensions] and before [method _generate_scene_node].
- Runs when parsing the node extensions of a GLTFNode. This method can be used to process the extension JSON data into a format that can be used by [method _generate_scene_node].
+ Runs when parsing the node extensions of a GLTFNode. This method can be used to process the extension JSON data into a format that can be used by [method _generate_scene_node]. The return value should be a member of the [enum Error] enum.
</description>
</method>
</methods>
diff --git a/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
index 0c0b134bd1..fe63afcc56 100644
--- a/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
+++ b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
@@ -33,18 +33,10 @@
#include "editor_scene_exporter_gltf_plugin.h"
#include "../gltf_document.h"
-#include "../gltf_state.h"
-#include "core/config/project_settings.h"
-#include "core/error/error_list.h"
-#include "core/object/object.h"
-#include "core/templates/vector.h"
#include "editor/editor_file_dialog.h"
#include "editor/editor_file_system.h"
#include "editor/editor_node.h"
-#include "scene/3d/mesh_instance_3d.h"
-#include "scene/gui/check_box.h"
-#include "scene/main/node.h"
String SceneExporterGLTFPlugin::get_name() const {
return "ConvertGLTF2";
diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp
index 7007ea5d13..4dafa746bc 100644
--- a/modules/gltf/editor/editor_scene_importer_blend.cpp
+++ b/modules/gltf/editor/editor_scene_importer_blend.cpp
@@ -33,7 +33,6 @@
#ifdef TOOLS_ENABLED
#include "../gltf_document.h"
-#include "../gltf_state.h"
#include "core/config/project_settings.h"
#include "editor/editor_file_dialog.h"
@@ -42,8 +41,6 @@
#include "editor/editor_settings.h"
#include "main/main.h"
#include "scene/gui/line_edit.h"
-#include "scene/main/node.h"
-#include "scene/resources/animation.h"
#ifdef WINDOWS_ENABLED
// Code by Pedro Estebanez (https://github.com/godotengine/godot/pull/59766)
diff --git a/modules/gltf/editor/editor_scene_importer_fbx.cpp b/modules/gltf/editor/editor_scene_importer_fbx.cpp
index 14f2117413..fb5fb455b8 100644
--- a/modules/gltf/editor/editor_scene_importer_fbx.cpp
+++ b/modules/gltf/editor/editor_scene_importer_fbx.cpp
@@ -33,12 +33,9 @@
#ifdef TOOLS_ENABLED
#include "../gltf_document.h"
-#include "../gltf_state.h"
#include "core/config/project_settings.h"
#include "editor/editor_settings.h"
-#include "scene/main/node.h"
-#include "scene/resources/animation.h"
uint32_t EditorSceneFormatImporterFBX::get_import_flags() const {
return ImportFlags::IMPORT_SCENE | ImportFlags::IMPORT_ANIMATION;
diff --git a/modules/gltf/editor/editor_scene_importer_gltf.cpp b/modules/gltf/editor/editor_scene_importer_gltf.cpp
index a194719b91..bd1ba85abf 100644
--- a/modules/gltf/editor/editor_scene_importer_gltf.cpp
+++ b/modules/gltf/editor/editor_scene_importer_gltf.cpp
@@ -33,9 +33,6 @@
#include "editor_scene_importer_gltf.h"
#include "../gltf_document.h"
-#include "../gltf_state.h"
-
-#include "scene/resources/animation.h"
uint32_t EditorSceneFormatImporterGLTF::get_import_flags() const {
return ImportFlags::IMPORT_SCENE | ImportFlags::IMPORT_ANIMATION;
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 49496afb62..cfa498af65 100644
--- a/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp
+++ b/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp
@@ -30,9 +30,7 @@
#include "gltf_document_extension_convert_importer_mesh.h"
-#include "../gltf_state.h"
-
-#include "core/error/error_macros.h"
+#include "scene/3d/importer_mesh_instance_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/resources/importer_mesh.h"
diff --git a/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.h b/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.h
index 00e664e73f..4fbfa0e066 100644
--- a/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.h
+++ b/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.h
@@ -33,10 +33,6 @@
#include "gltf_document_extension.h"
-#include "scene/3d/importer_mesh_instance_3d.h"
-#include "scene/3d/mesh_instance_3d.h"
-#include "scene/resources/importer_mesh.h"
-
class GLTFDocumentExtensionConvertImporterMesh : public GLTFDocumentExtension {
GDCLASS(GLTFDocumentExtensionConvertImporterMesh, GLTFDocumentExtension);
diff --git a/modules/gltf/extensions/gltf_light.cpp b/modules/gltf/extensions/gltf_light.cpp
index d00bead61c..0379c62c9d 100644
--- a/modules/gltf/extensions/gltf_light.cpp
+++ b/modules/gltf/extensions/gltf_light.cpp
@@ -30,6 +30,8 @@
#include "gltf_light.h"
+#include "scene/3d/light_3d.h"
+
void GLTFLight::_bind_methods() {
ClassDB::bind_static_method("GLTFLight", D_METHOD("from_node", "light_node"), &GLTFLight::from_node);
ClassDB::bind_method(D_METHOD("to_node"), &GLTFLight::to_node);
diff --git a/modules/gltf/extensions/gltf_light.h b/modules/gltf/extensions/gltf_light.h
index 04980e144c..85284f1d0e 100644
--- a/modules/gltf/extensions/gltf_light.h
+++ b/modules/gltf/extensions/gltf_light.h
@@ -31,9 +31,9 @@
#ifndef GLTF_LIGHT_H
#define GLTF_LIGHT_H
-#include "core/config/engine.h"
#include "core/io/resource.h"
-#include "scene/3d/light_3d.h"
+
+class Light3D;
// https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual
diff --git a/modules/gltf/extensions/gltf_spec_gloss.cpp b/modules/gltf/extensions/gltf_spec_gloss.cpp
index 83af91bfcc..0645f31e01 100644
--- a/modules/gltf/extensions/gltf_spec_gloss.cpp
+++ b/modules/gltf/extensions/gltf_spec_gloss.cpp
@@ -30,6 +30,8 @@
#include "gltf_spec_gloss.h"
+#include "core/io/image.h"
+
void GLTFSpecGloss::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_diffuse_img"), &GLTFSpecGloss::get_diffuse_img);
ClassDB::bind_method(D_METHOD("set_diffuse_img", "diffuse_img"), &GLTFSpecGloss::set_diffuse_img);
diff --git a/modules/gltf/extensions/gltf_spec_gloss.h b/modules/gltf/extensions/gltf_spec_gloss.h
index 2b4d3ee609..56474acd03 100644
--- a/modules/gltf/extensions/gltf_spec_gloss.h
+++ b/modules/gltf/extensions/gltf_spec_gloss.h
@@ -31,9 +31,10 @@
#ifndef GLTF_SPEC_GLOSS_H
#define GLTF_SPEC_GLOSS_H
-#include "core/io/image.h"
#include "core/io/resource.h"
+class Image;
+
// KHR_materials_pbrSpecularGlossiness is an archived GLTF extension.
// This means that it is deprecated and not recommended for new files.
// However, it is still supported for loading old files.
diff --git a/modules/gltf/gltf_defines.h b/modules/gltf/gltf_defines.h
index 23bf33869e..7b990e6573 100644
--- a/modules/gltf/gltf_defines.h
+++ b/modules/gltf/gltf_defines.h
@@ -36,9 +36,10 @@
// Godot classes used by GLTF headers.
class BoneAttachment3D;
class CSGShape3D;
-class DirectionalLight3D;
class GridMap;
+class ImporterMeshInstance3D;
class Light3D;
+class MeshInstance3D;
class MultiMeshInstance3D;
class Skeleton3D;
class Skin;
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index a3685daf0e..a4be0629c4 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -31,31 +31,23 @@
#include "gltf_document.h"
#include "extensions/gltf_spec_gloss.h"
-#include "gltf_state.h"
#include "core/crypto/crypto_core.h"
-#include "core/error/error_macros.h"
#include "core/io/dir_access.h"
#include "core/io/file_access.h"
#include "core/io/file_access_memory.h"
#include "core/io/json.h"
#include "core/io/stream_peer.h"
#include "core/math/disjoint_set.h"
-#include "core/math/vector2.h"
-#include "core/variant/dictionary.h"
-#include "core/variant/typed_array.h"
-#include "core/variant/variant.h"
#include "core/version.h"
#include "drivers/png/png_driver_common.h"
-#include "scene/2d/node_2d.h"
+#include "scene/3d/bone_attachment_3d.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/importer_mesh_instance_3d.h"
+#include "scene/3d/light_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/multimesh_instance_3d.h"
-#include "scene/3d/node_3d.h"
-#include "scene/animation/animation_player.h"
-#include "scene/resources/importer_mesh.h"
-#include "scene/resources/material.h"
-#include "scene/resources/mesh.h"
-#include "scene/resources/multimesh.h"
+#include "scene/resources/skin.h"
#include "scene/resources/surface_tool.h"
#include "modules/modules_enabled.gen.h" // For csg, gridmap.
diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h
index 6eb38354a2..45cb639a19 100644
--- a/modules/gltf/gltf_document.h
+++ b/modules/gltf/gltf_document.h
@@ -32,13 +32,6 @@
#define GLTF_DOCUMENT_H
#include "extensions/gltf_document_extension.h"
-#include "structures/gltf_animation.h"
-
-#include "scene/3d/bone_attachment_3d.h"
-#include "scene/3d/importer_mesh_instance_3d.h"
-#include "scene/3d/mesh_instance_3d.h"
-#include "scene/animation/animation_player.h"
-#include "scene/resources/material.h"
#include "modules/modules_enabled.gen.h" // For csg, gridmap.
diff --git a/modules/gltf/gltf_state.cpp b/modules/gltf/gltf_state.cpp
index 6654c9e5d2..9f6cb20935 100644
--- a/modules/gltf/gltf_state.cpp
+++ b/modules/gltf/gltf_state.cpp
@@ -30,6 +30,8 @@
#include "gltf_state.h"
+#include "gltf_template_convert.h"
+
void GLTFState::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_used_extension", "extension_name", "required"), &GLTFState::add_used_extension);
ClassDB::bind_method(D_METHOD("get_json"), &GLTFState::get_json);
diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h
index 1c20520b22..e264da69e0 100644
--- a/modules/gltf/gltf_state.h
+++ b/modules/gltf/gltf_state.h
@@ -32,7 +32,6 @@
#define GLTF_STATE_H
#include "extensions/gltf_light.h"
-#include "gltf_template_convert.h"
#include "structures/gltf_accessor.h"
#include "structures/gltf_animation.h"
#include "structures/gltf_buffer_view.h"
@@ -44,10 +43,6 @@
#include "structures/gltf_texture.h"
#include "structures/gltf_texture_sampler.h"
-#include "core/templates/rb_map.h"
-#include "scene/animation/animation_player.h"
-#include "scene/resources/texture.h"
-
class GLTFState : public Resource {
GDCLASS(GLTFState, Resource);
friend class GLTFDocument;
@@ -194,21 +189,6 @@ public:
Variant get_additional_data(const StringName &p_extension_name);
void set_additional_data(const StringName &p_extension_name, Variant p_additional_data);
-
- //void set_scene_nodes(RBMap<GLTFNodeIndex, Node *> p_scene_nodes) {
- // this->scene_nodes = p_scene_nodes;
- //}
-
- //void set_animation_players(Vector<AnimationPlayer *> p_animation_players) {
- // this->animation_players = p_animation_players;
- //}
-
- //RBMap<Ref<Material>, GLTFMaterialIndex> get_material_cache() {
- // return this->material_cache;
- //}
- //void set_material_cache(RBMap<Ref<Material>, GLTFMaterialIndex> p_material_cache) {
- // this->material_cache = p_material_cache;
- //}
};
#endif // GLTF_STATE_H
diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp
index a7abf256ce..cd7a23fbb2 100644
--- a/modules/gltf/register_types.cpp
+++ b/modules/gltf/register_types.cpp
@@ -30,23 +30,9 @@
#include "register_types.h"
-#ifndef _3D_DISABLED
-
#include "extensions/gltf_document_extension_convert_importer_mesh.h"
-#include "extensions/gltf_light.h"
#include "extensions/gltf_spec_gloss.h"
#include "gltf_document.h"
-#include "gltf_state.h"
-#include "structures/gltf_accessor.h"
-#include "structures/gltf_animation.h"
-#include "structures/gltf_buffer_view.h"
-#include "structures/gltf_camera.h"
-#include "structures/gltf_mesh.h"
-#include "structures/gltf_node.h"
-#include "structures/gltf_skeleton.h"
-#include "structures/gltf_skin.h"
-#include "structures/gltf_texture.h"
-#include "structures/gltf_texture_sampler.h"
#ifdef TOOLS_ENABLED
#include "core/config/project_settings.h"
@@ -172,5 +158,3 @@ void uninitialize_gltf_module(ModuleInitializationLevel p_level) {
}
GLTFDocument::unregister_all_gltf_document_extensions();
}
-
-#endif // _3D_DISABLED
diff --git a/modules/gltf/structures/gltf_accessor.h b/modules/gltf/structures/gltf_accessor.h
index bfb71d57fe..8e4bb2d3f9 100644
--- a/modules/gltf/structures/gltf_accessor.h
+++ b/modules/gltf/structures/gltf_accessor.h
@@ -31,9 +31,8 @@
#ifndef GLTF_ACCESSOR_H
#define GLTF_ACCESSOR_H
-#include "core/io/resource.h"
-
#include "../gltf_defines.h"
+#include "core/io/resource.h"
struct GLTFAccessor : public Resource {
GDCLASS(GLTFAccessor, Resource);
diff --git a/modules/gltf/structures/gltf_animation.h b/modules/gltf/structures/gltf_animation.h
index 3777f579f6..fc535631bb 100644
--- a/modules/gltf/structures/gltf_animation.h
+++ b/modules/gltf/structures/gltf_animation.h
@@ -31,7 +31,7 @@
#ifndef GLTF_ANIMATION_H
#define GLTF_ANIMATION_H
-#include "core/io/resource.h"
+#include "scene/animation/animation_player.h"
class GLTFAnimation : public Resource {
GDCLASS(GLTFAnimation, Resource);
diff --git a/modules/gltf/structures/gltf_camera.cpp b/modules/gltf/structures/gltf_camera.cpp
index 212b9b80c8..7a5ab2763c 100644
--- a/modules/gltf/structures/gltf_camera.cpp
+++ b/modules/gltf/structures/gltf_camera.cpp
@@ -30,6 +30,8 @@
#include "gltf_camera.h"
+#include "scene/3d/camera_3d.h"
+
void GLTFCamera::_bind_methods() {
ClassDB::bind_static_method("GLTFCamera", D_METHOD("from_node", "camera_node"), &GLTFCamera::from_node);
ClassDB::bind_method(D_METHOD("to_node"), &GLTFCamera::to_node);
diff --git a/modules/gltf/structures/gltf_camera.h b/modules/gltf/structures/gltf_camera.h
index 50ae10e17a..14b8efdde6 100644
--- a/modules/gltf/structures/gltf_camera.h
+++ b/modules/gltf/structures/gltf_camera.h
@@ -32,7 +32,8 @@
#define GLTF_CAMERA_H
#include "core/io/resource.h"
-#include "scene/3d/camera_3d.h"
+
+class Camera3D;
// Reference and test file:
// https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_015_SimpleCameras.md
diff --git a/modules/gltf/structures/gltf_mesh.h b/modules/gltf/structures/gltf_mesh.h
index 2fa37fd727..92722ce75c 100644
--- a/modules/gltf/structures/gltf_mesh.h
+++ b/modules/gltf/structures/gltf_mesh.h
@@ -31,10 +31,8 @@
#ifndef GLTF_MESH_H
#define GLTF_MESH_H
-#include "core/io/resource.h"
-#include "scene/3d/importer_mesh_instance_3d.h"
+#include "../gltf_defines.h"
#include "scene/resources/importer_mesh.h"
-#include "scene/resources/mesh.h"
class GLTFMesh : public Resource {
GDCLASS(GLTFMesh, Resource);
diff --git a/modules/gltf/structures/gltf_texture_sampler.h b/modules/gltf/structures/gltf_texture_sampler.h
index 3fad31bbee..7bb7cd62e3 100644
--- a/modules/gltf/structures/gltf_texture_sampler.h
+++ b/modules/gltf/structures/gltf_texture_sampler.h
@@ -31,7 +31,6 @@
#ifndef GLTF_TEXTURE_SAMPLER_H
#define GLTF_TEXTURE_SAMPLER_H
-#include "core/io/resource.h"
#include "scene/resources/material.h"
class GLTFTextureSampler : public Resource {
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index de50e9ea1e..06ad806afc 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -656,6 +656,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
if (bake_navigation) {
RID region = NavigationServer3D::get_singleton()->region_create();
+ NavigationServer3D::get_singleton()->region_set_owner_id(region, get_instance_id());
NavigationServer3D::get_singleton()->region_set_navigation_layers(region, navigation_layers);
NavigationServer3D::get_singleton()->region_set_navmesh(region, navmesh);
NavigationServer3D::get_singleton()->region_set_transform(region, get_global_transform() * nm.xform);
@@ -779,6 +780,7 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
Ref<NavigationMesh> nm = mesh_library->get_item_navmesh(cell_map[F.key].item);
if (nm.is_valid()) {
RID region = NavigationServer3D::get_singleton()->region_create();
+ NavigationServer3D::get_singleton()->region_set_owner_id(region, get_instance_id());
NavigationServer3D::get_singleton()->region_set_navigation_layers(region, navigation_layers);
NavigationServer3D::get_singleton()->region_set_navmesh(region, nm);
NavigationServer3D::get_singleton()->region_set_transform(region, get_global_transform() * F.value.xform);
diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp
index 8ca73a3adb..0e40e5a4af 100644
--- a/modules/navigation/godot_navigation_server.cpp
+++ b/modules/navigation/godot_navigation_server.cpp
@@ -383,6 +383,20 @@ real_t GodotNavigationServer::region_get_travel_cost(RID p_region) const {
return region->get_travel_cost();
}
+COMMAND_2(region_set_owner_id, RID, p_region, ObjectID, p_owner_id) {
+ NavRegion *region = region_owner.get_or_null(p_region);
+ ERR_FAIL_COND(region == nullptr);
+
+ region->set_owner_id(p_owner_id);
+}
+
+ObjectID GodotNavigationServer::region_get_owner_id(RID p_region) const {
+ const NavRegion *region = region_owner.get_or_null(p_region);
+ ERR_FAIL_COND_V(region == nullptr, ObjectID());
+
+ return region->get_owner_id();
+}
+
bool GodotNavigationServer::region_owns_point(RID p_region, const Vector3 &p_point) const {
const NavRegion *region = region_owner.get_or_null(p_region);
ERR_FAIL_COND_V(region == nullptr, false);
@@ -570,6 +584,20 @@ real_t GodotNavigationServer::link_get_travel_cost(const RID p_link) const {
return link->get_travel_cost();
}
+COMMAND_2(link_set_owner_id, RID, p_link, ObjectID, p_owner_id) {
+ NavLink *link = link_owner.get_or_null(p_link);
+ ERR_FAIL_COND(link == nullptr);
+
+ link->set_owner_id(p_owner_id);
+}
+
+ObjectID GodotNavigationServer::link_get_owner_id(RID p_link) const {
+ const NavLink *link = link_owner.get_or_null(p_link);
+ ERR_FAIL_COND_V(link == nullptr, ObjectID());
+
+ return link->get_owner_id();
+}
+
RID GodotNavigationServer::agent_create() const {
GodotNavigationServer *mut_this = const_cast<GodotNavigationServer *>(this);
MutexLock lock(mut_this->operations_mutex);
diff --git a/modules/navigation/godot_navigation_server.h b/modules/navigation/godot_navigation_server.h
index ab5e722d35..08ad545b37 100644
--- a/modules/navigation/godot_navigation_server.h
+++ b/modules/navigation/godot_navigation_server.h
@@ -125,6 +125,9 @@ public:
COMMAND_2(region_set_travel_cost, RID, p_region, real_t, p_travel_cost);
virtual real_t region_get_travel_cost(RID p_region) const override;
+ COMMAND_2(region_set_owner_id, RID, p_region, ObjectID, p_owner_id);
+ virtual ObjectID region_get_owner_id(RID p_region) const override;
+
virtual bool region_owns_point(RID p_region, const Vector3 &p_point) const override;
COMMAND_2(region_set_map, RID, p_region, RID, p_map);
@@ -153,6 +156,8 @@ public:
virtual real_t link_get_enter_cost(RID p_link) const override;
COMMAND_2(link_set_travel_cost, RID, p_link, real_t, p_travel_cost);
virtual real_t link_get_travel_cost(RID p_link) const override;
+ COMMAND_2(link_set_owner_id, RID, p_link, ObjectID, p_owner_id);
+ virtual ObjectID link_get_owner_id(RID p_link) const override;
virtual RID agent_create() const override;
COMMAND_2(agent_set_map, RID, p_agent, RID, p_map);
diff --git a/modules/navigation/nav_base.h b/modules/navigation/nav_base.h
index 6dfaaf9af4..f5d2880d36 100644
--- a/modules/navigation/nav_base.h
+++ b/modules/navigation/nav_base.h
@@ -41,6 +41,7 @@ protected:
uint32_t navigation_layers = 1;
float enter_cost = 0.0;
float travel_cost = 1.0;
+ ObjectID owner_id;
public:
void set_navigation_layers(uint32_t p_navigation_layers) { navigation_layers = p_navigation_layers; }
@@ -51,6 +52,9 @@ public:
void set_travel_cost(float p_travel_cost) { travel_cost = MAX(p_travel_cost, 0.0); }
float get_travel_cost() const { return travel_cost; }
+
+ void set_owner_id(ObjectID p_owner_id) { owner_id = p_owner_id; }
+ ObjectID get_owner_id() const { return owner_id; }
};
#endif // NAV_BASE_H