Fixed error using the same atlas rect for all images, closes #4139

(cherry picked from commit 3edf66477a)
This commit is contained in:
Juan Linietsky 2016-06-21 20:51:41 -03:00 committed by Rémi Verschelde
parent 5b3551a91f
commit 140949e013
2 changed files with 13 additions and 2 deletions

View File

@ -810,9 +810,11 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
//imd->set_editor(); //imd->set_editor();
for (List<StringName>::Element *F=atlas_images.front();F;F=F->next()) { for (List<StringName>::Element *F=atlas_images.front();F;F=F->next()) {
imd->add_source(EditorImportPlugin::validate_source_path(F->get()),FileAccess::get_md5(F->get())); imd->add_source(EditorImportPlugin::validate_source_path(F->get()),FileAccess::get_md5(F->get()));
} }

View File

@ -1217,21 +1217,30 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
ERR_CONTINUE( !source_map.has(i) ); ERR_CONTINUE( !source_map.has(i) );
for (List<int>::Element *E=source_map[i].front();E;E=E->next()) { for (List<int>::Element *E=source_map[i].front();E;E=E->next()) {
String apath = p_path.get_base_dir().plus_file(from->get_source_path(E->get()).get_file().basename()+".atex"); String apath;
String spath = from->get_source_path(E->get()).get_file();
if (p_external) {
apath = p_path.get_base_dir().plus_file(spath.basename()+"."+from->get_source_path(E->get()).md5_text()+".atex");
} else {
apath = p_path.get_base_dir().plus_file(spath.basename()+".atex");
}
Ref<AtlasTexture> at; Ref<AtlasTexture> at;
if (ResourceCache::has(apath)) { if (ResourceCache::has(apath)) {
at = Ref<AtlasTexture>( ResourceCache::get(apath)->cast_to<AtlasTexture>() ); at = Ref<AtlasTexture>( ResourceCache::get(apath)->cast_to<AtlasTexture>() );
} else { } else {
at = Ref<AtlasTexture>( memnew( AtlasTexture ) ); at = Ref<AtlasTexture>( memnew( AtlasTexture ) );
} }
at->set_region(region); at->set_region(region);
at->set_margin(margin); at->set_margin(margin);
at->set_path(apath); at->set_path(apath);
atlases[E->get()]=at; atlases[E->get()]=at;
print_line("Atlas Tex: "+apath);
} }
} }
if (ResourceCache::has(p_path)) { if (ResourceCache::has(p_path)) {