merged some stuff for okam

This commit is contained in:
Juan Linietsky 2015-09-03 23:24:55 -03:00
parent 7900d5daf2
commit b0aa49accb
38 changed files with 470 additions and 216 deletions

View File

@ -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;\
} \

View File

@ -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();

View File

@ -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) {

View File

@ -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);

View File

@ -40,7 +40,6 @@
#endif
#include <stdio.h>
#include <stdlib.h>
#include "zlib.h"
#if defined(USE_FILE32API)

View File

@ -39,6 +39,8 @@
#ifndef _zip12_H
#define _zip12_H
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -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;

View File

@ -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_

View File

@ -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;

View File

@ -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]

View File

@ -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<StringName,SL::DataType>::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;i<bnode->statements.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<StringName,SL::Uniform>::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);

View File

@ -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') {

View File

@ -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();

View File

@ -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 ")

View File

@ -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

View File

@ -29,14 +29,13 @@
#ifndef FILE_ACCESS_ANDROID_H
#define FILE_ACCESS_ANDROID_H
#ifdef ANDROID_NATIVE_ACTIVITY
#include "os/file_access.h"
#include <stdio.h>
#include <android/asset_manager.h>
#include <android/log.h>
#include <android_native_app_glue.h>
//#include <android_native_app_glue.h>
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

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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();

View File

@ -33,13 +33,14 @@
#include "main/main.h"
#include <unistd.h>
#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);
}

View File

@ -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);

View File

@ -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<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
else
else {
#ifdef USE_JAVA_FILE_ACCESS
FileAccess::make_default<FileAccessBufferedFA<FileAccessJAndroid> >(FileAccess::ACCESS_RESOURCES);
#else
//FileAccess::make_default<FileAccessBufferedFA<FileAccessAndroid> >(FileAccess::ACCESS_RESOURCES);
FileAccess::make_default<FileAccessAndroid>(FileAccess::ACCESS_RESOURCES);
#endif
}
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
//FileAccessBufferedFA<FileAccessUnix>::make_default();

View File

@ -41,6 +41,9 @@
#include "servers/visual/rasterizer.h"
//#ifdef USE_JAVA_FILE_ACCESS
#ifdef ANDROID_NATIVE_ACTIVITY
#include <android/sensor.h>

View File

@ -43,6 +43,11 @@
#import <AdSupport/AdSupport.h>
#endif
#ifdef MODULE_PARSE_ENABLED
#import <Parse/Parse.h>
#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];

View File

@ -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',

View File

@ -34,7 +34,7 @@
#import <MediaPlayer/MediaPlayer.h>
#import <AVFoundation/AVFoundation.h>
#define USE_CADISPLAYLINK 1 //iOS version 3.1+ is required
#define USE_CADISPLAYLINK 0 //iOS version 3.1+ is required
@protocol GLViewDelegate;

View File

@ -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");

View File

@ -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'])

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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();
};

View File

@ -255,7 +255,16 @@ static void _add_filter_to_list(Set<StringName>& r_list,const String& p_filter)
}
Vector<uint8_t> EditorExportPlatform::get_exported_file_default(String& p_fname) const {
FileAccess *f = FileAccess::open(p_fname,FileAccess::READ);
ERR_FAIL_COND_V(!f,Vector<uint8_t>());
Vector<uint8_t> ret;
ret.resize(f->get_len());
int rbs = f->get_buffer(ret.ptr(),ret.size());
memdelete(f);
return ret;
}
Vector<uint8_t> EditorExportPlatform::get_exported_file(String& p_fname) const {
@ -270,13 +279,9 @@ Vector<uint8_t> EditorExportPlatform::get_exported_file(String& p_fname) const {
}
FileAccess *f = FileAccess::open(p_fname,FileAccess::READ);
ERR_FAIL_COND_V(!f,Vector<uint8_t>());
Vector<uint8_t> 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<StringName> 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<files.size();i++) {
if (remap_files.has(files[i]) || files[i]==engine_cfg) //gonna be remapped (happened before!)
continue; //from atlas?
String src=files[i];
Vector<uint8_t> buf = get_exported_file(src);
Vector<uint8_t> 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;
}

View File

