Merge pull request #12852 from djrm/pr_import_fixes

Update meshes when reimporting,
This commit is contained in:
Rémi Verschelde 2017-11-12 21:17:58 +01:00 committed by GitHub
commit 47e5b43160
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 25 deletions

View File

@ -821,8 +821,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
scan_actions.push_back(ia);
}
}
EditorResourcePreview::get_singleton()->check_for_invalidation(p_dir->get_file_path(i));
}
for (int i = 0; i < p_dir->subdirs.size(); i++) {
@ -1266,7 +1264,6 @@ void EditorFileSystem::update_file(const String &p_file) {
fs->files[cpos]->deps = _get_dependencies(p_file);
fs->files[cpos]->import_valid = ResourceLoader::is_import_valid(p_file);
EditorResourcePreview::get_singleton()->call_deferred("check_for_invalidation", p_file);
call_deferred("emit_signal", "filesystem_changed"); //update later
}
@ -1436,6 +1433,8 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
r->set_import_last_modified_time(0);
}
}
EditorResourcePreview::get_singleton()->check_for_invalidation(p_file);
}
void EditorFileSystem::reimport_files(const Vector<String> &p_files) {

View File

@ -872,7 +872,7 @@ void EditorNode::_find_node_types(Node *p_node, int &count_2d, int &count_3d) {
_find_node_types(p_node->get_child(i), count_2d, count_3d);
}
void EditorNode::_save_scene_with_preview(String p_file) {
void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
EditorProgress save("save", TTR("Saving Scene"), 4);
save.step(TTR("Analyzing"), 0);
@ -938,7 +938,7 @@ void EditorNode::_save_scene_with_preview(String p_file) {
}
save.step(TTR("Saving Scene"), 4);
_save_scene(p_file);
_save_scene(p_file, p_idx);
EditorResourcePreview::get_singleton()->check_for_invalidation(p_file);
}
@ -1096,10 +1096,7 @@ void EditorNode::_dialog_action(String p_file) {
if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
_save_default_environment();
if (scene_idx != editor_data.get_edited_scene())
_save_scene(p_file, scene_idx);
else
_save_scene_with_preview(p_file);
_save_scene_with_preview(p_file, scene_idx);
if (scene_idx != -1)
_discard_changes();
@ -1826,7 +1823,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
if (scene && scene->get_filename() != "") {
if (scene_idx != editor_data.get_edited_scene())
_save_scene(scene->get_filename(), scene_idx);
_save_scene_with_preview(scene->get_filename(), scene_idx);
else
_save_scene_with_preview(scene->get_filename());

View File

@ -503,7 +503,7 @@ private:
void _mark_unsaved_scenes();
void _find_node_types(Node *p_node, int &count_2d, int &count_3d);
void _save_scene_with_preview(String p_file);
void _save_scene_with_preview(String p_file, int p_idx = -1);
Map<String, Set<String> > dependency_errors;

View File

@ -86,7 +86,6 @@ void EditorResourcePreview::_thread_func(void *ud) {
void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture> &p_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) {
//print_line("preview is ready");
preview_mutex->lock();
String path = p_str;
@ -121,7 +120,6 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem &p_item, c
type = p_item.resource->get_class();
else
type = ResourceLoader::get_resource_type(p_item.path);
//print_line("resource type is: "+type);
if (type == "")
return Ref<Texture>(); //could not guess type
@ -144,7 +142,6 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem &p_item, c
if (!p_item.resource.is_valid()) {
// cache the preview in case it's a resource on disk
if (generated.is_valid()) {
//print_line("was generated");
int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
thumbnail_size *= EDSCALE;
//wow it generated a preview... save cache
@ -164,15 +161,11 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem &p_item, c
void EditorResourcePreview::_thread() {
//print_line("begin thread");
while (!exit) {
//print_line("wait for semaphore");
preview_sem->wait();
preview_mutex->lock();
//print_line("blue team go");
if (queue.size()) {
QueueItem item = queue.front()->get();
@ -189,12 +182,11 @@ void EditorResourcePreview::_thread() {
preview_mutex->unlock();
} else {
preview_mutex->unlock();
Ref<ImageTexture> texture;
//print_line("pop from queue "+item.path);
int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
thumbnail_size *= EDSCALE;
@ -304,7 +296,6 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p
cache.erase(path_id); //erase if exists, since it will be regen
//print_line("send to thread "+p_path);
QueueItem item;
item.function = p_receiver_func;
item.id = p_receiver->get_instance_id();
@ -328,7 +319,6 @@ void EditorResourcePreview::queue_resource_preview(const String &p_path, Object
return;
}
//print_line("send to thread "+p_path);
QueueItem item;
item.function = p_receiver_func;
item.id = p_receiver->get_instance_id();

View File

@ -574,7 +574,6 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) {
ERR_FAIL_COND_V(!d.has("format"), false);
uint32_t format = d["format"];
ERR_FAIL_COND_V(!d.has("primitive"), false);
uint32_t primitive = d["primitive"];
ERR_FAIL_COND_V(!d.has("vertex_count"), false);
@ -598,8 +597,8 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) {
Rect3 aabb = d["aabb"];
Vector<Rect3> bone_aabb;
if (d.has("bone_aabb")) {
Array baabb = d["bone_aabb"];
if (d.has("skeleton_aabb")) {
Array baabb = d["skeleton_aabb"];
bone_aabb.resize(baabb.size());
for (int i = 0; i < baabb.size(); i++) {
@ -1090,6 +1089,14 @@ void ArrayMesh::_bind_methods() {
BIND_ENUM_CONSTANT(ARRAY_FORMAT_INDEX);
}
void ArrayMesh::reload_from_file() {
for (int i = 0; i < get_surface_count(); i++) {
surface_remove(i);
}
Resource::reload_from_file();
String path = get_path();
}
ArrayMesh::ArrayMesh() {
mesh = VisualServer::get_singleton()->mesh_create();

View File

@ -213,6 +213,8 @@ public:
void center_geometry();
void regen_normalmaps();
virtual void reload_from_file();
ArrayMesh();
~ArrayMesh();