You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Add Blender install autodetection and configuration.
This PR is a continuation to #54886 * Changed Blender path editor setting from binary to installation. * Add a class to query whether the format is supported. * This class allows to create proper editors to configure support. **NOTE**: This PR only provides autodetection on Linux. Code needs to be added for Windows and MacOS to autodetect the Blender installation. Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com> Co-authored-by: Pedro J. Estébanez <pedrojrulez@gmail.com>
This commit is contained in:
@@ -520,6 +520,45 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
|
||||
return false; //nothing changed
|
||||
}
|
||||
|
||||
bool EditorFileSystem::_scan_import_support(Vector<String> reimports) {
|
||||
if (import_support_queries.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
Map<String, int> import_support_test;
|
||||
Vector<bool> import_support_tested;
|
||||
import_support_tested.resize(import_support_queries.size());
|
||||
for (int i = 0; i < import_support_queries.size(); i++) {
|
||||
import_support_tested.write[i] = false;
|
||||
if (import_support_queries[i]->is_active()) {
|
||||
Vector<String> extensions = import_support_queries[i]->get_file_extensions();
|
||||
for (int j = 0; j < extensions.size(); j++) {
|
||||
import_support_test.insert(extensions[j], i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (import_support_test.size() == 0) {
|
||||
return false; //well nothing to do
|
||||
}
|
||||
|
||||
for (int i = 0; i < reimports.size(); i++) {
|
||||
Map<String, int>::Element *E = import_support_test.find(reimports[i].get_extension());
|
||||
if (E) {
|
||||
import_support_tested.write[E->get()] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < import_support_tested.size(); i++) {
|
||||
if (import_support_tested[i]) {
|
||||
if (import_support_queries.write[i]->query()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EditorFileSystem::_update_scan_actions() {
|
||||
sources_changed.clear();
|
||||
|
||||
@@ -612,7 +651,7 @@ bool EditorFileSystem::_update_scan_actions() {
|
||||
if (_scan_extensions()) {
|
||||
//needs editor restart
|
||||
//extensions also may provide filetypes to be imported, so they must run before importing
|
||||
if (EditorNode::immediate_confirmation_dialog(TTR("Some extensions need the editor to restart to take effect."), first_scan ? TTR("Restart") : TTR("Save&Restart"), TTR("Continue"))) {
|
||||
if (EditorNode::immediate_confirmation_dialog(TTR("Some extensions need the editor to restart to take effect."), first_scan ? TTR("Restart") : TTR("Save & Restart"), TTR("Continue"))) {
|
||||
if (!first_scan) {
|
||||
EditorNode::get_singleton()->save_all_scenes();
|
||||
}
|
||||
@@ -621,7 +660,12 @@ bool EditorFileSystem::_update_scan_actions() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (reimports.size()) {
|
||||
if (_scan_import_support(reimports)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
reimport_files(reimports);
|
||||
} else {
|
||||
//reimport files will update the uid cache file so if nothing was reimported, update it manually
|
||||
@@ -2274,6 +2318,7 @@ static void _scan_extensions_dir(EditorFileSystemDirectory *d, Set<String> &exte
|
||||
bool EditorFileSystem::_scan_extensions() {
|
||||
EditorFileSystemDirectory *d = get_filesystem();
|
||||
Set<String> extensions;
|
||||
|
||||
_scan_extensions_dir(d, extensions);
|
||||
|
||||
//verify against loaded extensions
|
||||
@@ -2374,6 +2419,14 @@ void EditorFileSystem::_update_extensions() {
|
||||
}
|
||||
}
|
||||
|
||||
void EditorFileSystem::add_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query) {
|
||||
ERR_FAIL_COND(import_support_queries.find(p_query) != -1);
|
||||
import_support_queries.push_back(p_query);
|
||||
}
|
||||
void EditorFileSystem::remove_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query) {
|
||||
import_support_queries.erase(p_query);
|
||||
}
|
||||
|
||||
EditorFileSystem::EditorFileSystem() {
|
||||
ResourceLoader::import = _resource_import;
|
||||
reimport_on_missing_imported_files = GLOBAL_DEF("editor/import/reimport_missing_imported_files", true);
|
||||
|
||||
Reference in New Issue
Block a user