@ -83,6 +83,7 @@ public:
typedef Error (*EditorExportSaveFunction)(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
protected:
Vector<uint8_t> get_exported_file_default(String& p_fname) const;
virtual Vector<uint8_t> get_exported_file(String& p_fname) const;
virtual Vector<StringName> 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 {

View File

@ -710,10 +710,126 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
//find largest source..
/************************/
/* ADD WEIGHTS IF EXIST */
/************************/
Map<int,Vector<Collada::Vertex::Weight> > 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_i<skin_controller->weights.sets.size();w_i++) {
int amount = skin_controller->weights.sets[w_i];
Vector<Collada::Vertex::Weight> weights;
for (int a_i=0;a_i<amount;a_i++) {
Collada::Vertex::Weight w;
int read_from = index_ofs+a_i*wstride;
ERR_FAIL_INDEX_V(read_from+wstride-1,skin_controller->weights.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<weights.size();i++)
total+=weights[i].weight;
if (total)
for(int i=0;i<weights.size();i++)
weights[i].weight/=total;
if (weights.size()==0 || total==0) { //if nothing, add a weight to bone 0
//no weights assigned
Collada::Vertex::Weight w;
w.bone_idx=0;
w.weight=1.0;
weights.clear();
weights.push_back(w);
}
pre_weights[w_i]=weights;
/*
for(Set<int>::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<Collada::Vertex> vertex_set; //vertex set will be the vertices
List<int> indices_list; //indices will be the indices
Map<int,Set<int> > vertex_map; //map vertices (for setting skinning/morph)
//Map<int,Set<int> > vertex_map; //map vertices (for setting skinning/morph)
/**************************/
/* CREATE PRIMITIVE ARRAY */
@ -753,11 +869,16 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& 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<Mesh>& p_mesh,con
vertex_set.insert(vertex);
}
if (!vertex_map.has(vertex_index))
/* if (!vertex_map.has(vertex_index))
vertex_map[vertex_index]=Set<int>();
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<Mesh>& p_mesh,con
vertex_array[F->get().idx]=F->get();
}
/************************/
/* ADD WEIGHTS IF EXIST */
/************************/
if (has_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_i<skin_controller->weights.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<Collada::Vertex::Weight> weights;
for (int a_i=0;a_i<amount;a_i++) {
Collada::Vertex::Weight w;
int read_from = index_ofs+a_i*wstride;
ERR_FAIL_INDEX_V(read_from+wstride-1,skin_controller->weights.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<weights.size();i++)
total+=weights[i].weight;
if (total)
for(int i=0;i<weights.size();i++)
weights[i].weight/=total;
if (weights.size()==0 || total==0) { //if nothing, add a weight to bone 0
//no weights assigned
Collada::Vertex::Weight w;
w.bone_idx=0;
w.weight=1.0;
weights.clear();
weights.push_back(w);
}
for(Set<int>::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 skeleton, localize
Transform local_xform = p_local_xform;
for(int i=0;i<vertex_array.size();i++) {
@ -1000,11 +1011,9 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
//vertex_array[i].tangent.normal*=-1.0;
}
}
has_weights=true;
}
DVector<int> index_array;
index_array.resize(indices_list.size());
DVector<int>::Write index_arrayw = index_array.write();

View File

@ -1068,12 +1068,14 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
//prepare atlas!
Vector< Image > 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;i<from->get_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<Resourc
if (src.detect_alpha())
alpha=true;
sources.push_back(src);
tsources.push_back(src);
}
ep.step("Converting Images",sources.size());
for(int i=0;i<sources.size();i++) {
int base_index=0;
Map<uint64_t,int> source_md5;
Map<int,List<int> > source_map;
for(int i=0;i<tsources.size();i++) {
Image src = tsources[i];
if (alpha) {
sources[i].convert(Image::FORMAT_RGBA);
src.convert(Image::FORMAT_RGBA);
} else {
sources[i].convert(Image::FORMAT_RGB);
src.convert(Image::FORMAT_RGB);
}
DVector<uint8_t> data = src.get_data();
MD5_CTX md5;
DVector<uint8_t>::Read r=data.read();
MD5Init(&md5);
int len=data.size();
for(int j=0;j<len;j++) {
uint8_t b = r[j];
b>>=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 {
int sidx=sources.size();
source_md5[*cmp]=sidx;
sources.push_back(src);
List<int> 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 Ref<Resourc
Image atlas;
atlas.create(nearest_power_of_2(dst_size.width),nearest_power_of_2(dst_size.height),0,alpha?Image::FORMAT_RGBA:Image::FORMAT_RGB);
atlases.resize(from->get_source_count());
for(int i=0;i<sources.size();i++) {
int x=dst_positions[i].x;
int y=dst_positions[i].y;
Ref<AtlasTexture> 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<int>::Element *E=source_map[i].front();E;E=E->next()) {
Ref<AtlasTexture> 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<ImageTexture> ( ResourceCache::get(p_path)->cast_to<ImageTexture>() );
@ -1414,6 +1472,9 @@ Vector<uint8_t> 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<uint8_t>();
} break; //use default
}

View File

@ -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");