From 07e97414250827c3b930befa123a4bbd48d24861 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 23 Aug 2015 20:15:56 -0300 Subject: **WARNING BEFORE PULLING** This push changes the binary and XML formats and bumps the major version to 2.0. As such, files saved in this version WILL NO LONGER WORK IN PREVIOUS VERSIONS. This compatibility breakage with older versions was required in order to properly provide project refactoring tools. If I were you, unless you are brave, I would wait a week or two before pulling, in case of bugs :) Summary of Changes -New Filesystem dock, with filesystem & tree view modes. -New refactoring tools, to change or fix dependencies. -Quick search dialog, to quickly search any file --- tools/editor/project_export.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools/editor/project_export.cpp') diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index a087f23c2..626fc6e6d 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -80,7 +80,7 @@ bool ProjectExportDialog::_create_tree(TreeItem *p_parent,EditorFileSystemDirect String path = p_dir->get_file_path(i); fitem->set_tooltip(0,path); fitem->set_metadata(0,path); - Ref icon = get_icon( (has_icon(p_dir->get_file_type(i),"EditorIcons")?p_dir->get_file_type(i):String("Object")),"EditorIcons"); + Ref icon = get_icon( (has_icon(p_dir->get_file_type(i),ei)?p_dir->get_file_type(i):ot),ei); fitem->set_icon(0,icon); fitem->set_cell_mode(1,TreeItem::CELL_MODE_RANGE); @@ -1372,6 +1372,8 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { button_export = add_button("Export..",!OS::get_singleton()->get_swap_ok_cancel(),"export_pck"); updating_script=false; + ei="EditorIcons"; + ot="Object"; } -- cgit v1.2.3-70-g09d2 From b0aa49accbd7e45dae38f1bd43b0fbdd11714211 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 3 Sep 2015 23:24:55 -0300 Subject: merged some stuff for okam --- core/error_macros.h | 18 +- core/globals.cpp | 2 +- core/io/compression.cpp | 4 +- core/io/image_loader.cpp | 11 +- core/io/ioapi.h | 1 - core/io/zip.h | 2 + core/io/zip_io.h | 1 + core/typedefs.h | 4 +- core/variant.cpp | 12 +- demos/2d/platformer/engine.cfg | 9 +- drivers/gles2/shader_compiler_gles2.cpp | 22 +- drivers/theoraplayer/src/YUV/libyuv/src/cpu_id.cc | 2 +- main/main.cpp | 22 +- platform/android/detect.py | 3 +- platform/android/file_access_android.cpp | 11 +- platform/android/file_access_android.h | 10 +- platform/android/file_access_jandroid.cpp | 4 +- .../android/java/src/com/android/godot/Godot.java | 2 +- .../java/src/com/android/godot/GodotIO.java | 5 +- .../java/src/com/android/godot/GodotLib.java | 2 +- platform/android/java_glue.cpp | 12 +- platform/android/java_glue.h | 2 +- platform/android/os_android.cpp | 10 +- platform/android/os_android.h | 3 + platform/iphone/app_delegate.mm | 45 +++- platform/iphone/detect.py | 4 +- platform/iphone/gl_view.h | 2 +- platform/iphone/in_app_store.mm | 9 + platform/osx/detect.py | 37 +++- servers/physics/area_sw.cpp | 8 + servers/physics/area_sw.h | 1 + servers/physics_2d/area_2d_sw.cpp | 8 + servers/visual/visual_server_raster.cpp | 18 +- tools/editor/editor_import_export.cpp | 46 +++- tools/editor/editor_import_export.h | 3 + tools/editor/io_plugins/editor_import_collada.cpp | 245 +++++++++++---------- .../io_plugins/editor_texture_import_plugin.cpp | 85 ++++++- tools/editor/project_export.cpp | 1 + 38 files changed, 470 insertions(+), 216 deletions(-) (limited to 'tools/editor/project_export.cpp') diff --git a/core/error_macros.h b/core/error_macros.h index 18b08d8e0..76da88287 100644 --- a/core/error_macros.h +++ b/core/error_macros.h @@ -104,7 +104,7 @@ extern bool _err_error_exists; #define ERR_FAIL_INDEX(m_index,m_size) \ do {if ((m_index)<0 || (m_index)>=(m_size)) { \ - _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Index "_STR(m_index)" out of size ("_STR(m_size)")."); \ + _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Index " _STR(m_index)" out of size (" _STR(m_size)")."); \ return; \ } else _err_error_exists=false; } while(0); \ @@ -115,7 +115,7 @@ extern bool _err_error_exists; #define ERR_FAIL_INDEX_V(m_index,m_size,m_retval) \ do {if ((m_index)<0 || (m_index)>=(m_size)) { \ - _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Index "_STR(m_index)" out of size ("_STR(m_size)")."); \ + _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Index " _STR(m_index)" out of size (" _STR(m_size)")."); \ return m_retval; \ } else _err_error_exists=false;} while (0); @@ -125,14 +125,14 @@ extern bool _err_error_exists; #define ERR_FAIL_NULL(m_param) \ { if ( !m_param ) { \ - _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Parameter ' "_STR(m_param)" ' is null."); \ + _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Parameter ' " _STR(m_param)" ' is null."); \ return; \ }else _err_error_exists=false; } \ #define ERR_FAIL_NULL_V(m_param,m_retval) \ { if ( !m_param ) { \ - _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Parameter ' "_STR(m_param)" ' is null."); \ + _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Parameter ' " _STR(m_param)" ' is null."); \ return m_retval; \ }else _err_error_exists=false; } \ @@ -142,7 +142,7 @@ extern bool _err_error_exists; #define ERR_FAIL_COND(m_cond) \ { if ( m_cond ) { \ - _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' "_STR(m_cond)" ' is true."); \ + _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' " _STR(m_cond)" ' is true."); \ return; \ }else _err_error_exists=false; } \ @@ -154,7 +154,7 @@ extern bool _err_error_exists; #define ERR_FAIL_COND_V(m_cond,m_retval) \ { if ( m_cond ) { \ - _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' "_STR(m_cond)" ' is true. returned: "_STR(m_retval)); \ + _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' " _STR(m_cond)" ' is true. returned: " _STR(m_retval)); \ return m_retval; \ }else _err_error_exists=false; } \ @@ -164,7 +164,7 @@ extern bool _err_error_exists; #define ERR_CONTINUE(m_cond) \ { if ( m_cond ) { \ - _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' "_STR(m_cond)" ' is true. Continuing..:"); \ + _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' " _STR(m_cond)" ' is true. Continuing..:"); \ continue;\ } else _err_error_exists=false;} \ @@ -174,7 +174,7 @@ extern bool _err_error_exists; #define ERR_BREAK(m_cond) \ { if ( m_cond ) { \ - _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' "_STR(m_cond)" ' is true. Breaking..:"); \ + _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' " _STR(m_cond)" ' is true. Breaking..:"); \ break;\ } else _err_error_exists=false;} \ @@ -193,7 +193,7 @@ extern bool _err_error_exists; #define ERR_FAIL_V(m_value) \ { \ - _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Method/Function Failed, returning: "__STR(m_value)); \ + _err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Method/Function Failed, returning: " __STR(m_value)); \ _err_error_exists=false; \ return m_value;\ } \ diff --git a/core/globals.cpp b/core/globals.cpp index d252d4e28..ffd4cf5d5 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -54,7 +54,7 @@ String Globals::localize_path(const String& p_path) const { if (resource_path=="") return p_path; //not initialied yet - if (p_path.begins_with("res://")) + if (p_path.find(":/") != -1) return p_path.simplify_path(); diff --git a/core/io/compression.cpp b/core/io/compression.cpp index 0bc006b41..729b7bec5 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -26,12 +26,12 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#include "zlib.h" +#include "os/copymem.h" #include "compression.h" #include "fastlz.h" -#include "zlib.h" #include "zip_io.h" -#include "os/copymem.h" int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,Mode p_mode) { diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index d3390ae19..2db6e00f0 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -50,8 +50,10 @@ Error ImageLoader::load_image(String p_file,Image *p_image, FileAccess *p_custom if (!f) { Error err; f=FileAccess::open(p_file,FileAccess::READ,&err); - if (!f) + if (!f) { + print_line("ERROR OPENING FILE: "+p_file); return err; + } } String extension = p_file.extension(); @@ -62,15 +64,20 @@ Error ImageLoader::load_image(String p_file,Image *p_image, FileAccess *p_custom if (!loader[i]->recognize(extension)) continue; Error err = loader[i]->load_image(p_image,f); + if (err!=ERR_FILE_UNRECOGNIZED) { + + if (!p_custom) memdelete(f); + return err; } } - + print_line("NO LOADER?"); + if (!p_custom) memdelete(f); diff --git a/core/io/ioapi.h b/core/io/ioapi.h index a13d7ba62..24bf61261 100644 --- a/core/io/ioapi.h +++ b/core/io/ioapi.h @@ -40,7 +40,6 @@ #endif #include -#include #include "zlib.h" #if defined(USE_FILE32API) diff --git a/core/io/zip.h b/core/io/zip.h index cca06c2ee..85f93568c 100644 --- a/core/io/zip.h +++ b/core/io/zip.h @@ -39,6 +39,8 @@ #ifndef _zip12_H #define _zip12_H +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/core/io/zip_io.h b/core/io/zip_io.h index c4b4d6b34..dd3c371a4 100644 --- a/core/io/zip_io.h +++ b/core/io/zip_io.h @@ -34,6 +34,7 @@ #include "os/file_access.h" #include "os/copymem.h" + static void* zipio_open(void* data, const char* p_fname, int mode) { FileAccess *&f = *(FileAccess**)data; diff --git a/core/typedefs.h b/core/typedefs.h index ae1eb1f5e..6ca31fd13 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -41,8 +41,8 @@ #define _MKSTR(m_x) _STR(m_x) #endif // have to include version.h for this to work, include it in the .cpp not the .h -#define VERSION_MKSTRING _MKSTR(VERSION_MAJOR)"."_MKSTR(VERSION_MINOR)"."_MKSTR(VERSION_STATUS)"."_MKSTR(VERSION_REVISION) -#define VERSION_FULL_NAME _MKSTR(VERSION_NAME)" v"VERSION_MKSTRING +#define VERSION_MKSTRING _MKSTR(VERSION_MAJOR)"." _MKSTR(VERSION_MINOR)"." _MKSTR(VERSION_STATUS)"." _MKSTR(VERSION_REVISION) +#define VERSION_FULL_NAME _MKSTR(VERSION_NAME)" v" VERSION_MKSTRING #ifndef _ALWAYS_INLINE_ diff --git a/core/variant.cpp b/core/variant.cpp index e0bceb4dd..c6a55b10e 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1592,9 +1592,17 @@ Variant::operator String() const { } break; case OBJECT: { - if (_get_obj().obj) + if (_get_obj().obj) { + #ifdef DEBUG_ENABLED + if (ScriptDebugger::get_singleton() && _get_obj().ref.is_null()) { + //only if debugging! + if (!ObjectDB::instance_validate(_get_obj().obj)) { + return "[Deleted Object]"; + }; + }; + #endif return "["+_get_obj().obj->get_type()+":"+itos(_get_obj().obj->get_instance_ID())+"]"; - else + } else return "[Object:null]"; } break; diff --git a/demos/2d/platformer/engine.cfg b/demos/2d/platformer/engine.cfg index 50b6b862e..cf679cede 100644 --- a/demos/2d/platformer/engine.cfg +++ b/demos/2d/platformer/engine.cfg @@ -4,14 +4,17 @@ name="Platformer" main_scene="res://stage.xml" icon="res://icon.png" name_es="Plataformero" +target_fps="60" [display] width=800 height=480 -stretch_2d=false -stretch_mode="viewport" -stretch_aspect="keep" +#stretch_2d=false +#stretch_mode="viewport" +#stretch_aspect="keep" +stretch_mode="2d" +stretch_aspect="keep_height" [image_loader] diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 157f2e398..d57512c93 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -132,18 +132,18 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a SL::BlockNode *bnode=(SL::BlockNode*)p_node; //variables - code+="{"ENDL; + code+="{" ENDL; for(Map::Element *E=bnode->variables.front();E;E=E->next()) { - code+=_mktab(p_level)+_typestr(E->value())+" "+replace_string(E->key())+";"ENDL; + code+=_mktab(p_level)+_typestr(E->value())+" "+replace_string(E->key())+";" ENDL; } for(int i=0;istatements.size();i++) { - code+=_mktab(p_level)+dump_node_code(bnode->statements[i],p_level)+";"ENDL; + code+=_mktab(p_level)+dump_node_code(bnode->statements[i],p_level)+";" ENDL; } - code+="}"ENDL; + code+="}" ENDL; } break; case SL::Node::TYPE_VARIABLE: { @@ -489,15 +489,15 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a SL::ControlFlowNode *cfnode=(SL::ControlFlowNode*)p_node; if (cfnode->flow_op==SL::FLOW_OP_IF) { - code+="if ("+dump_node_code(cfnode->statements[0],p_level)+") {"ENDL; + code+="if ("+dump_node_code(cfnode->statements[0],p_level)+") {" ENDL; code+=dump_node_code(cfnode->statements[1],p_level+1); if (cfnode->statements.size()==3) { - code+="} else {"ENDL; + code+="} else {" ENDL; code+=dump_node_code(cfnode->statements[2],p_level+1); } - code+="}"ENDL; + code+="}" ENDL; } else if (cfnode->flow_op==SL::FLOW_OP_RETURN) { @@ -560,7 +560,7 @@ Error ShaderCompilerGLES2::compile_node(SL::ProgramNode *p_program) { ubase=uniforms->size(); for(Map::Element *E=p_program->uniforms.front();E;E=E->next()) { - String uline="uniform "+_typestr(E->get().type)+" _"+E->key().operator String()+";"ENDL; + String uline="uniform "+_typestr(E->get().type)+" _"+E->key().operator String()+";" ENDL; global_code+=uline; if (uniforms) { @@ -593,10 +593,10 @@ Error ShaderCompilerGLES2::compile_node(SL::ProgramNode *p_program) { header+=_typestr(fnode->arguments[i].type)+" "+replace_string(fnode->arguments[i].name); } - header+=") {"ENDL; + header+=") {" ENDL; String fcode=header; fcode+=dump_node_code(fnode->body,1); - fcode+="}"ENDL; + fcode+="}" ENDL; global_code+=fcode; } @@ -605,7 +605,7 @@ Error ShaderCompilerGLES2::compile_node(SL::ProgramNode *p_program) { StringName varname=E->key(); String newvarname=replace_string(varname); - global_code+="uniform "+_typestr(E->get())+" "+newvarname+";"ENDL; + global_code+="uniform "+_typestr(E->get())+" "+newvarname+";" ENDL; }*/ code=dump_node_code(p_program,0); diff --git a/drivers/theoraplayer/src/YUV/libyuv/src/cpu_id.cc b/drivers/theoraplayer/src/YUV/libyuv/src/cpu_id.cc index f52bd9555..aac7390b3 100755 --- a/drivers/theoraplayer/src/YUV/libyuv/src/cpu_id.cc +++ b/drivers/theoraplayer/src/YUV/libyuv/src/cpu_id.cc @@ -174,7 +174,7 @@ int cpu_info_ = kCpuInit; // cpu_info is not initialized yet. #if !defined(__native_client__) && !defined(_M_ARM) static LIBYUV_BOOL TestEnv(const char* name) { -#ifndef _WINRT +#if !defined(_WINRT) && !defined(ORBIS_ENABLED) const char* var = getenv(name); if (var) { if (var[0] != '0') { diff --git a/main/main.cpp b/main/main.cpp index cd1e12126..452e95660 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -846,17 +846,29 @@ Error Main::setup2() { if (init_maximized) { OS::get_singleton()->set_window_maximized(true); } + MAIN_PRINT("Main: Load Remaps"); + + path_remap->load_remaps(); if (show_logo) { //boot logo! String boot_logo_path=GLOBAL_DEF("application/boot_splash",String()); bool boot_logo_scale=GLOBAL_DEF("application/boot_splash_fullsize",true); Globals::get_singleton()->set_custom_property_info("application/boot_splash",PropertyInfo(Variant::STRING,"application/boot_splash",PROPERTY_HINT_FILE,"*.png")); - + print_line("BOOT SPLASH: "+boot_logo_path); Image boot_logo; - if (boot_logo_path.strip_edges()!="" && FileAccess::exists(boot_logo_path)) { - boot_logo.load(boot_logo_path); + boot_logo_path = boot_logo_path.strip_edges(); + print_line("BOOT SPLASH IS : "+boot_logo_path); + + if (boot_logo_path!=String() /*&& FileAccess::exists(boot_logo_path)*/) { + Error err = boot_logo.load(boot_logo_path); + if (err!=OK) { + print_line("ËRROR LOADING BOOT LOGO SPLASH :"+boot_logo_path); + } else { + print_line("BOOT SPLASH OK!"); + + } } if (!boot_logo.empty()) { @@ -867,7 +879,7 @@ Error Main::setup2() { VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg,boot_logo_scale); #ifndef TOOLS_ENABLED //no tools, so free the boot logo (no longer needed) - Globals::get_singleton()->set("application/boot_logo",Image()); + // Globals::get_singleton()->set("application/boot_logo",Image()); #endif } else { @@ -902,8 +914,6 @@ Error Main::setup2() { } MAIN_PRINT("Main: Load Remaps"); - path_remap->load_remaps(); - MAIN_PRINT("Main: Load Scene Types"); register_scene_types(); diff --git a/platform/android/detect.py b/platform/android/detect.py index 76575a1ec..fce1fe3ed 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -173,8 +173,7 @@ def configure(env): env.Append(LDPATH=[ld_path]) env.Append(LIBS=['OpenSLES']) # env.Append(LIBS=['c','m','stdc++','log','EGL','GLESv1_CM','GLESv2','OpenSLES','supc++','android']) - if (env["ndk_platform"]!="2.2"): - env.Append(LIBS=['EGL','OpenSLES','android']) + env.Append(LIBS=['EGL','OpenSLES','android']) env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2', 'z']) env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ") diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp index da3a37fb4..ff70d5ae7 100644 --- a/platform/android/file_access_android.cpp +++ b/platform/android/file_access_android.cpp @@ -29,16 +29,16 @@ #include "file_access_android.h" #include "print_string.h" -#ifdef ANDROID_NATIVE_ACTIVITY + AAssetManager *FileAccessAndroid::asset_manager=NULL; -void FileAccessAndroid::make_default() { +/*void FileAccessAndroid::make_default() { create_func=create_android; -} +}*/ FileAccess* FileAccessAndroid::create_android() { @@ -46,7 +46,7 @@ FileAccess* FileAccessAndroid::create_android() { } -Error FileAccessAndroid::open(const String& p_path, int p_mode_flags) { +Error FileAccessAndroid::_open(const String& p_path, int p_mode_flags) { String path=fix_path(p_path).simplify_path(); if (path.begins_with("/")) @@ -55,7 +55,6 @@ Error FileAccessAndroid::open(const String& p_path, int p_mode_flags) { path=path.substr(6,path.length()); - ERR_FAIL_COND_V(p_mode_flags&FileAccess::WRITE,ERR_UNAVAILABLE); //can't write on android.. a=AAssetManager_open(asset_manager,path.utf8().get_data(),AASSET_MODE_STREAMING); if (!a) @@ -184,4 +183,4 @@ FileAccessAndroid::~FileAccessAndroid() { close(); } -#endif + diff --git a/platform/android/file_access_android.h b/platform/android/file_access_android.h index f477920ae..506c2c023 100644 --- a/platform/android/file_access_android.h +++ b/platform/android/file_access_android.h @@ -29,14 +29,13 @@ #ifndef FILE_ACCESS_ANDROID_H #define FILE_ACCESS_ANDROID_H -#ifdef ANDROID_NATIVE_ACTIVITY #include "os/file_access.h" #include #include #include -#include +//#include class FileAccessAndroid : public FileAccess { @@ -51,7 +50,7 @@ public: static AAssetManager *asset_manager; - virtual Error open(const String& p_path, int p_mode_flags); ///< open a file + virtual Error _open(const String& p_path, int p_mode_flags); ///< open a file virtual void close(); ///< close a file virtual bool is_open() const; ///< true when file is open @@ -71,12 +70,13 @@ public: virtual bool file_exists(const String& p_path); ///< return true if a file exists + virtual uint64_t _get_modified_time(const String& p_file) { return 0; } - static void make_default(); + //static void make_default(); FileAccessAndroid(); ~FileAccessAndroid(); }; #endif // FILE_ACCESS_ANDROID_H -#endif + diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp index 971d4f84a..be38d806b 100644 --- a/platform/android/file_access_jandroid.cpp +++ b/platform/android/file_access_jandroid.cpp @@ -62,13 +62,15 @@ Error FileAccessJAndroid::_open(const String& p_path, int p_mode_flags) { JNIEnv *env = ThreadAndroid::get_env(); - //OS::get_singleton()->print("env: %p, io %p, fo: %p\n",env,io,_file_open); jstring js = env->NewStringUTF(path.utf8().get_data()); int res = env->CallIntMethod(io,_file_open,js,p_mode_flags&WRITE?true:false); env->DeleteLocalRef(js); + OS::get_singleton()->print("fopen: '%s' ret %i\n",path.utf8().get_data(),res); + + if (res<=0) return ERR_FILE_CANT_OPEN; id=res; diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index 9b9b1ab2a..4c5a31357 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -357,7 +357,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC Log.d("GODOT"," " + command_line[w]); } }*/ - GodotLib.initialize(this,io.needsReloadHooks(),command_line); + GodotLib.initialize(this,io.needsReloadHooks(),command_line,getAssets()); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); diff --git a/platform/android/java/src/com/android/godot/GodotIO.java b/platform/android/java/src/com/android/godot/GodotIO.java index addceb152..a7dc0c2f7 100644 --- a/platform/android/java/src/com/android/godot/GodotIO.java +++ b/platform/android/java/src/com/android/godot/GodotIO.java @@ -94,6 +94,7 @@ public class GodotIO { //System.out.printf("file_open: Attempt to Open %s\n",path); + //Log.v("MyApp", "TRYING TO OPEN FILE: " + path); if (write) return -1; @@ -105,7 +106,7 @@ public class GodotIO { } catch (Exception e) { - //System.out.printf("Exception on file_open: %s\n",e); + //System.out.printf("Exception on file_open: %s\n",path); return -1; } @@ -113,7 +114,7 @@ public class GodotIO { ad.len=ad.is.available(); } catch (Exception e) { - System.out.printf("Exception availabling on file_open: %s\n",e); + System.out.printf("Exception availabling on file_open: %s\n",path); return -1; } diff --git a/platform/android/java/src/com/android/godot/GodotLib.java b/platform/android/java/src/com/android/godot/GodotLib.java index 71c31e9f8..f099e0fef 100644 --- a/platform/android/java/src/com/android/godot/GodotLib.java +++ b/platform/android/java/src/com/android/godot/GodotLib.java @@ -44,7 +44,7 @@ public class GodotLib { * @param height the current view height */ - public static native void initialize(Godot p_instance,boolean need_reload_hook,String[] p_cmdline); + public static native void initialize(Godot p_instance,boolean need_reload_hook,String[] p_cmdline,Object p_asset_manager); public static native void resize(int width, int height,boolean reload); public static native void newcontext(); public static native void quit(); diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 315825478..d001cface 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -33,13 +33,14 @@ #include "main/main.h" #include #include "file_access_jandroid.h" +#include "file_access_android.h" #include "dir_access_jandroid.h" #include "audio_driver_jandroid.h" #include "globals.h" #include "thread_jandroid.h" #include "core/os/keyboard.h" #include "java_class_wrapper.h" - +#include "android/asset_manager_jni.h" static JavaClassWrapper *java_class_wrapper=NULL; static OS_Android *os_android=NULL; @@ -764,7 +765,7 @@ static void _stop_video() { env->CallVoidMethod(godot_io, _stopVideo); } -JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, jobject obj, jobject activity,jboolean p_need_reload_hook, jobjectArray p_cmdline) { +JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, jobject obj, jobject activity,jboolean p_need_reload_hook, jobjectArray p_cmdline,jobject p_asset_manager) { __android_log_print(ANDROID_LOG_INFO,"godot","**INIT EVENT! - %p\n",env); @@ -820,7 +821,14 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, } ThreadAndroid::make_default(jvm); +#ifdef USE_JAVA_FILE_ACCESS FileAccessJAndroid::setup(gob); +#else + + jobject amgr = env->NewGlobalRef(p_asset_manager); + + FileAccessAndroid::asset_manager=AAssetManager_fromJava(env,amgr); +#endif DirAccessJAndroid::setup(gob); AudioDriverAndroid::setup(gob); } diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h index 57a4cc865..9410fe713 100644 --- a/platform/android/java_glue.h +++ b/platform/android/java_glue.h @@ -36,7 +36,7 @@ extern "C" { - JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, jobject obj, jobject activity,jboolean p_need_reload_hook, jobjectArray p_cmdline); + JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, jobject obj, jobject activity,jboolean p_need_reload_hook, jobjectArray p_cmdline,jobject p_asset_manager); JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_resize(JNIEnv * env, jobject obj, jint width, jint height, jboolean reload); JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_newcontext(JNIEnv * env, jobject obj); JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_step(JNIEnv * env, jobject obj); diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 612148418..e2ff128f0 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -37,6 +37,8 @@ #include "servers/visual/visual_server_wrap_mt.h" #include "main/main.h" +#include "file_access_android.h" + #include "core/globals.h" #ifdef ANDROID_NATIVE_ACTIVITY @@ -89,8 +91,14 @@ void OS_Android::initialize_core() { if (use_apk_expansion) FileAccess::make_default(FileAccess::ACCESS_RESOURCES); - else + else { +#ifdef USE_JAVA_FILE_ACCESS FileAccess::make_default >(FileAccess::ACCESS_RESOURCES); +#else + //FileAccess::make_default >(FileAccess::ACCESS_RESOURCES); + FileAccess::make_default(FileAccess::ACCESS_RESOURCES); +#endif + } FileAccess::make_default(FileAccess::ACCESS_USERDATA); FileAccess::make_default(FileAccess::ACCESS_FILESYSTEM); //FileAccessBufferedFA::make_default(); diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 7a5a55653..e9b0d0019 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -41,6 +41,9 @@ #include "servers/visual/rasterizer.h" +//#ifdef USE_JAVA_FILE_ACCESS + + #ifdef ANDROID_NATIVE_ACTIVITY #include diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 3c7913717..d5764b2b5 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -43,6 +43,11 @@ #import #endif +#ifdef MODULE_PARSE_ENABLED +#import +#import "FBSDKCoreKit/FBSDKCoreKit.h" +#endif + #define kFilteringFactor 0.1 #define kRenderingFrequency 60 #define kAccelerometerFrequency 100.0 // Hz @@ -139,8 +144,9 @@ static int frame_count = 0; ++frame_count; // this might be necessary before here - for (NSString* key in [[NSBundle mainBundle] infoDictionary]) { - NSObject* value = [[[NSBundle mainBundle] infoDictionary] objectForKey:key]; + NSDictionary* dict = [[NSBundle mainBundle] infoDictionary]; + for (NSString* key in dict) { + NSObject* value = [dict objectForKey:key]; String ukey = String::utf8([key UTF8String]); // we need a NSObject to Variant conversor @@ -341,6 +347,15 @@ static int frame_count = 0; // For 4.2+ support - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { +#ifdef MODULE_PARSE_ENABLED + NSLog(@"Handling application openURL"); + return [[FBSDKApplicationDelegate sharedInstance] application:application + openURL:url + sourceApplication:sourceApplication + annotation:annotation]; +#endif + + #ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED return [[[FacebookScorer sharedInstance] facebook] handleOpenURL:url]; #else @@ -348,6 +363,32 @@ static int frame_count = 0; #endif } +- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { +#ifdef MODULE_PARSE_ENABLED + // Store the deviceToken in the current installation and save it to Parse. + PFInstallation *currentInstallation = [PFInstallation currentInstallation]; + //NSString* token = [[NSString alloc] initWithData:deviceToken encoding:NSUTF8StringEncoding]; + NSLog(@"Device Token : %@ ", deviceToken); + [currentInstallation setDeviceTokenFromData:deviceToken]; + [currentInstallation saveInBackground]; +#endif +} + +- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { +#ifdef MODULE_PARSE_ENABLED + [PFPush handlePush:userInfo]; + NSDictionary *aps = [userInfo objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + + NSLog(@"Push Notification Payload (app active) %@", aps); + [defaults setObject:aps forKey:@"notificationInfo"]; + [defaults synchronize]; + if (application.applicationState == UIApplicationStateInactive) { + [PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo]; + } +#endif +} + - (void)dealloc { [window release]; diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index fb57876a8..6be3539b9 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -59,7 +59,7 @@ def configure(env): env.Append(CPPFLAGS=['-DNEED_LONG_INT']) env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) else: - env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -gdwarf-2 -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=4.3 -MMD -MT dependencies -isysroot $IPHONESDK') + env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -gdwarf-2 -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=5.1.1 -MMD -MT dependencies -isysroot $IPHONESDK') if (env["bits"]=="64"): env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1', @@ -80,7 +80,7 @@ def configure(env): '-framework', 'CoreMedia', ]) else: - env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=4.3', + env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1', '-isysroot', '$IPHONESDK', '-framework', 'Foundation', '-framework', 'UIKit', diff --git a/platform/iphone/gl_view.h b/platform/iphone/gl_view.h index c58c86351..cda75394d 100755 --- a/platform/iphone/gl_view.h +++ b/platform/iphone/gl_view.h @@ -34,7 +34,7 @@ #import #import -#define USE_CADISPLAYLINK 1 //iOS version 3.1+ is required +#define USE_CADISPLAYLINK 0 //iOS version 3.1+ is required @protocol GLViewDelegate; diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm index e3ba6bbd7..f689123c8 100644 --- a/platform/iphone/in_app_store.mm +++ b/platform/iphone/in_app_store.mm @@ -28,6 +28,10 @@ /*************************************************************************/ #ifdef STOREKIT_ENABLED +#ifdef MODULE_FUSEBOXX_ENABLED +#import "modules/fuseboxx/ios/FuseSDK.h" +#endif + #include "in_app_store.h" extern "C" { @@ -222,6 +226,11 @@ Error InAppStore::request_product_info(Variant p_params) { else{ [pending_transactions setObject:transaction forKey:transaction.payment.productIdentifier]; } + + #ifdef MODULE_FUSEBOXX_ENABLED + printf("Registering transaction on Fuseboxx!\n"); + [FuseSDK registerInAppPurchase: transaction]; + #endif } break; case SKPaymentTransactionStateFailed: { printf("status transaction failed!\n"); diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 5703cbc54..22cee0527 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -11,15 +11,17 @@ def get_name(): def can_build(): - if (sys.platform != "darwin"): - return False + if (sys.platform == "darwin" or os.environ.has_key("OSXCROSS_ROOT")): + return True - return True # osx enabled + + return False def get_opts(): return [ ('force_64_bits','Force 64 bits binary','no'), + ('osxcross_sdk','OSXCross SDK version','darwin14'), ] @@ -59,12 +61,31 @@ def configure(env): env.Append(CPPPATH=['#tools/freetype']) env.Append(CPPPATH=['#tools/freetype/freetype/include']) - if (env["bits"]=="64"): - env.Append(CCFLAGS=['-arch', 'x86_64']) - env.Append(LINKFLAGS=['-arch', 'x86_64']) + + + if (not os.environ.has_key("OSXCROSS_ROOT")): + #regular native build + if (env["bits"]=="64"): + env.Append(CCFLAGS=['-arch', 'x86_64']) + env.Append(LINKFLAGS=['-arch', 'x86_64']) + else: + env.Append(CCFLAGS=['-arch', 'i386']) + env.Append(LINKFLAGS=['-arch', 'i386']) else: - env.Append(CCFLAGS=['-arch', 'i386']) - env.Append(LINKFLAGS=['-arch', 'i386']) + #osxcross build + root=os.environ.get("OSXCROSS_ROOT",0) + if env["bits"]=="64": + basecmd=root+"/target/bin/x86_64-apple-"+env["osxcross_sdk"]+"-" + else: + basecmd=root+"/target/bin/i386-apple-"+env["osxcross_sdk"]+"-" + + + env['CC'] = basecmd+"cc" + env['CXX'] = basecmd+"c++" + env['AR'] = basecmd+"ar" + env['RANLIB'] = basecmd+"ranlib" + env['AS'] = basecmd+"as" + # env.Append(CPPPATH=['#platform/osx/include/freetype2', '#platform/osx/include']) # env.Append(LIBPATH=['#platform/osx/lib']) diff --git a/servers/physics/area_sw.cpp b/servers/physics/area_sw.cpp index 01dfdd633..e78f0699c 100644 --- a/servers/physics/area_sw.cpp +++ b/servers/physics/area_sw.cpp @@ -83,6 +83,10 @@ void AreaSW::set_monitor_callback(ObjectID p_id, const StringName& p_method) { _shape_changed(); + if (!moved_list.in_list() && get_space()) + get_space()->area_add_to_moved_list(&moved_list); + + } void AreaSW::set_area_monitor_callback(ObjectID p_id, const StringName& p_method) { @@ -103,6 +107,10 @@ void AreaSW::set_area_monitor_callback(ObjectID p_id, const StringName& p_method _shape_changed(); + if (!moved_list.in_list() && get_space()) + get_space()->area_add_to_moved_list(&moved_list); + + } diff --git a/servers/physics/area_sw.h b/servers/physics/area_sw.h index 0c5295d42..40ccdaf37 100644 --- a/servers/physics/area_sw.h +++ b/servers/physics/area_sw.h @@ -206,6 +206,7 @@ void AreaSW::remove_area_from_query(AreaSW *p_area, uint32_t p_area_shape,uint32 monitored_areas[bk].dec(); if (!monitor_query_list.in_list()) _queue_monitor_update(); + } diff --git a/servers/physics_2d/area_2d_sw.cpp b/servers/physics_2d/area_2d_sw.cpp index 1a41cda48..a5a132020 100644 --- a/servers/physics_2d/area_2d_sw.cpp +++ b/servers/physics_2d/area_2d_sw.cpp @@ -82,6 +82,10 @@ void Area2DSW::set_monitor_callback(ObjectID p_id, const StringName& p_method) { _shape_changed(); + if (!moved_list.in_list() && get_space()) + get_space()->area_add_to_moved_list(&moved_list); + + } void Area2DSW::set_area_monitor_callback(ObjectID p_id, const StringName& p_method) { @@ -102,6 +106,10 @@ void Area2DSW::set_area_monitor_callback(ObjectID p_id, const StringName& p_meth _shape_changed(); + if (!moved_list.in_list() && get_space()) + get_space()->area_add_to_moved_list(&moved_list); + + } diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index b51f59050..8b47596d7 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -7351,6 +7351,8 @@ void VisualServerRaster::_draw_cursors_and_margins() { rasterizer->canvas_draw_rect(Rect2(cursors[i].pos, size), 0, Rect2(), tex, Color(1, 1, 1, 1)); }; + + if (black_image[MARGIN_LEFT].is_valid()) { Size2 sz(rasterizer->texture_get_width(black_image[MARGIN_LEFT]),rasterizer->texture_get_height(black_image[MARGIN_LEFT])); rasterizer->canvas_draw_rect(Rect2(0,0,black_margin[MARGIN_LEFT],window_h),0,Rect2(0,0,sz.x,sz.y),black_image[MARGIN_LEFT],Color(1,1,1)); @@ -7362,10 +7364,22 @@ void VisualServerRaster::_draw_cursors_and_margins() { rasterizer->canvas_draw_rect(Rect2(window_w-black_margin[MARGIN_RIGHT],0,black_margin[MARGIN_RIGHT],window_h),0,Rect2(0,0,sz.x,sz.y),black_image[MARGIN_RIGHT],Color(1,1,1)); } else if (black_margin[MARGIN_RIGHT]) rasterizer->canvas_draw_rect(Rect2(window_w-black_margin[MARGIN_RIGHT],0,black_margin[MARGIN_RIGHT],window_h),0,Rect2(0,0,1,1),RID(),Color(0,0,0)); - if (black_margin[MARGIN_TOP]) + + if (black_image[MARGIN_TOP].is_valid()) { + Size2 sz(rasterizer->texture_get_width(black_image[MARGIN_TOP]),rasterizer->texture_get_height(black_image[MARGIN_TOP])); + rasterizer->canvas_draw_rect(Rect2(0,0,window_w,black_margin[MARGIN_TOP]),0,Rect2(0,0,sz.x,sz.y),black_image[MARGIN_TOP],Color(1,1,1)); + + } else if (black_margin[MARGIN_TOP]) { rasterizer->canvas_draw_rect(Rect2(0,0,window_w,black_margin[MARGIN_TOP]),0,Rect2(0,0,1,1),RID(),Color(0,0,0)); - if (black_margin[MARGIN_BOTTOM]) + } + + if (black_image[MARGIN_BOTTOM].is_valid()) { + + Size2 sz(rasterizer->texture_get_width(black_image[MARGIN_BOTTOM]),rasterizer->texture_get_height(black_image[MARGIN_BOTTOM])); + rasterizer->canvas_draw_rect(Rect2(0,window_h-black_margin[MARGIN_BOTTOM],window_w,black_margin[MARGIN_BOTTOM]),0,Rect2(0,0,sz.x,sz.y),black_image[MARGIN_BOTTOM],Color(1,1,1)); + } else if (black_margin[MARGIN_BOTTOM]) { rasterizer->canvas_draw_rect(Rect2(0,window_h-black_margin[MARGIN_BOTTOM],window_w,black_margin[MARGIN_BOTTOM]),0,Rect2(0,0,1,1),RID(),Color(0,0,0)); + } rasterizer->canvas_end_rect(); }; diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index b28b349c8..84fc14d2e 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -255,7 +255,16 @@ static void _add_filter_to_list(Set& r_list,const String& p_filter) } +Vector EditorExportPlatform::get_exported_file_default(String& p_fname) const { + FileAccess *f = FileAccess::open(p_fname,FileAccess::READ); + ERR_FAIL_COND_V(!f,Vector()); + Vector ret; + ret.resize(f->get_len()); + int rbs = f->get_buffer(ret.ptr(),ret.size()); + memdelete(f); + return ret; +} Vector EditorExportPlatform::get_exported_file(String& p_fname) const { @@ -270,13 +279,9 @@ Vector EditorExportPlatform::get_exported_file(String& p_fname) const { } - FileAccess *f = FileAccess::open(p_fname,FileAccess::READ); - ERR_FAIL_COND_V(!f,Vector()); - Vector ret; - ret.resize(f->get_len()); - int rbs = f->get_buffer(ret.ptr(),ret.size()); - memdelete(f); - return ret; + return get_exported_file_default(p_fname); + + } Vector EditorExportPlatform::get_dependencies(bool p_bundles) const { @@ -557,6 +562,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func group_shrink*=EditorImportExport::get_singleton()->get_export_image_shrink(); switch(EditorImportExport::get_singleton()->image_export_group_get_image_action(E->get())) { + case EditorImportExport::IMAGE_ACTION_KEEP: case EditorImportExport::IMAGE_ACTION_NONE: { switch(EditorImportExport::get_singleton()->get_export_image_action()) { @@ -581,7 +587,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func } break; //use default case EditorImportExport::IMAGE_ACTION_COMPRESS_RAM: { group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM; - } break; //use default + } break; //use default } String image_list_md5; @@ -825,13 +831,32 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func StringName engine_cfg="res://engine.cfg"; + StringName boot_splash; + { + String splash=Globals::get_singleton()->get("application/boot_splash"); //avoid splash from being converted + splash=splash.strip_edges(); + if (splash!=String()) { + if (!splash.begins_with("res://")) + splash="res://"+splash; + splash=splash.simplify_path(); + boot_splash=splash; + } + } + + + for(int i=0;i buf = get_exported_file(src); + Vector buf; + + if (src==boot_splash) + buf = get_exported_file_default(src); //bootsplash must be kept if used + else + buf = get_exported_file(src); ERR_CONTINUE( saved.has(src) ); @@ -1608,6 +1633,8 @@ void EditorImportExport::load_config() { g.action=IMAGE_ACTION_COMPRESS_RAM; else if (action=="compress_disk") g.action=IMAGE_ACTION_COMPRESS_DISK; + else if (action=="keep") + g.action=IMAGE_ACTION_KEEP; } if (d.has("atlas")) @@ -1735,6 +1762,7 @@ void EditorImportExport::save_config() { case IMAGE_ACTION_NONE: d["action"]="default"; break; case IMAGE_ACTION_COMPRESS_RAM: d["action"]="compress_ram"; break; case IMAGE_ACTION_COMPRESS_DISK: d["action"]="compress_disk"; break; + case IMAGE_ACTION_KEEP: d["action"]="keep"; break; } diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h index f134a479a..d8601929c 100644 --- a/tools/editor/editor_import_export.h +++ b/tools/editor/editor_import_export.h @@ -83,6 +83,7 @@ public: typedef Error (*EditorExportSaveFunction)(void *p_userdata,const String& p_path, const Vector& p_data,int p_file,int p_total); protected: + Vector get_exported_file_default(String& p_fname) const; virtual Vector get_exported_file(String& p_fname) const; virtual Vector get_dependencies(bool p_bundles) const; @@ -227,6 +228,8 @@ public: IMAGE_ACTION_NONE, IMAGE_ACTION_COMPRESS_DISK, IMAGE_ACTION_COMPRESS_RAM, + IMAGE_ACTION_KEEP //for group + }; enum ScriptAction { diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp index d510333a3..d57cff850 100644 --- a/tools/editor/io_plugins/editor_import_collada.cpp +++ b/tools/editor/io_plugins/editor_import_collada.cpp @@ -710,10 +710,126 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref& p_mesh,con //find largest source.. + /************************/ + /* ADD WEIGHTS IF EXIST */ + /************************/ + + Map > pre_weights; + + bool has_weights=false; + + if (skin_controller) { + + const Collada::SkinControllerData::Source *weight_src=NULL; + int weight_ofs=0; + + if (skin_controller->weights.sources.has("WEIGHT")) { + + String weight_id = skin_controller->weights.sources["WEIGHT"].source; + weight_ofs = skin_controller->weights.sources["WEIGHT"].offset; + if (skin_controller->sources.has(weight_id)) { + + weight_src = &skin_controller->sources[weight_id]; + + } + } + + int joint_ofs=0; + + if (skin_controller->weights.sources.has("JOINT")) { + + joint_ofs = skin_controller->weights.sources["JOINT"].offset; + } + + //should be OK, given this was pre-checked. + + int index_ofs=0; + int wstride = skin_controller->weights.sources.size(); + for(int w_i=0;w_iweights.sets.size();w_i++) { + + int amount = skin_controller->weights.sets[w_i]; + + Vector weights; + + for (int a_i=0;a_iweights.indices.size(),ERR_INVALID_DATA); + int weight_index = skin_controller->weights.indices[read_from+weight_ofs]; + ERR_FAIL_INDEX_V(weight_index,weight_src->array.size(),ERR_INVALID_DATA); + + w.weight = weight_src->array[weight_index]; + + int bone_index = skin_controller->weights.indices[read_from+joint_ofs]; + if (bone_index==-1) + continue; //ignore this weight (refers to bind shape) + ERR_FAIL_INDEX_V(bone_index,bone_remap.size(),ERR_INVALID_DATA); + + w.bone_idx=bone_remap[bone_index]; + + + weights.push_back(w); + } + + /* FIX WEIGHTS */ + + + + weights.sort(); + + if (weights.size()>4) { + //cap to 4 and make weights add up 1 + weights.resize(4); + + } + + //make sure weights allways add up to 1 + float total=0; + for(int i=0;i::Element *E=vertex_map[w_i].front();E;E=E->next()) { + + int dst = E->get(); + ERR_EXPLAIN("invalid vertex index in array"); + ERR_FAIL_INDEX_V(dst,vertex_array.size(),ERR_INVALID_DATA); + vertex_array[dst].weights=weights; + + }*/ + + + + + index_ofs+=wstride*amount; + + } + + //vertices need to be localized + has_weights=true; + + } Set vertex_set; //vertex set will be the vertices List indices_list; //indices will be the indices - Map > vertex_map; //map vertices (for setting skinning/morph) + //Map > vertex_map; //map vertices (for setting skinning/morph) /**************************/ /* CREATE PRIMITIVE ARRAY */ @@ -753,11 +869,16 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref& p_mesh,con if (!p_optimize) vertex.uid=vertidx++; + + int vertex_index=p.indices[src+vertex_ofs]; //used for index field (later used by controllers) int vertex_pos = (vertex_src->stride?vertex_src->stride:3) * vertex_index; ERR_FAIL_INDEX_V(vertex_pos,vertex_src->array.size(),ERR_INVALID_DATA); vertex.vertex=Vector3(vertex_src->array[vertex_pos+0],vertex_src->array[vertex_pos+1],vertex_src->array[vertex_pos+2]); + if (pre_weights.has(vertex_index)) { + vertex.weights=pre_weights[vertex_index]; + } if (normal_src) { @@ -836,9 +957,9 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref& p_mesh,con vertex_set.insert(vertex); } - if (!vertex_map.has(vertex_index)) + /* if (!vertex_map.has(vertex_index)) vertex_map[vertex_index]=Set(); - vertex_map[vertex_index].insert(index); //should be outside.. + vertex_map[vertex_index].insert(index); //should be outside..*/ //build triangles if needed if (j==0) prev2[0]=index; @@ -874,120 +995,10 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref& p_mesh,con vertex_array[F->get().idx]=F->get(); } - /************************/ - /* ADD WEIGHTS IF EXIST */ - /************************/ - - - bool has_weights=false; - - if (skin_controller) { - - const Collada::SkinControllerData::Source *weight_src=NULL; - int weight_ofs=0; - - if (skin_controller->weights.sources.has("WEIGHT")) { - - String weight_id = skin_controller->weights.sources["WEIGHT"].source; - weight_ofs = skin_controller->weights.sources["WEIGHT"].offset; - if (skin_controller->sources.has(weight_id)) { - - weight_src = &skin_controller->sources[weight_id]; - - } - } - - int joint_ofs=0; - - if (skin_controller->weights.sources.has("JOINT")) { - - joint_ofs = skin_controller->weights.sources["JOINT"].offset; - } - - //should be OK, given this was pre-checked. - - int index_ofs=0; - int wstride = skin_controller->weights.sources.size(); - for(int w_i=0;w_iweights.sets.size();w_i++) { - - int amount = skin_controller->weights.sets[w_i]; - - if (vertex_map.has(w_i)) { //vertex may no longer be here, don't bother converting - Vector weights; - - for (int a_i=0;a_iweights.indices.size(),ERR_INVALID_DATA); - int weight_index = skin_controller->weights.indices[read_from+weight_ofs]; - ERR_FAIL_INDEX_V(weight_index,weight_src->array.size(),ERR_INVALID_DATA); - - w.weight = weight_src->array[weight_index]; - - int bone_index = skin_controller->weights.indices[read_from+joint_ofs]; - if (bone_index==-1) - continue; //ignore this weight (refers to bind shape) - ERR_FAIL_INDEX_V(bone_index,bone_remap.size(),ERR_INVALID_DATA); - - w.bone_idx=bone_remap[bone_index]; - - - weights.push_back(w); - } - - /* FIX WEIGHTS */ - - - - weights.sort(); - - if (weights.size()>4) { - //cap to 4 and make weights add up 1 - weights.resize(4); - - } - - //make sure weights allways add up to 1 - float total=0; - for(int i=0;i::Element *E=vertex_map[w_i].front();E;E=E->next()) { - - int dst = E->get(); - ERR_EXPLAIN("invalid vertex index in array"); - ERR_FAIL_INDEX_V(dst,vertex_array.size(),ERR_INVALID_DATA); - vertex_array[dst].weights=weights; - - } - - } else { - //zzprint_line("no vertex found for index "+itos(w_i)); - } - - index_ofs+=wstride*amount; - - } - - //vertices need to be localized + if (has_weights) { + //if skeleton, localize Transform local_xform = p_local_xform; for(int i=0;i& p_mesh,con //vertex_array[i].tangent.normal*=-1.0; } } - - has_weights=true; - } + DVector index_array; index_array.resize(indices_list.size()); DVector::Write index_arrayw = index_array.write(); diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index 4f7ec1839..436725f6f 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -1068,12 +1068,14 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref sources; + Vector< Image > tsources; bool alpha=false; bool crop = from->get_option("crop"); EditorProgress ep("make_atlas","Build Atlas For: "+p_path.get_file(),from->get_source_count()+3); print_line("sources: "+itos(from->get_source_count())); + for(int i=0;iget_source_count();i++) { String path = EditorImportPlugin::expand_source_path(from->get_source_path(i)); @@ -1091,17 +1093,57 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref source_md5; + Map > source_map; + + for(int i=0;i data = src.get_data(); + MD5_CTX md5; + DVector::Read r=data.read(); + MD5Init(&md5); + int len=data.size(); + for(int j=0;j>=2; //to aid in comparing + MD5Update(&md5,(unsigned char*)&b,1); + } + MD5Final(&md5); + uint64_t *cmp = (uint64_t*)md5.digest; //less bits, but still useful for this + + tsources[i]=Image(); //clear + + if (source_md5.has(*cmp)) { + int sidx=source_md5[*cmp]; + source_map[sidx].push_back(i); + print_line("REUSING "+from->get_source_path(i)); + } else { - sources[i].convert(Image::FORMAT_RGB); + int sidx=sources.size(); + source_md5[*cmp]=sidx; + sources.push_back(src); + List sm; + sm.push_back(i); + source_map[sidx]=sm; + } + + } //texturepacker is not really good for optimizing, so.. @@ -1141,28 +1183,44 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Refget_source_count()); + for(int i=0;i at = memnew( AtlasTexture ); Size2 sz = Size2(sources[i].get_width(),sources[i].get_height()); + + Rect2 region; + Rect2 margin; + if (crop && sz!=crops[i].size) { Rect2 rect = crops[i]; rect.size=sz-rect.size; - at->set_region(Rect2(x+border,y+border,crops[i].size.width,crops[i].size.height)); - at->set_margin(rect); + region=Rect2(x+border,y+border,crops[i].size.width,crops[i].size.height); + margin=rect; atlas.blit_rect(sources[i],crops[i],Point2(x+border,y+border)); } else { - at->set_region(Rect2(x+border,y+border,sz.x,sz.y)); + region=Rect2(x+border,y+border,sz.x,sz.y); atlas.blit_rect(sources[i],Rect2(0,0,sources[i].get_width(),sources[i].get_height()),Point2(x+border,y+border)); } - String apath = p_path.get_base_dir().plus_file(from->get_source_path(i).get_file().basename()+".atex"); - print_line("Atlas Tex: "+apath); - at->set_path(apath); - atlases.push_back(at); + ERR_CONTINUE( !source_map.has(i) ); + for (List::Element *E=source_map[i].front();E;E=E->next()) { + + Ref at = memnew( AtlasTexture ); + + + at->set_region(region); + at->set_margin(margin); + String apath = p_path.get_base_dir().plus_file(from->get_source_path(E->get()).get_file().basename()+".atex"); + at->set_path(apath); + atlases[E->get()]=at; + print_line("Atlas Tex: "+apath); + + } } if (ResourceCache::has(p_path)) { texture = Ref ( ResourceCache::get(p_path)->cast_to() ); @@ -1414,6 +1472,9 @@ Vector EditorTextureImportPlugin::custom_export(const String& p_path, c case EditorImportExport::IMAGE_ACTION_COMPRESS_RAM: { group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM; } break; //use default + case EditorImportExport::IMAGE_ACTION_KEEP: { + return Vector(); + } break; //use default } diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index 626fc6e6d..9f871fd3a 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -1216,6 +1216,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { group_image_action->add_item("Default"); group_image_action->add_item("Compress Disk"); group_image_action->add_item("Compress RAM"); + group_image_action->add_item("Keep Original"); group_options->add_margin_child("Compress Mode:",group_image_action); group_image_action->connect("item_selected",this,"_group_changed"); -- cgit v1.2.3-70-g09d2