diff options
200 files changed, 2981 insertions, 4025 deletions
diff --git a/.gitignore b/.gitignore index f7eac1122d..8ab969c9a4 100644 --- a/.gitignore +++ b/.gitignore @@ -246,6 +246,9 @@ node_modules/ #Kdevelop project files *.kdev4 +# xCode +xcuserdata + # RIA/Silverlight projects Generated_Code/ diff --git a/core/SCsub b/core/SCsub index 8d89f6427b..a9721a1052 100644 --- a/core/SCsub +++ b/core/SCsub @@ -13,7 +13,7 @@ for x in env.global_defaults: gd_inc += '#include "platform/' + x + '/globals/global_defaults.h"\n' gd_call += "\tregister_" + x + "_global_defaults();\n" -gd_cpp = '#include "globals.h"\n' +gd_cpp = '#include "global_config.h"\n' gd_cpp += gd_inc gd_cpp += "void GlobalConfig::register_global_defaults() {\n" + gd_call + "\n}\n" @@ -45,7 +45,7 @@ if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ): print("Invalid AES256 encryption key, not 64 bits hex: " + e) f = open("script_encryption_key.cpp", "wb") -f.write("#include \"globals.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n") +f.write("#include \"global_config.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n") f.close() diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 7bd652349d..54ab51657b 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -31,7 +31,7 @@ #include "geometry.h" #include "io/marshalls.h" #include "io/base64.h" -#include "core/globals.h" +#include "core/global_config.h" #include "io/file_access_encrypted.h" #include "os/keyboard.h" diff --git a/core/class_db.cpp b/core/class_db.cpp index 2eff8c07c7..4bdae45fb9 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -295,7 +295,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { OBJTYPE_RLOCK; #ifdef DEBUG_METHODS_ENABLED - uint64_t hash = hash_djb2_one_64(HashMapHahserDefault::hash(VERSION_FULL_NAME)); + uint64_t hash = hash_djb2_one_64(HashMapHasherDefault::hash(VERSION_FULL_NAME)); List<StringName> names; @@ -1256,7 +1256,7 @@ void ClassDB::get_extensions_for_type(const StringName& p_class,List<String> *p_ while((K=resource_base_extensions.next(K))) { StringName cmp = resource_base_extensions[*K]; - if (is_parent_class(cmp,p_class)) + if (is_parent_class(p_class,cmp)) p_extensions->push_back(*K); } } diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp index a173f98602..f8c6f47797 100644 --- a/core/core_string_names.cpp +++ b/core/core_string_names.cpp @@ -35,7 +35,7 @@ CoreStringNames::CoreStringNames() { _free=StaticCString::create("free"); changed=StaticCString::create("changed"); _meta=StaticCString::create("__meta__"); - _script=StaticCString::create("script/script"); + _script=StaticCString::create("script"); script_changed=StaticCString::create("script_changed"); ___pdcdata=StaticCString::create("___pdcdata"); __getvar=StaticCString::create("__getvar"); diff --git a/core/globals.cpp b/core/global_config.cpp index 0c35a9f89a..b76991c04e 100644 --- a/core/globals.cpp +++ b/core/global_config.cpp @@ -26,7 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "globals.h" +#include "global_config.h" #include "os/dir_access.h" #include "os/file_access.h" @@ -247,9 +247,22 @@ bool GlobalConfig::_load_resource_pack(const String& p_pack) { Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) { - //an absolute mess of a function, must be cleaned up and reorganized somehow at some point + //If looking for files in network, just use network! - //_load_settings(p_path+"/override.cfg"); + if (FileAccessNetworkClient::get_singleton()) { + + if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { + + _load_settings("res://override.cfg"); + + } + + return OK; + } + + String exec_path = OS::get_singleton()->get_executable_path(); + + //Attempt with a passed main pack first if (p_main_pack!="") { @@ -257,8 +270,8 @@ Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) { ERR_FAIL_COND_V(!ok,ERR_CANT_OPEN); if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { - - _load_settings("res://override.cfg"); + //load override from location of the main pack + _load_settings(p_main_pack.get_base_dir().plus_file("override.cfg")); } @@ -266,21 +279,15 @@ Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) { } - if (OS::get_singleton()->get_executable_path()!="") { + //Attempt with execname.pck + if (exec_path!="") { - if (_load_resource_pack(OS::get_singleton()->get_executable_path())) { - if (p_path!="") { - resource_path=p_path; - } else { - DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - resource_path=d->get_current_dir(); - memdelete(d); + if (_load_resource_pack(exec_path.get_basename()+".pck")) { - } if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { - - _load_settings("res://override.cfg"); + //load override from location of executable + _load_settings(exec_path.get_base_dir().plus_file("override.cfg")); } @@ -292,31 +299,19 @@ Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) { } - if (FileAccessNetworkClient::get_singleton()) { - - if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { - - _load_settings("res://override.cfg"); - - } - - return OK; - } - + //Try to use the filesystem for files, according to OS. (only Android -when reading from pck- and iOS use this) if (OS::get_singleton()->get_resource_dir()!="") { - //OS will call Globals->get_resource_path which will be empty if not overriden! + //OS will call Globals->get_resource_path which will be empty if not overriden! //if the OS would rather use somewhere else, then it will not be empty. + resource_path=OS::get_singleton()->get_resource_dir().replace("\\","/"); if (resource_path.length() && resource_path[ resource_path.length()-1]=='/') resource_path=resource_path.substr(0,resource_path.length()-1); // chop end - print_line("has res dir: "+resource_path); - if (!_load_resource_pack("res://data.pck")) - _load_resource_pack("res://data.zip"); - // make sure this is load from the resource path - print_line("exists engine cfg? "+itos(FileAccess::exists("/godot.cfg"))); + // data.pck and data.zip are deprecated and no longer supported, apologies. + // make sure this is loaded from the resource path + if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { - print_line("loaded godot.cfg"); _load_settings("res://override.cfg"); } @@ -324,67 +319,41 @@ Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) { return OK; } - DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - if (!d) { - - resource_path = p_path; - - } else { - - d->change_dir(p_path); - - String candidate = d->get_current_dir(); - String current_dir = d->get_current_dir(); - String exec_name = OS::get_singleton()->get_executable_path().get_file().get_basename(); - bool found = false; - bool first_time=true; - - while(true) { - //try to load settings in ascending through dirs shape! - - //tries to open pack, but only first time - if (first_time && (_load_resource_pack(current_dir+"/"+exec_name+".pck") || _load_resource_pack(current_dir+"/"+exec_name+".zip") )) { - if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { + //Nothing was found, try to find a godot.cfg somewhere! - _load_settings("res://override.cfg"); - found=true; - - - } - break; - } else if (first_time && (_load_resource_pack(current_dir+"/data.pck") || _load_resource_pack(current_dir+"/data.zip") )) { - if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { + DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + ERR_FAIL_COND_V(!d,ERR_CANT_CREATE); - _load_settings("res://override.cfg"); - found=true; + d->change_dir(p_path); + String candidate = d->get_current_dir(); + String current_dir = d->get_current_dir(); + bool found = false; - } - break; - } else if (_load_settings(current_dir+"/godot.cfg")==OK || _load_settings_binary(current_dir+"/godot.cfb")==OK) { + while(true) { + //try to load settings in ascending through dirs shape! - _load_settings(current_dir+"/override.cfg"); - candidate=current_dir; - found=true; - break; - } + if (_load_settings(current_dir+"/godot.cfg")==OK || _load_settings_binary(current_dir+"/godot.cfb")==OK) { - d->change_dir(".."); - if (d->get_current_dir()==current_dir) - break; //not doing anything useful - current_dir=d->get_current_dir(); - first_time=false; + _load_settings(current_dir+"/override.cfg"); + candidate=current_dir; + found=true; + break; } + d->change_dir(".."); + if (d->get_current_dir()==current_dir) + break; //not doing anything useful + current_dir=d->get_current_dir(); + } - resource_path=candidate; - resource_path = resource_path.replace("\\","/"); // windows path to unix path just in case - memdelete(d); - if (!found) - return ERR_FILE_NOT_FOUND; - }; + resource_path=candidate; + resource_path = resource_path.replace("\\","/"); // windows path to unix path just in case + memdelete(d); + if (!found) + return ERR_FILE_NOT_FOUND; if (resource_path.length() && resource_path[ resource_path.length()-1]=='/') resource_path=resource_path.substr(0,resource_path.length()-1); // chop end diff --git a/core/globals.h b/core/global_config.h index faf077f2a5..471f1ff885 100644 --- a/core/globals.h +++ b/core/global_config.h @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GLOBALS_H -#define GLOBALS_H +#ifndef GLOBAL_CONFIG_H +#define GLOBAL_CONFIG_H #include "object.h" #include "set.h" diff --git a/core/hash_map.h b/core/hash_map.h index 0d55206935..515fc6c4fe 100644 --- a/core/hash_map.h +++ b/core/hash_map.h @@ -30,40 +30,45 @@ #define HASH_MAP_H #include "hashfuncs.h" +#include "math_funcs.h" #include "error_macros.h" #include "ustring.h" #include "os/memory.h" #include "list.h" - -class HashMapHahserDefault { -public: - +struct HashMapHasherDefault { static _FORCE_INLINE_ uint32_t hash(const String &p_string) { return p_string.hash(); } static _FORCE_INLINE_ uint32_t hash(const char *p_cstr) { return hash_djb2(p_cstr); } - static _FORCE_INLINE_ uint32_t hash(const uint64_t p_int) { - uint64_t v=p_int; - v = (~v) + (v << 18); // v = (v << 18) - v - 1; - v = v ^ (v >> 31); - v = v * 21; // v = (v + (v << 2)) + (v << 4); - v = v ^ (v >> 11); - v = v + (v << 6); - v = v ^ (v >> 22); - return (int) v; - } - static _FORCE_INLINE_ uint32_t hash(const int64_t p_int) { return hash(uint64_t(p_int)); } + static _FORCE_INLINE_ uint32_t hash(const uint64_t p_int) { return hash_one_uint64(p_int); } - - static _FORCE_INLINE_ uint32_t hash(const uint32_t p_int) { return p_int; } + static _FORCE_INLINE_ uint32_t hash(const int64_t p_int) { return hash(uint64_t(p_int)); } + static _FORCE_INLINE_ uint32_t hash(const float p_float) { return hash_djb2_one_float(p_float); } + static _FORCE_INLINE_ uint32_t hash(const double p_double){ return hash_djb2_one_float(p_double); } + static _FORCE_INLINE_ uint32_t hash(const uint32_t p_int) { return p_int; } static _FORCE_INLINE_ uint32_t hash(const int32_t p_int) { return (uint32_t)p_int; } - static _FORCE_INLINE_ uint32_t hash(const uint16_t p_int) { return p_int; } + static _FORCE_INLINE_ uint32_t hash(const uint16_t p_int) { return p_int; } static _FORCE_INLINE_ uint32_t hash(const int16_t p_int) { return (uint32_t)p_int; } static _FORCE_INLINE_ uint32_t hash(const uint8_t p_int) { return p_int; } - static _FORCE_INLINE_ uint32_t hash(const int8_t p_int) { return (uint32_t)p_int; } - static _FORCE_INLINE_ uint32_t hash(const wchar_t p_wchar) { return (uint32_t)p_wchar; } + static _FORCE_INLINE_ uint32_t hash(const int8_t p_int) { return (uint32_t)p_int; } + static _FORCE_INLINE_ uint32_t hash(const wchar_t p_wchar){ return (uint32_t)p_wchar; } //static _FORCE_INLINE_ uint32_t hash(const void* p_ptr) { return uint32_t(uint64_t(p_ptr))*(0x9e3779b1L); } }; +template <typename T> +struct HashMapComparatorDefault { + static bool compare(const T& p_lhs, const T& p_rhs) { + return p_lhs == p_rhs; + } + + bool compare(const float& p_lhs, const float& p_rhs) { + return (p_lhs == p_rhs) || (Math::is_nan(p_lhs) && Math::is_nan(p_rhs)); + } + + bool compare(const double& p_lhs, const double& p_rhs) { + return (p_lhs == p_rhs) || (Math::is_nan(p_lhs) && Math::is_nan(p_rhs)); + } +}; + /** * @class HashMap * @author Juan Linietsky <reduzio@gmail.com> @@ -74,13 +79,14 @@ public: * @param TKey Key, search is based on it, needs to be hasheable. It is unique in this container. * @param TData Data, data associated with the key * @param Hasher Hasher object, needs to provide a valid static hash function for TKey + * @param Comparator comparator object, needs to be able to safely compare two TKey values. It needs to ensure that x == x for any items inserted in the map. Bear in mind that nan != nan when implementing an equality check. * @param MIN_HASH_TABLE_POWER Miminum size of the hash table, as a power of two. You rarely need to change this parameter. * @param RELATIONSHIP Relationship at which the hash table is resized. if amount of elements is RELATIONSHIP * times bigger than the hash table, table is resized to solve this condition. if RELATIONSHIP is zero, table is always MIN_HASH_TABLE_POWER. * */ -template<class TKey, class TData, class Hasher=HashMapHahserDefault,uint8_t MIN_HASH_TABLE_POWER=3,uint8_t RELATIONSHIP=8> +template<class TKey, class TData, class Hasher=HashMapHasherDefault, class Comparator=HashMapComparatorDefault<TKey>, uint8_t MIN_HASH_TABLE_POWER=3,uint8_t RELATIONSHIP=8> class HashMap { public: @@ -194,7 +200,6 @@ private: } - /* I want to have only one function.. */ _FORCE_INLINE_ const Entry * get_entry( const TKey& p_key ) const { @@ -206,7 +211,7 @@ private: while (e) { /* checking hash first avoids comparing key, which may take longer */ - if (e->hash == hash && e->pair.key == p_key ) { + if (e->hash == hash && Comparator::compare(e->pair.key,p_key) ) { /* the pair exists in this hashtable, so just update data */ return e; @@ -253,7 +258,6 @@ private: for (int i=0;i<( 1<<p_t.hash_table_power );i++) { hash_table[i]=NULL; - /* elements will be in the reverse order, but it doesn't matter */ const Entry *e = p_t.hash_table[i]; @@ -385,7 +389,7 @@ public: while (e) { /* checking hash first avoids comparing key, which may take longer */ - if (e->hash == hash && e->pair.key == p_custom_key ) { + if (e->hash == hash && Comparator::compare(e->pair.key,p_custom_key) ) { /* the pair exists in this hashtable, so just update data */ return &e->pair.data; @@ -411,7 +415,7 @@ public: while (e) { /* checking hash first avoids comparing key, which may take longer */ - if (e->hash == hash && e->pair.key == p_custom_key ) { + if (e->hash == hash && Comparator::compare(e->pair.key,p_custom_key) ) { /* the pair exists in this hashtable, so just update data */ return &e->pair.data; @@ -442,7 +446,7 @@ public: while (e) { /* checking hash first avoids comparing key, which may take longer */ - if (e->hash == hash && e->pair.key == p_key ) { + if (e->hash == hash && Comparator::compare(e->pair.key,p_key) ) { if (p) { @@ -637,7 +641,8 @@ public: clear(); } - }; + + #endif diff --git a/core/hashfuncs.h b/core/hashfuncs.h index e9e57d8b42..121d7e8c59 100644 --- a/core/hashfuncs.h +++ b/core/hashfuncs.h @@ -29,7 +29,8 @@ #ifndef HASHFUNCS_H #define HASHFUNCS_H - +#include "math_funcs.h" +#include "math_defs.h" #include "typedefs.h" /** @@ -69,19 +70,52 @@ static inline uint32_t hash_djb2_one_32(uint32_t p_in,uint32_t p_prev=5381) { return ((p_prev<<5)+p_prev)+p_in; } +static inline uint32_t hash_one_uint64(const uint64_t p_int) { + uint64_t v=p_int; + v = (~v) + (v << 18); // v = (v << 18) - v - 1; + v = v ^ (v >> 31); + v = v * 21; // v = (v + (v << 2)) + (v << 4); + v = v ^ (v >> 11); + v = v + (v << 6); + v = v ^ (v >> 22); + return (int) v; +} + static inline uint32_t hash_djb2_one_float(float p_in,uint32_t p_prev=5381) { union { float f; uint32_t i; } u; - // handle -0 case - if (p_in==0.0f) u.f=0.0f; - else u.f=p_in; + // Normalize +/- 0.0 and NaN values so they hash the same. + if (p_in==0.0f) + u.f=0.0; + else if (Math::is_nan(p_in)) + u.f=Math_NAN; + else + u.f=p_in; return ((p_prev<<5)+p_prev)+u.i; } +// Overload for real_t size changes +static inline uint32_t hash_djb2_one_float(double p_in,uint32_t p_prev=5381) { + union { + double d; + uint64_t i; + } u; + + // Normalize +/- 0.0 and NaN values so they hash the same. + if (p_in==0.0f) + u.d=0.0; + else if (Math::is_nan(p_in)) + u.d=Math_NAN; + else + u.d=p_in; + + return ((p_prev<<5)+p_prev) + hash_one_uint64(u.i); +} + template<class T> static inline uint32_t make_uint32_t(T p_in) { diff --git a/core/input_map.cpp b/core/input_map.cpp index 249c75cea0..444c55cac6 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "input_map.h" -#include "globals.h" +#include "global_config.h" #include "os/keyboard.h" InputMap *InputMap::singleton=NULL; diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 32eb003228..b4ba14ddc9 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -30,7 +30,7 @@ #include "os/dir_access.h" #include "os/copymem.h" -#include "globals.h" +#include "global_config.h" #include "map.h" static Map<String, Vector<uint8_t> >* files = NULL; diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index 7bf750f6e1..d9fdc9cedc 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "file_access_network.h" #include "marshalls.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" #include "io/ip.h" diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index d63539a7a5..fa1bebde16 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -31,7 +31,7 @@ #include <stdio.h> -#define PACK_VERSION 0 +#define PACK_VERSION 1 Error PackedData::add_pack(const String& p_path) { @@ -167,8 +167,8 @@ bool PackedSourcePCK::try_open_pack(const String& p_path) { uint32_t ver_minor = f->get_32(); uint32_t ver_rev = f->get_32(); - ERR_EXPLAIN("Pack version newer than supported by engine: "+itos(version)); - ERR_FAIL_COND_V( version > PACK_VERSION, ERR_INVALID_DATA); + ERR_EXPLAIN("Pack version unsupported: "+itos(version)); + ERR_FAIL_COND_V( version != PACK_VERSION, ERR_INVALID_DATA); ERR_EXPLAIN("Pack created with a newer version of the engine: "+itos(ver_major)+"."+itos(ver_minor)+"."+itos(ver_rev)); ERR_FAIL_COND_V( ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR), ERR_INVALID_DATA); diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index aca095b6a5..cf5883121f 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -29,7 +29,7 @@ #include "packet_peer.h" #include "io/marshalls.h" -#include "globals.h" +#include "global_config.h" /* helpers / binders */ diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index c75e476764..2d733842fa 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "version.h" #include "resource_format_binary.h" -#include "globals.h" +#include "global_config.h" #include "io/file_access_compressed.h" #include "io/marshalls.h" #include "os/dir_access.h" @@ -98,6 +98,27 @@ void ResourceInteractiveLoaderBinary::_advance_padding(uint32_t p_len) { } + +StringName ResourceInteractiveLoaderBinary::_get_string() { + + uint32_t id = f->get_32(); + if (id&0x80000000) { + uint32_t len = id&0x7FFFFFFF; + if (len>str_buf.size()) { + str_buf.resize(len); + } + if (len==0) + return StringName(); + f->get_buffer((uint8_t*)&str_buf[0],len); + String s; + s.parse_utf8(&str_buf[0]); + return s; + } + + return string_map[id]; + +} + Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { @@ -272,8 +293,8 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { Image::Format fmt=Image::Format(format&format_version_mask); //if format changes, we can add a compatibility bit on top - uint32_t datalen = f->get_32(); + print_line("image format: "+String(Image::get_format_name(fmt))+" datalen "+itos(datalen)); PoolVector<uint8_t> imgdata; imgdata.resize(datalen); @@ -282,6 +303,14 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { _advance_padding(datalen); w=PoolVector<uint8_t>::Write(); +#ifdef TOOLS_ENABLED +//compatibility + int correct_size = Image::get_image_data_size(width,height,fmt,mipmaps?-1:0); + if (correct_size < datalen) { + WARN_PRINT("Image data was too large, shrinking for compatibility") + imgdata.resize(correct_size); + } +#endif r_v=Image(width,height,mipmaps,fmt,imgdata); } else { @@ -323,10 +352,10 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { for(int i=0;i<name_count;i++) - names.push_back(string_map[f->get_32()]); + names.push_back(_get_string()); for(uint32_t i=0;i<subname_count;i++) - subnames.push_back(string_map[f->get_32()]); - property=string_map[f->get_32()]; + subnames.push_back(_get_string()); + property=_get_string(); NodePath np = NodePath(names,subnames,absolute,property); //print_line("got path: "+String(np)); @@ -641,6 +670,8 @@ Error ResourceInteractiveLoaderBinary::poll(){ if (s<external_resources.size()) { String path = external_resources[s].path; + + print_line("load external res: "+path); if (remaps.has(path)) { path=remaps[path]; } @@ -711,6 +742,8 @@ Error ResourceInteractiveLoaderBinary::poll(){ String t = get_unicode_string(); +// print_line("loading resource of type "+t+" path is "+path); + Object *obj = ClassDB::instance(t); if (!obj) { error=ERR_FILE_CORRUPT; @@ -737,8 +770,8 @@ Error ResourceInteractiveLoaderBinary::poll(){ for(int i=0;i<pc;i++) { - uint32_t name_idx = f->get_32(); - if (name_idx>=(uint32_t)string_map.size()) { + StringName name = _get_string(); + if (name==StringName()) { error=ERR_FILE_CORRUPT; ERR_FAIL_V(ERR_FILE_CORRUPT); } @@ -749,7 +782,7 @@ Error ResourceInteractiveLoaderBinary::poll(){ if (error) return error; - res->set(string_map[name_idx],value); + res->set(name,value); } #ifdef TOOLS_ENABLED res->set_edited(false); @@ -2143,6 +2176,8 @@ void ResourceFormatSaverBinary::get_recognized_extensions(const RES& p_resource, String base = p_resource->get_base_extension().to_lower(); p_extensions->push_back(base); + if (base!="res") + p_extensions->push_back("res"); } diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 1dac51cc5c..1fab6144d5 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -54,6 +54,8 @@ class ResourceInteractiveLoaderBinary : public ResourceInteractiveLoader { //Map<int,StringName> string_map; Vector<StringName> string_map; + StringName _get_string(); + struct ExtResoucre { String path; String type; diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp index 556dff3125..892c2988dc 100644 --- a/core/io/resource_import.cpp +++ b/core/io/resource_import.cpp @@ -81,8 +81,10 @@ RES ResourceFormatImporter::load(const String &p_path,const String& p_original_p RES res = ResourceLoader::load(pat.path,pat.type,false,r_error); #ifdef TOOLS_ENABLED - res->set_import_last_modified_time( res->get_last_modified_time() ); //pass this, if used - res->set_import_path(pat.path); + if (res.is_valid()) { + res->set_import_last_modified_time( res->get_last_modified_time() ); //pass this, if used + res->set_import_path(pat.path); + } #endif return res; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 3199f05ff8..c14389eefa 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "resource_loader.h" #include "print_string.h" -#include "globals.h" +#include "global_config.h" #include "path_remap.h" #include "os/file_access.h" #include "os/os.h" @@ -61,6 +61,7 @@ bool ResourceFormatLoader::recognize_path(const String& p_path,const String& p_f for (List<String>::Element *E=extensions.front();E;E=E->next()) { + if (E->get().nocasecmp_to(extension)==0) return true; } @@ -191,12 +192,15 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p for (int i=0;i<loader_count;i++) { - if (!loader[i]->recognize_path(local_path,p_type_hint)) + if (!loader[i]->recognize_path(local_path,p_type_hint)) { + print_line("path not recognized"); continue; + } found=true; RES res = loader[i]->load(local_path,local_path,r_error); - if (res.is_null()) + if (res.is_null()) { continue; + } if (!p_no_cache) res->set_path(local_path); #ifdef TOOLS_ENABLED diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 222d3e6bc0..f0bea30051 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "resource_saver.h" -#include "globals.h" +#include "global_config.h" #include "os/file_access.h" #include "script_language.h" #include "resource_loader.h" diff --git a/core/math/geometry.h b/core/math/geometry.h index 13cbbdce6f..1dd7df038d 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -109,6 +109,7 @@ public: static void get_closest_points_between_segments(const Vector3& p1,const Vector3& p2,const Vector3& q1,const Vector3& q2,Vector3& c1, Vector3& c2) { +#if 0 //do the function 'd' as defined by pb. I think is is dot product of some sort #define d_of(m,n,o,p) ( (m.x - n.x) * (o.x - p.x) + (m.y - n.y) * (o.y - p.y) + (m.z - n.z) * (o.z - p.z) ) @@ -123,6 +124,33 @@ public: if (mub > 1) mub = 1; c1 = p1.linear_interpolate(p2,mua); c2 = q1.linear_interpolate(q2,mub); +#endif + + Vector3 u = p2 - p1; + Vector3 v = q2 - q1; + Vector3 w = p1 - q1; + float a = u.dot(u); + float b = u.dot(v); + float c = v.dot(v); // always >= 0 + float d = u.dot(w); + float e = v.dot(w); + float D = a*c - b*b; // always >= 0 + float sc, tc; + + // compute the line parameters of the two closest points + if (D < CMP_EPSILON) { // the lines are almost parallel + sc = 0.0; + tc = (b>c ? d/b : e/c); // use the largest denominator + } + else { + sc = (b*e - c*d) / D; + tc = (a*e - b*d) / D; + } + + c1 = w + sc * u; + c2 = w + tc * v; + // get the difference of the two closest points + //Vector dP = w + (sc * u) - (tc * v); // = L1(sc) - L2(tc) } static real_t get_closest_distance_between_segments( const Vector3& p_from_a,const Vector3& p_to_a, const Vector3& p_from_b,const Vector3& p_to_b) { diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 511af91835..51877891e3 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -39,6 +39,7 @@ #define Math_PI 3.14159265358979323846 #define Math_SQRT12 0.7071067811865475244008443621048490 #define Math_LN2 0.693147180559945309417 +#define Math_NAN NAN class Math { diff --git a/core/message_queue.cpp b/core/message_queue.cpp index 668d321e05..50b52e4970 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "message_queue.h" -#include "globals.h" +#include "global_config.h" #include "script_language.h" MessageQueue *MessageQueue::singleton=NULL; diff --git a/core/object.cpp b/core/object.cpp index 730b4209fe..79905a6be6 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -383,7 +383,7 @@ void Object::set(const String& p_name, const Variant& p_value) { if (p_name=="__meta__") { metadata=p_value; - } else if (p_name=="script/script") { + } else if (p_name=="script") { set_script(p_value); } else if (script_instance) { script_instance->set(p_name,p_value); @@ -516,7 +516,7 @@ Variant Object::get(const String& p_name) const { if (p_name=="__meta__") return metadata; - else if (p_name=="script/script") + else if (p_name=="script") return script; if (script_instance) { @@ -539,7 +539,7 @@ void Object::get_property_list(List<PropertyInfo> *p_list,bool p_reversed) const if (!is_class("Script")) // can still be set, but this is for userfriendlyness - p_list->push_back( PropertyInfo( Variant::OBJECT, "script/script", PROPERTY_HINT_RESOURCE_TYPE, "Script",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_STORE_IF_NONZERO)); + p_list->push_back( PropertyInfo( Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_STORE_IF_NONZERO)); if (!metadata.empty()) p_list->push_back( PropertyInfo( Variant::DICTIONARY, "__meta__", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR|PROPERTY_USAGE_STORE_IF_NONZERO)); if (script_instance && !p_reversed) { @@ -1041,7 +1041,7 @@ void Object::set_script(const RefPtr& p_script) { } - _change_notify("script/script"); + _change_notify("script"); emit_signal(CoreStringNames::get_singleton()->script_changed); } diff --git a/core/object.h b/core/object.h index ba4fa62e1a..3fe31bee6b 100644 --- a/core/object.h +++ b/core/object.h @@ -680,7 +680,7 @@ class ObjectDB { unsigned long i; } u; u.p=p_obj; - return HashMapHahserDefault::hash((uint64_t)u.i); + return HashMapHasherDefault::hash((uint64_t)u.i); } }; diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 804fe15c39..974225a3e8 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -30,7 +30,7 @@ #include "os/file_access.h" #include "os/memory.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" String DirAccess::_get_root_path() const { diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 06723c5131..ae592720e8 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "file_access.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" #include "core/io/marshalls.h" #include "io/md5.h" diff --git a/core/os/input.cpp b/core/os/input.cpp index e20c966ff2..34883e63ba 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -29,7 +29,7 @@ #include "input.h" #include "input_map.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" Input *Input::singleton=NULL; Input *Input::get_singleton() { diff --git a/core/os/os.cpp b/core/os/os.cpp index 3a8e15a692..912f7f0b0f 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -29,7 +29,7 @@ #include "os.h" #include "dir_access.h" -#include "globals.h" +#include "global_config.h" #include "input.h" #include "os/file_access.h" diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index ab94b56cdc..00f6f8662f 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -35,7 +35,7 @@ #include "io/packet_peer.h" #include "math/a_star.h" #include "math/triangle_mesh.h" -#include "globals.h" +#include "global_config.h" #include "class_db.h" #include "geometry.h" #include "bind/core_bind.h" diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 62d14c4e5a..b14eb51b6c 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -30,7 +30,7 @@ #include "os/os.h" #include "io/ip.h" -#include "globals.h" +#include "global_config.h" #include "os/input.h" void ScriptDebuggerRemote::_send_video_memory() { diff --git a/core/translation.cpp b/core/translation.cpp index 655bfd36b8..d9d4fe7784 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "translation.h" -#include "globals.h" +#include "global_config.h" #include "io/resource_loader.h" #include "os/os.h" diff --git a/core/ustring.cpp b/core/ustring.cpp index a0d26ea0af..c13c13ec11 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -52,8 +52,40 @@ #define UPPERCASE(m_c) (((m_c)>='a' && (m_c)<='z')?((m_c)-('a'-'A')):(m_c)) #define LOWERCASE(m_c) (((m_c)>='A' && (m_c)<='Z')?((m_c)+('a'-'A')):(m_c)) + + + /** STRING **/ +bool CharString::operator<(const CharString& p_right) const { + + if (length()==0) { + return p_right.length()!=0; + } + + + const char *this_str=get_data(); + const char *that_str=get_data(); + while (true) { + + if (*that_str==0 && *this_str==0) + return false; //this can't be equal, sadly + else if (*this_str==0) + return true; //if this is empty, and the other one is not, then we're less.. I think? + else if (*that_str==0) + return false; //otherwise the other one is smaller.. + else if (*this_str < *that_str ) //more than + return true; + else if (*this_str > *that_str ) //less than + return false; + + this_str++; + that_str++; + } + + return false; //should never reach here anyway +} + const char *CharString::get_data() const { if (size()) diff --git a/core/ustring.h b/core/ustring.h index 5665a23112..87289f9e16 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -41,6 +41,8 @@ class CharString : public Vector<char> { public: + + bool operator<(const CharString& p_right) const; int length() const { return size() ? size()-1 : 0; } const char *get_data() const; operator const char*() {return get_data();}; diff --git a/core/variant.cpp b/core/variant.cpp index 103c8f6746..132d7a1c88 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -28,6 +28,7 @@ /*************************************************************************/ #include "variant.h" +#include "math_funcs.h" #include "resource.h" #include "print_string.h" #include "scene/main/node.h" @@ -2674,14 +2675,10 @@ uint32_t Variant::hash() const { case INT: { return _data._int; - } break; case REAL: { - MarshallFloat mf; - mf.f=_data._real; - return mf.i; - + return hash_djb2_one_float(_data._real); } break; case STRING: { @@ -2921,6 +2918,186 @@ uint32_t Variant::hash() const { } +#define hash_compare_scalar(p_lhs, p_rhs)\ + ((p_lhs) == (p_rhs)) || (Math::is_nan(p_lhs) == Math::is_nan(p_rhs)) + +#define hash_compare_vector2(p_lhs, p_rhs)\ + (hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \ + (hash_compare_scalar((p_lhs).y, (p_rhs).y)) + +#define hash_compare_vector3(p_lhs, p_rhs)\ + (hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \ + (hash_compare_scalar((p_lhs).y, (p_rhs).y)) && \ + (hash_compare_scalar((p_lhs).z, (p_rhs).z)) + +#define hash_compare_quat(p_lhs, p_rhs)\ + (hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \ + (hash_compare_scalar((p_lhs).y, (p_rhs).y)) && \ + (hash_compare_scalar((p_lhs).z, (p_rhs).z)) && \ + (hash_compare_scalar((p_lhs).w, (p_rhs).w)) + +#define hash_compare_color(p_lhs, p_rhs)\ + (hash_compare_scalar((p_lhs).r, (p_rhs).r)) && \ + (hash_compare_scalar((p_lhs).g, (p_rhs).g)) && \ + (hash_compare_scalar((p_lhs).b, (p_rhs).b)) && \ + (hash_compare_scalar((p_lhs).a, (p_rhs).a)) + +#define hash_compare_pool_array(p_lhs, p_rhs, p_type, p_compare_func)\ + const PoolVector<p_type>& l = *reinterpret_cast<const PoolVector<p_type>*>(p_lhs);\ + const PoolVector<p_type>& r = *reinterpret_cast<const PoolVector<p_type>*>(p_rhs);\ + \ + if(l.size() != r.size()) \ + return false; \ + \ + PoolVector<p_type>::Read lr = l.read(); \ + PoolVector<p_type>::Read rr = r.read(); \ + \ + for(int i = 0; i < l.size(); ++i) { \ + if(! p_compare_func((lr[0]), (rr[0]))) \ + return false; \ + }\ + \ + return true + +bool Variant::hash_compare(const Variant& p_variant) const { + if (type != p_variant.type) + return false; + + switch( type ) { + case REAL: { + return hash_compare_scalar(_data._real, p_variant._data._real); + } break; + + case VECTOR2: { + const Vector2* l = reinterpret_cast<const Vector2*>(_data._mem); + const Vector2* r = reinterpret_cast<const Vector2*>(p_variant._data._mem); + + return hash_compare_vector2(*l, *r); + } break; + + case RECT2: { + const Rect2* l = reinterpret_cast<const Rect2*>(_data._mem); + const Rect2* r = reinterpret_cast<const Rect2*>(p_variant._data._mem); + + return (hash_compare_vector2(l->pos, r->pos)) && + (hash_compare_vector2(l->size, r->size)); + } break; + + case TRANSFORM2D: { + Transform2D* l = _data._transform2d; + Transform2D* r = p_variant._data._transform2d; + + for(int i=0;i<3;i++) { + if (! (hash_compare_vector2(l->elements[i], r->elements[i]))) + return false; + } + + return true; + } break; + + case VECTOR3: { + const Vector3* l = reinterpret_cast<const Vector3*>(_data._mem); + const Vector3* r = reinterpret_cast<const Vector3*>(p_variant._data._mem); + + return hash_compare_vector3(*l, *r); + } break; + + case PLANE: { + const Plane* l = reinterpret_cast<const Plane*>(_data._mem); + const Plane* r = reinterpret_cast<const Plane*>(p_variant._data._mem); + + return (hash_compare_vector3(l->normal, r->normal)) && + (hash_compare_scalar(l->d, r->d)); + } break; + + case RECT3: { + const Rect3* l = _data._rect3; + const Rect3* r = p_variant._data._rect3; + + return (hash_compare_vector3(l->pos, r->pos) && + (hash_compare_vector3(l->size, r->size))); + + } break; + + case QUAT: { + const Quat* l = reinterpret_cast<const Quat*>(_data._mem); + const Quat* r = reinterpret_cast<const Quat*>(p_variant._data._mem); + + return hash_compare_quat(*l, *r); + } break; + + case BASIS: { + const Basis* l = _data._basis; + const Basis* r = p_variant._data._basis; + + for(int i=0;i<3;i++) { + if (! (hash_compare_vector3(l->elements[i], r->elements[i]))) + return false; + } + + return true; + } break; + + case TRANSFORM: { + const Transform* l = _data._transform; + const Transform* r = p_variant._data._transform; + + for(int i=0;i<3;i++) { + if (! (hash_compare_vector3(l->basis.elements[i], r->basis.elements[i]))) + return false; + } + + return hash_compare_vector3(l->origin, r->origin); + } break; + + case COLOR: { + const Color* l = reinterpret_cast<const Color*>(_data._mem); + const Color* r = reinterpret_cast<const Color*>(p_variant._data._mem); + + return hash_compare_color(*l, *r); + } break; + + case ARRAY: { + const Array& l = *(reinterpret_cast<const Array*>(_data._mem)); + const Array& r = *(reinterpret_cast<const Array*>(p_variant._data._mem)); + + if(l.size() != r.size()) + return false; + + for(int i = 0; i < l.size(); ++i) { + if(! l[0].hash_compare(r[0])) + return false; + } + + return true; + } break; + + case POOL_REAL_ARRAY: { + hash_compare_pool_array(_data._mem, p_variant._data._mem, real_t, hash_compare_scalar); + } break; + + case POOL_VECTOR2_ARRAY: { + hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector2, hash_compare_vector2); + } break; + + case POOL_VECTOR3_ARRAY: { + hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector3, hash_compare_vector3); + } break; + + case POOL_COLOR_ARRAY: { + hash_compare_pool_array(_data._mem, p_variant._data._mem, Color, hash_compare_color); + } break; + + default: + bool v; + Variant r; + evaluate(OP_EQUAL,*this,p_variant,r,v); + return r; + } + + return false; +} + bool Variant::is_ref() const { diff --git a/core/variant.h b/core/variant.h index 5936325c1b..f9ceca1ca0 100644 --- a/core/variant.h +++ b/core/variant.h @@ -421,6 +421,7 @@ public: bool operator<(const Variant& p_variant) const; uint32_t hash() const; + bool hash_compare(const Variant& p_variant) const; bool booleanize(bool &valid) const; void static_assign(const Variant& p_variant); @@ -459,6 +460,10 @@ struct VariantHasher { static _FORCE_INLINE_ uint32_t hash(const Variant &p_variant) { return p_variant.hash(); } }; +struct VariantComparator { + + static _FORCE_INLINE_ bool compare(const Variant &p_lhs, const Variant &p_rhs) { return p_lhs.hash_compare(p_rhs); } +}; Variant::ObjData& Variant::_get_obj() { diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index 8984d412a3..f2616b11b8 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -30,7 +30,7 @@ #ifdef ALSA_ENABLED -#include "globals.h" +#include "global_config.h" #include <errno.h> diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 1486e85a04..94c5ecdec1 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -30,7 +30,7 @@ #include "rasterizer_gles2.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" #include <stdio.h> #include "servers/visual/shader_language.h" #include "servers/visual/particle_system_sw.h" diff --git a/drivers/gles2/shader_gles2.h b/drivers/gles2/shader_gles2.h index 509f9a82b4..004d636c1e 100644 --- a/drivers/gles2/shader_gles2.h +++ b/drivers/gles2/shader_gles2.h @@ -134,7 +134,7 @@ private: struct VersionKeyHash { - static _FORCE_INLINE_ uint32_t hash( const VersionKey& p_key) { return HashMapHahserDefault::hash(p_key.key); }; + static _FORCE_INLINE_ uint32_t hash( const VersionKey& p_key) { return HashMapHasherDefault::hash(p_key.key); }; }; //this should use a way more cachefriendly version.. diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 2923dfff9f..5980a645fa 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -382,7 +382,7 @@ void RasterizerCanvasGLES3::_draw_gui_primitive(int p_points, const Vector2 *p_v } - float b[(2+2+4)]; + float b[(2+2+4)*4]; for(int i=0;i<p_points;i++) { @@ -646,7 +646,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item,Item *curr state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE,texpixel_size); } - _draw_polygon(polygon->count,polygon->indices.ptr(),polygon->points.ptr(),polygon->uvs.ptr(),polygon->colors.ptr(),polygon->texture,polygon->colors.size()==1); + //_draw_polygon(polygon->count,polygon->indices.ptr(),polygon->points.ptr(),polygon->uvs.ptr(),polygon->colors.ptr(),polygon->texture,polygon->colors.size()==1); } break; case Item::Command::TYPE_CIRCLE: { @@ -666,7 +666,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item,Item *curr indices[i*3+1]=(i+1)%numpoints; indices[i*3+2]=numpoints; } - _draw_polygon(numpoints*3,indices,points,NULL,&circle->color,RID(),true); + //_draw_polygon(numpoints*3,indices,points,NULL,&circle->color,RID(),true); //canvas_draw_circle(circle->indices.size(),circle->indices.ptr(),circle->points.ptr(),circle->uvs.ptr(),circle->colors.ptr(),circle->texture,circle->colors.size()==1); } break; case Item::Command::TYPE_TRANSFORM: { @@ -1459,7 +1459,7 @@ void RasterizerCanvasGLES3::initialize() { glGenBuffers(1,&data.primitive_quad_buffer); glBindBuffer(GL_ARRAY_BUFFER,data.primitive_quad_buffer); - glBufferData(GL_ARRAY_BUFFER,sizeof(float)*2+sizeof(float)*2+sizeof(float)*4,NULL,GL_DYNAMIC_DRAW); //allocate max size + glBufferData(GL_ARRAY_BUFFER,(2+2+4)*4*sizeof(float),NULL,GL_DYNAMIC_DRAW); //allocate max size glBindBuffer(GL_ARRAY_BUFFER,0); diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index e1ddad0dc9..aea4642d88 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -1,6 +1,6 @@ #include "rasterizer_gles3.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" #include "gl_context/context_gl.h" #include <string.h> RasterizerStorage *RasterizerGLES3::get_storage() { @@ -167,7 +167,6 @@ void RasterizerGLES3::initialize() { void RasterizerGLES3::begin_frame(){ - uint64_t tick = OS::get_singleton()->get_ticks_usec(); double time_total = double(tick)/1000000.0; @@ -186,12 +185,8 @@ void RasterizerGLES3::begin_frame(){ storage->frame.prev_tick=tick; + storage->update_dirty_resources(); - storage->update_dirty_multimeshes(); - storage->update_dirty_skeletons(); - storage->update_dirty_shaders(); - storage->update_dirty_materials(); - storage->update_particles(); storage->info.render_object_count=0; storage->info.render_material_switch_count=0; diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index b504ef819f..87a70d2750 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1,5 +1,5 @@ #include "rasterizer_scene_gles3.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" #include "rasterizer_canvas_gles3.h" @@ -133,7 +133,7 @@ void RasterizerSceneGLES3::shadow_atlas_set_size(RID p_atlas,int p_size){ glActiveTexture(GL_TEXTURE0); glGenTextures(1, &shadow_atlas->depth); glBindTexture(GL_TEXTURE_2D, shadow_atlas->depth); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, shadow_atlas->size, shadow_atlas->size, 0, + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, shadow_atlas->size, shadow_atlas->size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -1386,6 +1386,8 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) { int amount = MAX(multi_mesh->size,multi_mesh->visible_instances); + + if (s->index_array_len>0) { glDrawElementsInstanced(gl_primitive[s->primitive],s->index_array_len, (s->array_len>=(1<<16))?GL_UNSIGNED_INT:GL_UNSIGNED_SHORT,0,amount); @@ -1609,6 +1611,7 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e,const Transform& state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_XFORM1, gipi->transform_to_data * p_view_transform); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BOUNDS1, gipi->bounds); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_MULTIPLIER1, gipi->probe?gipi->probe->dynamic_range*gipi->probe->energy:0.0); + state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BIAS1, gipi->probe?gipi->probe->bias:0.0); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BLEND_AMBIENT1, gipi->probe?!gipi->probe->interior:false); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_CELL_SIZE1, gipi->cell_size_cache); if (gi_probe_count>1) { @@ -1621,6 +1624,7 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e,const Transform& state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BOUNDS2, gipi2->bounds); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_CELL_SIZE2, gipi2->cell_size_cache); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_MULTIPLIER2, gipi2->probe?gipi2->probe->dynamic_range*gipi2->probe->energy:0.0); + state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BIAS2, gipi2->probe?gipi2->probe->bias:0.0); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_BLEND_AMBIENT2, gipi2->probe?!gipi2->probe->interior:false); state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE2_ENABLED, true ); } else { @@ -1746,6 +1750,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e RasterizerStorageGLES3::Material* prev_material=NULL; RasterizerStorageGLES3::Geometry* prev_geometry=NULL; + RasterizerStorageGLES3::GeometryOwner* prev_owner=NULL; VS::InstanceType prev_base_type = VS::INSTANCE_MAX; int current_blend_mode=-1; @@ -1765,6 +1770,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e RasterizerStorageGLES3::Material* material= e->material; RID skeleton = e->instance->skeleton; + bool rebind=first; int shading = (e->sort_key>>RenderList::SORT_KEY_SHADING_SHIFT)&RenderList::SORT_KEY_SHADING_MASK; @@ -1934,7 +1940,8 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e } - if (prev_base_type != e->instance->base_type || prev_geometry!=e->geometry) { + if (e->owner != prev_owner || prev_base_type != e->instance->base_type || prev_geometry!=e->geometry) { + _setup_geometry(e); storage->info.render_surface_switch_count++; @@ -1952,6 +1959,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e prev_material=material; prev_base_type=e->instance->base_type; prev_geometry=e->geometry; + prev_owner=e->owner; prev_shading=shading; prev_skeleton=skeleton; first=false; @@ -2654,19 +2662,19 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result,int p_light_cu glBindBuffer(GL_UNIFORM_BUFFER, state.omni_array_ubo); glBufferSubData(GL_UNIFORM_BUFFER, 0, state.omni_light_count*state.ubo_light_size, state.omni_array_tmp); glBindBuffer(GL_UNIFORM_BUFFER, 0); - - glBindBufferBase(GL_UNIFORM_BUFFER,4,state.omni_array_ubo); } + glBindBufferBase(GL_UNIFORM_BUFFER,4,state.omni_array_ubo); + if (state.spot_light_count) { glBindBuffer(GL_UNIFORM_BUFFER, state.spot_array_ubo); glBufferSubData(GL_UNIFORM_BUFFER, 0, state.spot_light_count*state.ubo_light_size, state.spot_array_tmp); glBindBuffer(GL_UNIFORM_BUFFER, 0); - glBindBufferBase(GL_UNIFORM_BUFFER,5,state.spot_array_ubo); } + glBindBufferBase(GL_UNIFORM_BUFFER,5,state.spot_array_ubo); } @@ -2762,9 +2770,10 @@ void RasterizerSceneGLES3::_setup_reflections(RID *p_reflection_probe_cull_resul glBufferSubData(GL_UNIFORM_BUFFER, 0, state.reflection_probe_count*sizeof(ReflectionProbeDataUBO), state.reflection_array_tmp); glBindBuffer(GL_UNIFORM_BUFFER, 0); - glBindBufferBase(GL_UNIFORM_BUFFER,6,state.reflection_array_ubo); } + glBindBufferBase(GL_UNIFORM_BUFFER,6,state.reflection_array_ubo); + } @@ -2877,6 +2886,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase** p_cull_result,int p_ RasterizerStorageGLES3::MultiMesh *multi_mesh = storage->multimesh_owner.getptr(inst->base); ERR_CONTINUE(!multi_mesh); + if (multi_mesh->size==0 || multi_mesh->visible_instances==0) continue; @@ -2892,6 +2902,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase** p_cull_result,int p_ _add_geometry(s,inst,multi_mesh,-1,p_shadow); } + } break; case VS::INSTANCE_IMMEDIATE: { @@ -3773,7 +3784,7 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C state.used_contact_shadows=true; - if (storage->frame.current_rt && true) { //detect with state.used_contact_shadows too + if ( storage->frame.current_rt && true) { //detect with state.used_contact_shadows too //pre z pass @@ -4092,11 +4103,11 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C if (false && env_radiance_tex) { - //_copy_texture_to_front_buffer(shadow_atlas->depth); - storage->canvas->canvas_begin(); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D,env_radiance_tex); - storage->canvas->draw_generic_textured_rect(Rect2(0,0,storage->frame.current_rt->width/2,storage->frame.current_rt->height/2),Rect2(0,0,1,1)); + //_copy_texture_to_front_buffer(shadow_atlas->depth); + storage->canvas->canvas_begin(); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D,env_radiance_tex); + storage->canvas->draw_generic_textured_rect(Rect2(0,0,storage->frame.current_rt->width/2,storage->frame.current_rt->height/2),Rect2(0,0,1,1)); } @@ -4794,7 +4805,7 @@ void RasterizerSceneGLES3::initialize() { //gen cubemap first for(int i=0;i<6;i++) { - glTexImage2D(_cube_side_enum[i], 0, GL_DEPTH_COMPONENT, cube.size, cube.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); + glTexImage2D(_cube_side_enum[i], 0, GL_DEPTH_COMPONENT24, cube.size, cube.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -4828,7 +4839,7 @@ void RasterizerSceneGLES3::initialize() { glBindFramebuffer(GL_FRAMEBUFFER,directional_shadow.fbo); glGenTextures(1,&directional_shadow.depth); glBindTexture(GL_TEXTURE_2D,directional_shadow.depth); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, directional_shadow.size, directional_shadow.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, directional_shadow.size, directional_shadow.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -4918,7 +4929,7 @@ void RasterizerSceneGLES3::initialize() { glGenTextures(1,&cube.depth); glBindTexture(GL_TEXTURE_2D,cube.depth); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, cube.size, cube.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, cube.size, cube.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 06daebbf82..cec41aa251 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -1,7 +1,7 @@ #include "rasterizer_storage_gles3.h" #include "rasterizer_canvas_gles3.h" #include "rasterizer_scene_gles3.h" -#include "globals.h" +#include "global_config.h" /* TEXTURE API */ @@ -93,16 +93,26 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima switch(p_format) { case Image::FORMAT_L8: { +#ifdef GLES_OVER_GL r_gl_internal_format=GL_R8; r_gl_format=GL_RED; r_gl_type=GL_UNSIGNED_BYTE; - +#else + r_gl_internal_format=GL_LUMINANCE; + r_gl_format=GL_LUMINANCE; + r_gl_type=GL_UNSIGNED_BYTE; +#endif } break; case Image::FORMAT_LA8: { - +#ifdef GLES_OVER_GL r_gl_internal_format=GL_RG8; r_gl_format=GL_RG; r_gl_type=GL_UNSIGNED_BYTE; +#else + r_gl_internal_format=GL_LUMINANCE_ALPHA; + r_gl_format=GL_LUMINANCE_ALPHA; + r_gl_type=GL_UNSIGNED_BYTE; +#endif } break; case Image::FORMAT_R8: { @@ -734,6 +744,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image } //set swizle for older format compatibility +#ifdef GLES_OVER_GL switch(texture->format) { case Image::FORMAT_L8: { @@ -759,6 +770,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image } break; } +#endif if (config.use_anisotropic_filter) { if (texture->flags&VS::TEXTURE_FLAG_ANISOTROPIC_FILTER) { @@ -1096,7 +1108,7 @@ RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source,int p_r ERR_FAIL_COND_V(!texture,RID()); ERR_FAIL_COND_V(!(texture->flags&VS::TEXTURE_FLAG_CUBEMAP),RID()); - bool use_float=true; + bool use_float=config.hdr_supported; if (p_resolution<0) { p_resolution=texture->width; @@ -1316,7 +1328,7 @@ void RasterizerStorageGLES3::skybox_set_texture(RID p_skybox, RID p_cube_map, in int mm_level=mipmaps; - bool use_float=true; + bool use_float=config.hdr_supported; GLenum internal_format = use_float?GL_RGBA16F:GL_RGB10_A2; GLenum format = GL_RGBA; @@ -2320,6 +2332,7 @@ void RasterizerStorageGLES3::_update_material(Material* material) { bool is_animated = false; if (material->shader && material->shader->mode==VS::SHADER_SPATIAL) { + if (!material->shader->spatial.uses_alpha && material->shader->spatial.blend_mode==Shader::Spatial::BLEND_MODE_MIX) { can_cast_shadow=true; } @@ -2332,20 +2345,19 @@ void RasterizerStorageGLES3::_update_material(Material* material) { is_animated=true; } - } + if (can_cast_shadow!=material->can_cast_shadow_cache || is_animated!=material->is_animated_cache) { + material->can_cast_shadow_cache=can_cast_shadow; + material->is_animated_cache=is_animated; - if (can_cast_shadow!=material->can_cast_shadow_cache || is_animated!=material->is_animated_cache) { - material->can_cast_shadow_cache=can_cast_shadow; - material->is_animated_cache=is_animated; + for(Map<Geometry*,int>::Element *E=material->geometry_owners.front();E;E=E->next()) { + E->key()->material_changed_notify(); + } - for(Map<Geometry*,int>::Element *E=material->geometry_owners.front();E;E=E->next()) { - E->key()->material_changed_notify(); - } + for(Map<RasterizerScene::InstanceBase*,int>::Element *E=material->instance_owners.front();E;E=E->next()) { + E->key()->base_material_changed(); + } - for(Map<RasterizerScene::InstanceBase*,int>::Element *E=material->instance_owners.front();E;E=E->next()) { - E->key()->base_material_changed(); } - } } @@ -3619,8 +3631,23 @@ void RasterizerStorageGLES3::multimesh_set_mesh(RID p_multimesh,RID p_mesh){ MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND(!multimesh); + if (multimesh->mesh.is_valid()) { + Mesh *mesh = mesh_owner.getornull(multimesh->mesh); + if (mesh) { + mesh->multimeshes.remove(&multimesh->mesh_list); + } + } + multimesh->mesh=p_mesh; + + if (multimesh->mesh.is_valid()) { + Mesh *mesh = mesh_owner.getornull(multimesh->mesh); + if (mesh) { + mesh->multimeshes.add(&multimesh->mesh_list); + } + } + multimesh->dirty_aabb=true; if (!multimesh->update_list.in_list()) { @@ -4778,6 +4805,7 @@ RID RasterizerStorageGLES3::gi_probe_create() { gip->dynamic_range=1.0; gip->energy=1.0; gip->propagation=1.0; + gip->bias=0.4; gip->interior=false; gip->compress=false; gip->version=1; @@ -4883,6 +4911,16 @@ void RasterizerStorageGLES3::gi_probe_set_energy(RID p_probe,float p_range){ } + +void RasterizerStorageGLES3::gi_probe_set_bias(RID p_probe,float p_range){ + + GIProbe *gip = gi_probe_owner.getornull(p_probe); + ERR_FAIL_COND(!gip); + + gip->bias=p_range; + +} + void RasterizerStorageGLES3::gi_probe_set_propagation(RID p_probe,float p_range){ GIProbe *gip = gi_probe_owner.getornull(p_probe); @@ -4936,6 +4974,15 @@ float RasterizerStorageGLES3::gi_probe_get_energy(RID p_probe) const{ return gip->energy; } +float RasterizerStorageGLES3::gi_probe_get_bias(RID p_probe) const{ + + const GIProbe *gip = gi_probe_owner.getornull(p_probe); + ERR_FAIL_COND_V(!gip,0); + + return gip->bias; +} + + float RasterizerStorageGLES3::gi_probe_get_propagation(RID p_probe) const{ const GIProbe *gip = gi_probe_owner.getornull(p_probe); @@ -5535,9 +5582,10 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ GLuint color_type; Image::Format image_format; + bool hdr = rt->flags[RENDER_TARGET_HDR] && config.hdr_supported; + hdr=false; - - if (!rt->flags[RENDER_TARGET_HDR] || rt->flags[RENDER_TARGET_NO_3D]) { + if (!hdr || rt->flags[RENDER_TARGET_NO_3D]) { color_internal_format=GL_RGBA8; color_format=GL_RGBA; @@ -5562,7 +5610,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ glGenTextures(1, &rt->depth); glBindTexture(GL_TEXTURE_2D, rt->depth); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, rt->width, rt->height, 0, + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, rt->width, rt->height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -5586,6 +5634,10 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo); + if (status != GL_FRAMEBUFFER_COMPLETE) { + printf("framebuffer fail, status: %x\n",status); + } + ERR_FAIL_COND( status != GL_FRAMEBUFFER_COMPLETE ); Texture *tex = texture_owner.get(rt->texture); @@ -5633,7 +5685,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ if (msaa==0) glRenderbufferStorage(GL_RENDERBUFFER,color_internal_format,rt->width,rt->height); else - glRenderbufferStorageMultisample(GL_RENDERBUFFER,msaa,GL_RGBA16F,rt->width,rt->height); + glRenderbufferStorageMultisample(GL_RENDERBUFFER,msaa,color_internal_format,rt->width,rt->height); glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_RENDERBUFFER,rt->buffers.diffuse); @@ -5641,7 +5693,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){ glBindRenderbuffer(GL_RENDERBUFFER, rt->buffers.specular); if (msaa==0) - glRenderbufferStorage(GL_RENDERBUFFER,GL_RGBA16F,rt->width,rt->height); + glRenderbufferStorage(GL_RENDERBUFFER,color_internal_format,rt->width,rt->height); else glRenderbufferStorageMultisample(GL_RENDERBUFFER,msaa,color_internal_format,rt->width,rt->height); @@ -6265,6 +6317,18 @@ bool RasterizerStorageGLES3::free(RID p_rid){ mesh->instance_remove_deps(); mesh_clear(p_rid); + while(mesh->multimeshes.first()) { + MultiMesh *multimesh = mesh->multimeshes.first()->self(); + multimesh->mesh=RID(); + multimesh->dirty_aabb=true; + mesh->multimeshes.remove(mesh->multimeshes.first()); + + if (!multimesh->update_list.in_list()) { + multimesh_update_list.add(&multimesh->update_list); + } + + } + mesh_owner.free(p_rid); memdelete(mesh); @@ -6274,9 +6338,17 @@ bool RasterizerStorageGLES3::free(RID p_rid){ MultiMesh *multimesh = multimesh_owner.get(p_rid); multimesh->instance_remove_deps(); + if (multimesh->mesh.is_valid()) { + Mesh *mesh = mesh_owner.getornull(multimesh->mesh); + if (mesh) { + mesh->multimeshes.remove(&multimesh->mesh_list); + } + } + multimesh_allocate(p_rid,0,VS::MULTIMESH_TRANSFORM_2D,VS::MULTIMESH_COLOR_NONE); //frees multimesh update_dirty_multimeshes(); + multimesh_owner.free(p_rid); memdelete(multimesh); } else if (immediate_owner.owns(p_rid)) { @@ -6405,9 +6477,11 @@ void RasterizerStorageGLES3::initialize() { config.latc_supported=config.extensions.has("GL_EXT_texture_compression_latc"); config.bptc_supported=config.extensions.has("GL_ARB_texture_compression_bptc"); #ifdef GLES_OVER_GL + config.hdr_supported=true; config.etc2_supported=false; #else config.etc2_supported=true; + config.hdr_supported=false; #endif config.pvrtc_supported=config.extensions.has("GL_IMG_texture_compression_pvrtc"); config.srgb_decode_supported=config.extensions.has("GL_EXT_texture_sRGB_decode"); @@ -6568,6 +6642,14 @@ void RasterizerStorageGLES3::finalize() { } +void RasterizerStorageGLES3::update_dirty_resources() { + + update_dirty_multimeshes(); + update_dirty_skeletons(); + update_dirty_shaders(); + update_dirty_materials(); + update_particles(); +} RasterizerStorageGLES3::RasterizerStorageGLES3() { diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 07998886a8..ab5e5612c6 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -46,6 +46,8 @@ public: bool etc2_supported; bool pvrtc_supported; + bool hdr_supported; + bool srgb_decode_supported; bool use_rgba_2d_shadows; @@ -567,6 +569,7 @@ public: virtual void material_changed_notify() { mesh->instance_material_change_notify(); + mesh->update_multimeshes(); } Surface() { @@ -591,6 +594,7 @@ public: } }; + class MultiMesh; struct Mesh : public GeometryOwner { @@ -600,6 +604,17 @@ public: VS::BlendShapeMode blend_shape_mode; Rect3 custom_aabb; mutable uint64_t last_pass; + SelfList<MultiMesh>::List multimeshes; + + _FORCE_INLINE_ void update_multimeshes() { + + SelfList<MultiMesh> *mm = multimeshes.first(); + while(mm) { + mm->self()->instance_material_change_notify(); + mm=mm->next(); + } + } + Mesh() { blend_shape_mode=VS::BLEND_SHAPE_MODE_NORMALIZED; blend_shape_count=0; @@ -659,6 +674,7 @@ public: Vector<float> data; Rect3 aabb; SelfList<MultiMesh> update_list; + SelfList<MultiMesh> mesh_list; GLuint buffer; int visible_instances; @@ -668,7 +684,7 @@ public: bool dirty_aabb; bool dirty_data; - MultiMesh() : update_list(this) { + MultiMesh() : update_list(this), mesh_list(this) { dirty_aabb=true; dirty_data=true; xform_floats=0; @@ -921,6 +937,7 @@ public: int dynamic_range; float energy; + float bias; float propagation; bool interior; bool compress; @@ -954,6 +971,9 @@ public: virtual void gi_probe_set_energy(RID p_probe,float p_range); virtual float gi_probe_get_energy(RID p_probe) const; + virtual void gi_probe_set_bias(RID p_probe,float p_range); + virtual float gi_probe_get_bias(RID p_probe) const; + virtual void gi_probe_set_propagation(RID p_probe,float p_range); virtual float gi_probe_get_propagation(RID p_probe) const; @@ -1259,6 +1279,7 @@ public: virtual bool has_os_feature(const String& p_feature) const; + virtual void update_dirty_resources(); RasterizerStorageGLES3(); }; diff --git a/drivers/gles3/shader_gles3.h b/drivers/gles3/shader_gles3.h index ee8db2ac8c..c2d283d492 100644 --- a/drivers/gles3/shader_gles3.h +++ b/drivers/gles3/shader_gles3.h @@ -149,7 +149,7 @@ private: struct VersionKeyHash { - static _FORCE_INLINE_ uint32_t hash( const VersionKey& p_key) { return HashMapHahserDefault::hash(p_key.key); }; + static _FORCE_INLINE_ uint32_t hash( const VersionKey& p_key) { return HashMapHasherDefault::hash(p_key.key); }; }; //this should use a way more cachefriendly version.. diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 200c0c0cac..a0bf6cd58b 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -533,8 +533,8 @@ float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) { float ratio_incr = 1.0/steps; do { - source += incr*2; - bias+=incr*2; + source += incr*2.0; + bias+=incr*2.0; vec3 uv_depth = (source.xyz / source.w) * 0.5 + 0.5; float depth = texture(depth_buffer,uv_depth.xy).r; @@ -931,6 +931,7 @@ uniform highp mat4 gi_probe_xform1; uniform highp vec3 gi_probe_bounds1; uniform highp vec3 gi_probe_cell_size1; uniform highp float gi_probe_multiplier1; +uniform highp float gi_probe_bias1; uniform bool gi_probe_blend_ambient1; uniform mediump sampler3D gi_probe2; //texunit:-7 @@ -938,13 +939,14 @@ uniform highp mat4 gi_probe_xform2; uniform highp vec3 gi_probe_bounds2; uniform highp vec3 gi_probe_cell_size2; uniform highp float gi_probe_multiplier2; +uniform highp float gi_probe_bias2; uniform bool gi_probe2_enabled; uniform bool gi_probe_blend_ambient2; -vec3 voxel_cone_trace(sampler3D probe, vec3 cell_size, vec3 pos, vec3 ambient, bool blend_ambient, vec3 direction, float tan_half_angle, float max_distance) { +vec3 voxel_cone_trace(sampler3D probe, vec3 cell_size, vec3 pos, vec3 ambient, bool blend_ambient, vec3 direction, float tan_half_angle, float max_distance, float p_bias) { - float dist = dot(direction,mix(vec3(-1.0),vec3(1.0),greaterThan(direction,vec3(0.0))))*2.0; + float dist = p_bias;//1.0; //dot(direction,mix(vec3(-1.0),vec3(1.0),greaterThan(direction,vec3(0.0))))*2.0; float alpha=0.0; vec3 color = vec3(0.0); @@ -957,12 +959,14 @@ vec3 voxel_cone_trace(sampler3D probe, vec3 cell_size, vec3 pos, vec3 ambient, b dist += diameter * 0.5; } - //color.rgb = mix(color.rgb,mix(ambient,color.rgb,alpha),blend_ambient); + if (blend_ambient) { + color.rgb = mix(ambient,color.rgb,min(1.0,alpha/0.95)); + } return color; } -void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_size,vec3 pos, vec3 ambient, vec3 environment, bool blend_ambient,float multiplier, mat3 normal_mtx,vec3 ref_vec, float roughness, out vec4 out_spec, out vec4 out_diff) { +void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_size,vec3 pos, vec3 ambient, vec3 environment, bool blend_ambient,float multiplier, mat3 normal_mtx,vec3 ref_vec, float roughness,float p_bias, out vec4 out_spec, out vec4 out_diff) { @@ -1023,7 +1027,7 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s for(int i=0;i<MAX_CONE_DIRS;i++) { vec3 dir = normalize( (probe_xform * vec4(pos + normal_mtx * cone_dirs[i],1.0)).xyz - probe_pos); - light+=cone_weights[i] * voxel_cone_trace(probe,cell_size,probe_pos,ambient,blend_ambient,dir,cone_angle_tan,max_distance); + light+=cone_weights[i] * voxel_cone_trace(probe,cell_size,probe_pos,ambient,blend_ambient,dir,cone_angle_tan,max_distance,p_bias); } @@ -1033,7 +1037,7 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s //irradiance - vec3 irr_light = voxel_cone_trace(probe,cell_size,probe_pos,environment,blend_ambient,ref_vec,max(min_ref_tan,tan(roughness * 0.5 * M_PI)) ,max_distance); + vec3 irr_light = voxel_cone_trace(probe,cell_size,probe_pos,environment,blend_ambient,ref_vec,max(min_ref_tan,tan(roughness * 0.5 * M_PI)) ,max_distance,p_bias); irr_light *= multiplier; //irr_light=vec3(0.0); @@ -1064,11 +1068,11 @@ void gi_probes_compute(vec3 pos, vec3 normal, float roughness, vec3 specular, in out_specular = vec3(0.0); - gi_probe_compute(gi_probe1,gi_probe_xform1,gi_probe_bounds1,gi_probe_cell_size1,pos,ambient,environment,gi_probe_blend_ambient1,gi_probe_multiplier1,normal_mat,ref_vec,roughness,spec_accum,diff_accum); + gi_probe_compute(gi_probe1,gi_probe_xform1,gi_probe_bounds1,gi_probe_cell_size1,pos,ambient,environment,gi_probe_blend_ambient1,gi_probe_multiplier1,normal_mat,ref_vec,roughness,gi_probe_bias1,spec_accum,diff_accum); if (gi_probe2_enabled) { - gi_probe_compute(gi_probe2,gi_probe_xform2,gi_probe_bounds2,gi_probe_cell_size2,pos,ambient,environment,gi_probe_blend_ambient2,gi_probe_multiplier2,normal_mat,ref_vec,roughness,spec_accum,diff_accum); + gi_probe_compute(gi_probe2,gi_probe_xform2,gi_probe_bounds2,gi_probe_cell_size2,pos,ambient,environment,gi_probe_blend_ambient2,gi_probe_multiplier2,normal_mat,ref_vec,roughness,gi_probe_bias2,spec_accum,diff_accum); } if (diff_accum.a>0.0) { diff --git a/drivers/gles3/shaders/ssao.glsl b/drivers/gles3/shaders/ssao.glsl index 75f49ef37a..ba29ec52c7 100644 --- a/drivers/gles3/shaders/ssao.glsl +++ b/drivers/gles3/shaders/ssao.glsl @@ -29,7 +29,7 @@ void main() { uniform sampler2D source_depth; //texunit:0 -uniform usampler2D source_depth_mipmaps; //texunit:1 +uniform highp usampler2D source_depth_mipmaps; //texunit:1 uniform sampler2D source_normal; //texunit:2 uniform ivec2 screen_size; @@ -78,8 +78,8 @@ vec3 reconstructCSFaceNormal(vec3 C) { /** Returns a unit vector and a screen-space radius for the tap on a unit disk (the caller should scale by the actual disk radius) */ vec2 tapLocation(int sampleNumber, float spinAngle, out float ssR){ // Radius relative to ssR - float alpha = float(sampleNumber + 0.5) * (1.0 / NUM_SAMPLES); - float angle = alpha * (NUM_SPIRAL_TURNS * 6.28) + spinAngle; + float alpha = (float(sampleNumber) + 0.5) * (1.0 / float(NUM_SAMPLES)); + float angle = alpha * (float(NUM_SPIRAL_TURNS) * 6.28) + spinAngle; ssR = alpha; return vec2(cos(angle), sin(angle)); @@ -193,7 +193,7 @@ void main() { // Hash function used in the HPG12 AlchemyAO paper - float randomPatternRotationAngle = (3 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 10; + float randomPatternRotationAngle = float((3 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 10); // Reconstruct normals from positions. These will lead to 1-pixel black lines // at depth discontinuities, however the blur will wipe those out so they are not visible @@ -208,12 +208,12 @@ void main() { sum += sampleAO(ssC, C, n_C, ssDiskRadius, radius,i, randomPatternRotationAngle); } - float A = max(0.0, 1.0 - sum * intensity_div_r6 * (5.0 / NUM_SAMPLES)); + float A = max(0.0, 1.0 - sum * intensity_div_r6 * (5.0 / float(NUM_SAMPLES))); #ifdef ENABLE_RADIUS2 //go again for radius2 - randomPatternRotationAngle = (5 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 11; + randomPatternRotationAngle = float((5 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 11); // Reconstruct normals from positions. These will lead to 1-pixel black lines // at depth discontinuities, however the blur will wipe those out so they are not visible @@ -228,15 +228,15 @@ void main() { sum += sampleAO(ssC, C, n_C, ssDiskRadius,radius2, i, randomPatternRotationAngle); } - A= min(A,max(0.0, 1.0 - sum * intensity_div_r62 * (5.0 / NUM_SAMPLES))); + A= min(A,max(0.0, 1.0 - sum * intensity_div_r62 * (5.0 / float(NUM_SAMPLES)))); #endif // Bilateral box-filter over a quad for free, respecting depth edges // (the difference that this makes is subtle) if (abs(dFdx(C.z)) < 0.02) { - A -= dFdx(A) * ((ssC.x & 1) - 0.5); + A -= dFdx(A) * (float(ssC.x & 1) - 0.5); } if (abs(dFdy(C.z)) < 0.02) { - A -= dFdy(A) * ((ssC.y & 1) - 0.5); + A -= dFdy(A) * (float(ssC.y & 1) - 0.5); } visibility = A; diff --git a/drivers/gles3/shaders/ssao_minify.glsl b/drivers/gles3/shaders/ssao_minify.glsl index df9045c28a..6e46a1842c 100644 --- a/drivers/gles3/shaders/ssao_minify.glsl +++ b/drivers/gles3/shaders/ssao_minify.glsl @@ -43,7 +43,7 @@ void main() { fdepth = fdepth * 2.0 - 1.0; fdepth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - fdepth * (camera_z_far - camera_z_near)); fdepth /= camera_z_far; - depth = uint(clamp(fdepth*65535,0.0,65535.0)); + depth = uint(clamp(fdepth*65535.0,0.0,65535.0)); #else depth = texelFetch(source_depth, clamp(ssP * 2 + ivec2(ssP.y & 1, ssP.x & 1), ivec2(0), from_size - ivec2(1)), source_mipmap).r; diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index a9a199bb59..f55b089ded 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -29,7 +29,7 @@ #include "resource_saver_png.h" #include "core/image.h" -#include "globals.h" +#include "global_config.h" #include "os/file_access.h" #include "scene/resources/texture.h" diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index 5f0e647545..f5268f3ebd 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -32,7 +32,7 @@ #include <pulse/error.h> -#include "globals.h" +#include "global_config.h" Error AudioDriverPulseAudio::init() { diff --git a/drivers/rtaudio/audio_driver_rtaudio.cpp b/drivers/rtaudio/audio_driver_rtaudio.cpp index 6ada0aaa68..cc715545bd 100644 --- a/drivers/rtaudio/audio_driver_rtaudio.cpp +++ b/drivers/rtaudio/audio_driver_rtaudio.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "audio_driver_rtaudio.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" #ifdef RTAUDIO_ENABLED diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index edf5f22714..fe49501328 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -61,7 +61,7 @@ #include <poll.h> #include <errno.h> #include <assert.h> -#include "globals.h" +#include "global_config.h" extern bool _print_error_enabled; diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp index fa55c97325..cd61fefd91 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.cpp +++ b/drivers/xaudio2/audio_driver_xaudio2.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "audio_driver_xaudio2.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" const char * AudioDriverXAudio2::get_name() const diff --git a/main/main.cpp b/main/main.cpp index 21a839a25f..9be77c31b6 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "main.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" #include "splash.h" #include "core/register_core_types.h" #include "scene/register_scene_types.h" diff --git a/main/tests/test_io.cpp b/main/tests/test_io.cpp index 42664e73cd..23459c68d1 100644 --- a/main/tests/test_io.cpp +++ b/main/tests/test_io.cpp @@ -39,7 +39,7 @@ #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/dir_access.h" -#include "core/globals.h" +#include "core/global_config.h" #include "io/file_access_memory.h" diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gd_compiler.h index dd211a852c..eb6079e8e0 100644 --- a/modules/gdscript/gd_compiler.h +++ b/modules/gdscript/gd_compiler.h @@ -93,7 +93,7 @@ class GDCompiler { //int get_identifier_pos(const StringName& p_dentifier) const; - HashMap<Variant,int,VariantHasher> constant_map; + HashMap<Variant,int,VariantHasher,VariantComparator> constant_map; Map<StringName,int> name_map; int get_name_map_pos(const StringName& p_identifier) { diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 114a25feeb..f325aec072 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "gd_script.h" #include "gd_compiler.h" -#include "globals.h" +#include "global_config.h" #include "os/file_access.h" void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const { diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp index d7274b5b8e..31bac2748a 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gd_function.cpp @@ -171,7 +171,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a if (p_state) { //use existing (supplied) state (yielded) stack=(Variant*)p_state->stack.ptr(); - call_args=(Variant**)&p_state->stack[sizeof(Variant)*p_state->stack_size]; + call_args=(Variant**)stack + sizeof(Variant)*p_state->stack_size; line=p_state->line; ip=p_state->ip; alloca_size=p_state->stack.size(); diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index c1c1f5d5a9..1bda8f0cd3 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -2587,6 +2587,8 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { constants.push_back(c->value); constant=true; } + } else { + constant=false; } } diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 167ede4853..d4646aa36d 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "gd_script.h" -#include "globals.h" +#include "global_config.h" #include "global_constants.h" #include "gd_compiler.h" #include "os/file_access.h" diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 5be2a2beae..477a1f1ac8 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -1169,7 +1169,7 @@ Vector<uint8_t> GDTokenizerBuffer::parse_code_string(const String& p_code) { Map<StringName,int> identifier_map; - HashMap<Variant,int,VariantHasher> constant_map; + HashMap<Variant,int,VariantHasher,VariantComparator> constant_map; Map<uint32_t,int> line_map; Vector<uint32_t> token_array; diff --git a/modules/gridmap/config.py b/modules/gridmap/config.py index 1ab13c4aeb..5698a37295 100644 --- a/modules/gridmap/config.py +++ b/modules/gridmap/config.py @@ -1,8 +1,7 @@ def can_build(platform): - # FIXME: Disabled temporary for gles3 implementation - return False + return True def configure(env): diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 1e6bd11154..d4fb174bfe 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -31,7 +31,7 @@ #include "scene/resources/surface_tool.h" #include "message_queue.h" #include "scene/3d/light.h" -#include "scene/3d/baked_light_instance.h" + #include "io/marshalls.h" #include "scene/scene_string_names.h" #include "os/os.h" @@ -41,25 +41,21 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) { String name=p_name; - if (name=="theme/theme") { + if (name=="theme") { set_theme(p_value); - } else if (name=="cell/size") { + } else if (name=="cell_size") { set_cell_size(p_value); - } else if (name=="cell/octant_size") { + } else if (name=="cell_octant_size") { set_octant_size(p_value); - } else if (name=="cell/center_x") { + } else if (name=="cell_center_x") { set_center_x(p_value); - } else if (name=="cell/center_y") { + } else if (name=="cell_center_y") { set_center_y(p_value); - } else if (name=="cell/center_z") { + } else if (name=="cell_center_z") { set_center_z(p_value); - } else if (name=="cell/scale") { + } else if (name=="cell_scale") { set_cell_scale(p_value); - } else if (name=="lighting/bake") { - set_use_baked_light(p_value); - } else if (name=="theme/bake") { - set_bake(p_value); /* } else if (name=="cells") { PoolVector<int> cells = p_value; int amount=cells.size(); @@ -81,9 +77,6 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) { Dictionary d = p_value; - Dictionary baked; - if (d.has("baked")) - baked=d["baked"]; if (d.has("cells")) { PoolVector<int> cells = d["cells"]; @@ -101,33 +94,7 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) { } } - baked_lock=baked.size()!=0; _recreate_octant_data(); - baked_lock=false; - if (!baked.empty()) { - List<Variant> kl; - baked.get_key_list(&kl); - for (List<Variant>::Element *E=kl.front();E;E=E->next()) { - - Plane ikv = E->get(); - Ref<Mesh> b=baked[ikv]; - ERR_CONTINUE(!b.is_valid()); - OctantKey ok; - ok.x=ikv.normal.x; - ok.y=ikv.normal.y; - ok.z=ikv.normal.z; - ok.area=ikv.d; - - ERR_CONTINUE(!octant_map.has(ok)); - - Octant &g = *octant_map[ok]; - - g.baked=b; - g.bake_instance=VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(g.bake_instance,g.baked->get_rid()); - VS::get_singleton()->instance_geometry_set_baked_light(g.bake_instance,baked_light_instance?baked_light_instance->get_baked_light_instance():RID()); - } - } } else if (name.begins_with("areas/")) { @@ -161,24 +128,20 @@ bool GridMap::_get(const StringName& p_name,Variant &r_ret) const { String name=p_name; - if (name=="theme/theme") { + if (name=="theme") { r_ret= get_theme(); - } else if (name=="cell/size") { + } else if (name=="cell_size") { r_ret= get_cell_size(); - } else if (name=="cell/octant_size") { + } else if (name=="cell_octant_size") { r_ret= get_octant_size(); - } else if (name=="cell/center_x") { + } else if (name=="cell_center_x") { r_ret= get_center_x(); - } else if (name=="cell/center_y") { + } else if (name=="cell_center_y") { r_ret= get_center_y(); - } else if (name=="cell/center_z") { + } else if (name=="cell_center_z") { r_ret= get_center_z(); - } else if (name=="cell/scale") { + } else if (name=="cell_scale") { r_ret= cell_scale; - } else if (name=="lighting/bake") { - r_ret=is_using_baked_light(); - } else if (name=="theme/bake") { - r_ret= bake; } else if (name=="data") { Dictionary d; @@ -197,23 +160,8 @@ bool GridMap::_get(const StringName& p_name,Variant &r_ret) const { d["cells"]=cells; - Dictionary baked; - for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) { - - Octant &g=*E->get(); - - if (g.baked.is_valid()) { - - baked[Plane(E->key().x,E->key().y,E->key().z,E->key().area)]=g.baked; - } - } - - if (baked.size()) { - d["baked"]=baked; - } - r_ret= d; } else if (name.begins_with("areas/")) { int which = name.get_slicec('/',1).to_int(); @@ -237,15 +185,14 @@ bool GridMap::_get(const StringName& p_name,Variant &r_ret) const { void GridMap::_get_property_list( List<PropertyInfo> *p_list) const { - p_list->push_back( PropertyInfo( Variant::OBJECT, "theme/theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary")); - p_list->push_back( PropertyInfo( Variant::BOOL, "theme/bake")); - p_list->push_back( PropertyInfo( Variant::BOOL, "lighting/bake")); - p_list->push_back( PropertyInfo( Variant::REAL, "cell/size",PROPERTY_HINT_RANGE,"0.01,16384,0.01") ); - p_list->push_back( PropertyInfo( Variant::INT, "cell/octant_size",PROPERTY_HINT_RANGE,"1,1024,1") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "cell/center_x") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "cell/center_y") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "cell/center_z") ); - p_list->push_back( PropertyInfo( Variant::REAL, "cell/scale") ); + p_list->push_back( PropertyInfo( Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary")); + p_list->push_back( PropertyInfo( Variant::NIL, "Cell", PROPERTY_HINT_NONE,"cell_",PROPERTY_USAGE_GROUP)); + p_list->push_back( PropertyInfo( Variant::REAL, "cell_size",PROPERTY_HINT_RANGE,"0.01,16384,0.01") ); + p_list->push_back( PropertyInfo( Variant::INT, "cell_octant_size",PROPERTY_HINT_RANGE,"1,1024,1") ); + p_list->push_back( PropertyInfo( Variant::BOOL, "cell_center_x") ); + p_list->push_back( PropertyInfo( Variant::BOOL, "cell_center_y") ); + p_list->push_back( PropertyInfo( Variant::BOOL, "cell_center_z") ); + p_list->push_back( PropertyInfo( Variant::REAL, "cell_scale") ); p_list->push_back( PropertyInfo( Variant::DICTIONARY, "data", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_STORAGE) ); @@ -380,17 +327,6 @@ void GridMap::set_cell_item(int p_x,int p_y,int p_z, int p_item,int p_rot){ g.items.erase(prev_item); } - - if (g.items.empty() || !baked_lock) { - //unbake just in case - if (g.baked.is_valid()) { - VS::get_singleton()->free(g.bake_instance); - g.bake_instance=RID(); - g.baked=Ref<Mesh>(); - } - - - } if (g.items.empty()) { PhysicsServer::get_singleton()->free(g.static_body); @@ -454,24 +390,12 @@ void GridMap::set_cell_item(int p_x,int p_y,int p_z, int p_item,int p_rot){ ii.navmesh=theme->get_item_navmesh(p_item); } ii.multimesh = Ref<MultiMesh>( memnew( MultiMesh ) ); + ii.multimesh->set_color_format(MultiMesh::COLOR_NONE); + ii.multimesh->set_transform_format(MultiMesh::TRANSFORM_3D); ii.multimesh->set_mesh(ii.mesh); ii.multimesh_instance = VS::get_singleton()->instance_create(); VS::get_singleton()->instance_set_base(ii.multimesh_instance,ii.multimesh->get_rid()); - VS::get_singleton()->instance_geometry_set_baked_light(ii.multimesh_instance,baked_light_instance?baked_light_instance->get_baked_light_instance():RID()); - - if (!baked_lock) { - //unbake just in case - if (g.bake_instance.is_valid()) - VS::get_singleton()->free(g.bake_instance); - g.baked=Ref<Mesh>(); - if (is_inside_world()) { - VS::get_singleton()->instance_set_scenario(ii.multimesh_instance,get_world()->get_scenario()); - if (ok.area) { - VS::get_singleton()->instance_set_room( ii.multimesh_instance,area_map[ok.area]->instance); - } - } - } g.items[p_item]=ii; } @@ -585,27 +509,14 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) { VS::get_singleton()->instance_set_room(g.collision_debug_instance,area_map[p_key.area]->instance); } } - if (g.baked.is_valid()) { + for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) { - Transform xf = get_global_transform(); - xf.translate(_octant_get_offset(p_key)); + VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance,get_world()->get_scenario()); + VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform()); + //print_line("INSTANCEPOS: "+get_global_transform()); - VS::get_singleton()->instance_set_transform(g.bake_instance,xf); - VS::get_singleton()->instance_set_scenario(g.bake_instance,get_world()->get_scenario()); if (area_map.has(p_key.area)) { - VS::get_singleton()->instance_set_room(g.bake_instance,area_map[p_key.area]->instance); - - } - } else { - for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) { - - VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance,get_world()->get_scenario()); - VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform()); - //print_line("INSTANCEPOS: "+get_global_transform()); - - if (area_map.has(p_key.area)) { - VS::get_singleton()->instance_set_room(E->get().multimesh_instance,area_map[p_key.area]->instance); - } + VS::get_singleton()->instance_set_room(E->get().multimesh_instance,area_map[p_key.area]->instance); } } } @@ -621,17 +532,10 @@ void GridMap::_octant_transform(const OctantKey &p_key) { VS::get_singleton()->instance_set_transform(g.collision_debug_instance,get_global_transform()); } - if (g.baked.is_valid()) { - - Transform xf = get_global_transform(); - xf.origin+=_octant_get_offset(p_key); - VS::get_singleton()->instance_set_transform(g.bake_instance,xf); - } else { - for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) { + for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) { - VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform()); - //print_line("UPDATEPOS: "+get_global_transform()); - } + VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform()); + //print_line("UPDATEPOS: "+get_global_transform()); } } @@ -711,7 +615,7 @@ void GridMap::_octant_update(const OctantKey &p_key) { ii.multimesh->set_instance_transform(idx,xform); //ii.multimesh->set_instance_transform(idx,Transform() ); - ii.multimesh->set_instance_color(idx,Color(1,1,1,1)); + //ii.multimesh->set_instance_color(idx,Color(1,1,1,1)); //print_line("MMINST: "+xform); @@ -748,7 +652,7 @@ void GridMap::_octant_update(const OctantKey &p_key) { idx++; } - ii.multimesh->set_aabb(aabb); + //ii.multimesh->set_aabb(aabb); } @@ -760,7 +664,7 @@ void GridMap::_octant_update(const OctantKey &p_key) { arr.resize(VS::ARRAY_MAX); arr[VS::ARRAY_VERTEX]=col_debug; - VS::get_singleton()->mesh_add_surface(g.collision_debug,VS::PRIMITIVE_LINES,arr); + VS::get_singleton()->mesh_add_surface_from_arrays(g.collision_debug,VS::PRIMITIVE_LINES,arr); SceneTree *st=SceneTree::get_singleton(); if (st) { VS::get_singleton()->mesh_surface_set_material( g.collision_debug, 0,st->get_debug_collision_material()->get_rid() ); @@ -780,13 +684,6 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) { PhysicsServer::get_singleton()->body_set_space(g.static_body,RID()); - if (g.baked.is_valid()) { - - VS::get_singleton()->instance_set_room(g.bake_instance,RID()); - VS::get_singleton()->instance_set_scenario(g.bake_instance,RID()); - - } - if (g.collision_debug_instance.is_valid()) { VS::get_singleton()->instance_set_room(g.collision_debug_instance,RID()); @@ -802,194 +699,6 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) { } -void GridMap::_octant_clear_baked(const OctantKey &p_key) { - - - ERR_FAIL_COND(!octant_map.has(p_key)); - Octant&g = *octant_map[p_key]; - - if (!g.baked.is_valid()) - return; - - VS::get_singleton()->free(g.bake_instance); - g.bake_instance=RID(); - g.baked=Ref<Mesh>(); - - if (is_inside_tree()) - _octant_enter_world(p_key); - g.dirty=true; - _queue_dirty_map(); -} - -void GridMap::_octant_bake(const OctantKey &p_key, const Ref<TriangleMesh>& p_tmesh,const Vector<BakeLight> &p_lights,List<Vector3> *p_prebake) { - - - ERR_FAIL_COND(!octant_map.has(p_key)); - Octant&g = *octant_map[p_key]; - - Ref<TriangleMesh> tm=p_tmesh; - if (!p_prebake && is_inside_world()) - _octant_exit_world(p_key); - - Map< Ref<Material>, Ref<SurfaceTool> > surfaces; - Vector3 ofs(cell_size*0.5*int(center_x),cell_size*0.5*int(center_y),cell_size*0.5*int(center_z)); - Vector3 octant_ofs=_octant_get_offset(p_key); - - for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) { - - Octant::ItemInstances &ii=E->get(); - - if (ii.mesh.is_null()) - continue; - - for(Set<IndexKey>::Element *F=ii.cells.front();F;F=F->next()) { - - IndexKey ik=F->get(); - Map<IndexKey,Cell>::Element *C=cell_map.find(ik); - ERR_CONTINUE(!C); - Vector3 cellpos = Vector3(ik.x,ik.y,ik.z ); - - Transform xform; - xform.basis.set_orthogonal_index(C->get().rot); - xform.set_origin( cellpos*cell_size+ofs); - if (!p_prebake) - xform.origin-=octant_ofs; - - - for(int i=0;i<ii.mesh->get_surface_count();i++) { - - if (p_prebake) { - - if (ii.mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES) - continue; - Array a = ii.mesh->surface_get_arrays(i); - PoolVector<Vector3> av=a[VS::ARRAY_VERTEX]; - int avs = av.size(); - PoolVector<Vector3>::Read vr = av.read(); - - PoolVector<int> ai=a[VS::ARRAY_INDEX]; - int ais=ai.size(); - if (ais) { - - PoolVector<int>::Read ir=ai.read(); - for(int j=0;j<ais;j++) { - - p_prebake->push_back(xform.xform(vr[ir[j]])); - //print_line("V SET: "+xform.xform(vr[ir[j]])); - } - - } else { - - for(int j=0;j<avs;j++) { - - p_prebake->push_back(xform.xform(vr[j])); - } - } - - } else { - - Ref<Material> m = ii.mesh->surface_get_material(i); - - Map< Ref<Material>, Ref<SurfaceTool> >::Element *S=surfaces.find(m); - - if (!S) { - - S=surfaces.insert(m,Ref<SurfaceTool>( memnew( SurfaceTool ))); - } - - Ref<SurfaceTool> st = S->get(); - List<SurfaceTool::Vertex>::Element *V=st->get_vertex_array().back(); - st->append_from(ii.mesh,i,xform); - st->set_material(m); - - - if (tm.is_valid()) { - - if (V) - V=V->next(); - else - V=st->get_vertex_array().front(); - int lc = p_lights.size(); - const BakeLight* bl = p_lights.ptr(); - float ofs = cell_size*0.02; - - - for(;V;V=V->next()) { - - SurfaceTool::Vertex &v=V->get(); - - Vector3 vertex = v.vertex + octant_ofs; - //print_line("V GET: "+vertex); - Vector3 normal = tm->get_area_normal( Rect3( Vector3(-ofs,-ofs,-ofs)+vertex,Vector3(ofs,ofs,ofs)*2.0)); - if (normal==Vector3()) { - print_line("couldn't find for vertex: "+vertex); - } - ERR_CONTINUE( normal== Vector3()); - - float max_l=1.0; - float max_dist=1.0; - - if (lc) { - - for(int j=0;j<lc;j++) { - const BakeLight &l=bl[j]; - switch(l.type) { - case VS::LIGHT_DIRECTIONAL: { - - Vector3 ray_from=vertex + normal *ofs; - Vector3 ray_to=l.dir*5000; - Vector3 n; - Vector3 p; - if (tm->intersect_segment(ray_from,ray_to,p,n)) { - - float dist = 1.0-l.param[VS::LIGHT_PARAM_SHADOW_DARKENING]; - if (dist<=max_dist) { - max_dist=dist; - max_l=1.0-dist; - } - } - } break; - } - - } - } - - v.color=Color(max_l,max_l,max_l,1.0); - - } - - st->add_to_format(VS::ARRAY_FORMAT_COLOR); - if (m.is_valid()) { - Ref<FixedSpatialMaterial> fm = m; - if (fm.is_valid()) - fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY,true); - } - } - } - } - } - } - - if (p_prebake) - return; - - g.baked = Ref<Mesh>( memnew( Mesh )); - - for(Map< Ref<Material>, Ref<SurfaceTool> >::Element *E=surfaces.front();E;E=E->next()) { - - Ref<SurfaceTool> st = E->get(); - st->commit(g.baked); - } - - g.bake_instance = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(g.bake_instance,g.baked->get_rid()); - - if (is_inside_world()) - _octant_enter_world(p_key); - - g.dirty=true; - _queue_dirty_map(); -} void GridMap::_notification(int p_what) { @@ -1011,10 +720,6 @@ void GridMap::_notification(int p_what) { last_transform=get_global_transform(); - if (use_baked_light) { - - _find_baked_light(); - } } break; case NOTIFICATION_TRANSFORM_CHANGED: { @@ -1036,15 +741,6 @@ void GridMap::_notification(int p_what) { _octant_exit_world(E->key()); } - if (use_baked_light) { - - if (baked_light_instance) { - baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed); - baked_light_instance=NULL; - } - _baked_light_changed(); - - } //_queue_dirty_map(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS); //_update_dirty_map_callback(); @@ -1122,9 +818,6 @@ void GridMap::_clear_internal(bool p_keep_areas) { VS::get_singleton()->free(F->get().multimesh_instance); } - //unbake just in case - if (E->get()->bake_instance.is_valid()) - VS::get_singleton()->free(E->get()->bake_instance); if (E->get()->collision_debug.is_valid()) VS::get_singleton()->free(E->get()->collision_debug); @@ -1188,9 +881,6 @@ void GridMap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_theme","theme:MeshLibrary"),&GridMap::set_theme); ClassDB::bind_method(D_METHOD("get_theme:MeshLibrary"),&GridMap::get_theme); - ClassDB::bind_method(D_METHOD("set_bake","enable"),&GridMap::set_bake); - ClassDB::bind_method(D_METHOD("is_baking_enabled"),&GridMap::is_baking_enabled); - ClassDB::bind_method(D_METHOD("set_cell_size","size"),&GridMap::set_cell_size); ClassDB::bind_method(D_METHOD("get_cell_size"),&GridMap::get_cell_size); @@ -1226,20 +916,11 @@ void GridMap::_bind_methods() { ClassDB::bind_method(D_METHOD("area_get_portal_disable_color","area"),&GridMap::area_get_portal_disable_color); ClassDB::bind_method(D_METHOD("erase_area","area"),&GridMap::erase_area); ClassDB::bind_method(D_METHOD("get_unused_area_id","area"),&GridMap::get_unused_area_id); - ClassDB::bind_method(D_METHOD("bake_geometry"),&GridMap::bake_geometry); - - ClassDB::bind_method(D_METHOD("_baked_light_changed"),&GridMap::_baked_light_changed); - ClassDB::bind_method(D_METHOD("set_use_baked_light","use"),&GridMap::set_use_baked_light); - ClassDB::bind_method(D_METHOD("is_using_baked_light","use"),&GridMap::is_using_baked_light); - - ClassDB::bind_method(D_METHOD("_get_baked_light_meshes"),&GridMap::_get_baked_light_meshes); - - - - ClassDB::set_method_flags("GridMap","bake_geometry",METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR); ClassDB::bind_method(D_METHOD("clear"),&GridMap::clear); + ClassDB::bind_method(D_METHOD("get_meshes"),&GridMap::get_meshes); + BIND_CONSTANT( INVALID_CELL_ITEM ); } @@ -1622,23 +1303,6 @@ int GridMap::get_unused_area_id() const { return area_map.back()->key()+1; } - -void GridMap::set_bake(bool p_bake) { - - bake=p_bake; - if (bake==false) { - for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) { - - _octant_clear_baked(E->key()); - } - } -} - -bool GridMap::is_baking_enabled() const { - - return bake; -} - void GridMap::set_cell_scale(float p_scale) { cell_scale=p_scale; @@ -1652,100 +1316,8 @@ float GridMap::get_cell_scale() const{ -void GridMap::bake_geometry() { - - //used to compute vertex occlusion - Ref<TriangleMesh> tmesh; - Vector<BakeLight> lights; - - if (true) { - - List<Vector3> vertices; - - for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) { - _octant_bake(E->key(),tmesh,lights,&vertices); - - } - - PoolVector<Vector3> vv; - vv.fill_with(vertices); - //print_line("TOTAL VERTICES: "+itos(vv.size())); - tmesh = Ref<TriangleMesh>( memnew( TriangleMesh )); - tmesh->create(vv); - - - for(int i=0;i<get_child_count();i++) { - - if (get_child(i)->cast_to<Light>()) { - Light *l = get_child(i)->cast_to<Light>(); - BakeLight bl; - for(int i=0;i<Light::PARAM_MAX;i++) { - bl.param[i]=l->get_parameter(Light::Parameter(i)); - } - Transform t=l->get_global_transform(); - bl.pos=t.origin; - bl.dir=t.basis.get_axis(2); - bl.type=l->get_light_type(); - lights.push_back(bl); - - } - } - } - - int idx=0; - for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) { - if (E->get()->baked.is_valid()) - _octant_clear_baked(E->key()); - - _octant_bake(E->key(),tmesh,lights); - print_line("baking "+itos(idx)+"/"+itos(octant_map.size())); - idx++; - } - -} - -void GridMap::_baked_light_changed() { - - /* - if (!baked_light_instance) - VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),RID()); - else - VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),baked_light_instance->get_baked_light_instance()); - */ - for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) { - - for(Map<int,Octant::ItemInstances>::Element *F=E->get()->items.front();F;F=F->next()) { - - VS::get_singleton()->instance_geometry_set_baked_light(F->get().multimesh_instance,baked_light_instance?baked_light_instance->get_baked_light_instance():RID()); - } - - } - -} -void GridMap::_find_baked_light() { - - Node *n=get_parent(); - while(n) { - - BakedLightInstance *bl=n->cast_to<BakedLightInstance>(); - if (bl) { - - baked_light_instance=bl; - baked_light_instance->connect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed); - _baked_light_changed(); - - return; - } - - n=n->get_parent(); - } - - _baked_light_changed(); -} - - -Array GridMap::_get_baked_light_meshes() { +Array GridMap::get_meshes() { if (theme.is_null()) return Array(); @@ -1783,31 +1355,6 @@ Array GridMap::_get_baked_light_meshes() { return meshes; } -void GridMap::set_use_baked_light(bool p_use) { - - if (use_baked_light==p_use) - return; - - use_baked_light=p_use; - - if (is_inside_world()) { - if (!p_use) { - if (baked_light_instance) { - baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed); - baked_light_instance=NULL; - } - _baked_light_changed(); - } else { - _find_baked_light(); - } - } - -} - -bool GridMap::is_using_baked_light() const{ - - return use_baked_light; -} @@ -1825,12 +1372,8 @@ GridMap::GridMap() { clip_floor=0; clip_axis=Vector3::AXIS_Z; clip_above=true; - baked_lock=false; - bake=false; cell_scale=1.0; - baked_light_instance=NULL; - use_baked_light=false; navigation = NULL; set_notify_transform(true); diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 04d140cdc6..5d4133383b 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -103,8 +103,6 @@ class GridMap : public Spatial { Ref<NavigationMesh> navmesh; }; - Ref<Mesh> baked; - RID bake_instance; RID collision_debug; RID collision_debug_instance; @@ -140,14 +138,12 @@ class GridMap : public Spatial { float cell_size; int octant_size; bool center_x,center_y,center_z; - bool bake; float cell_scale; Navigation *navigation; bool clip; bool clip_above; int clip_floor; - bool baked_lock; Vector3::Axis clip_axis; @@ -205,9 +201,7 @@ class GridMap : public Spatial { void _octant_exit_world(const OctantKey &p_key); void _octant_update(const OctantKey &p_key); void _octant_transform(const OctantKey &p_key); - void _octant_clear_baked(const OctantKey &p_key); void _octant_clear_navmesh(const GridMap::OctantKey&); - void _octant_bake(const OctantKey &p_key,const Ref<TriangleMesh>& p_tmesh=RES(),const Vector<BakeLight> &p_lights=Vector<BakeLight>(),List<Vector3> *r_prebake=NULL); bool awaiting_update; void _queue_dirty_map(); @@ -221,14 +215,6 @@ class GridMap : public Spatial { void _clear_internal(bool p_keep_areas=false); - BakedLightInstance *baked_light_instance; - bool use_baked_light; - void _find_baked_light(); - void _baked_light_changed(); - - - Array _get_baked_light_meshes(); - protected: bool _set(const StringName& p_name, const Variant& p_value); @@ -285,13 +271,11 @@ public: void set_cell_scale(float p_scale); float get_cell_scale() const; - void set_bake(bool p_bake); - bool is_baking_enabled() const; - void bake_geometry(); - void set_use_baked_light(bool p_use); - bool is_using_baked_light() const; + Array get_meshes(); + + void clear(); GridMap(); diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index d4c7cb7ca9..2630360058 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -249,7 +249,7 @@ void GridMapEditor::_update_cursor_transform() { if (cursor_instance.is_valid()) { VisualServer::get_singleton()->instance_set_transform(cursor_instance,cursor_transform); - VisualServer::get_singleton()->instance_geometry_set_flag(cursor_instance,VS::INSTANCE_FLAG_VISIBLE,cursor_visible); + VisualServer::get_singleton()->instance_set_visible(cursor_instance,cursor_visible); } } @@ -852,11 +852,11 @@ void GridMapEditor::edit(GridMap *p_gridmap) { if (!node) { set_process(false); for(int i=0;i<3;i++) { - VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_VISIBLE,false); + VisualServer::get_singleton()->instance_set_visible(grid_instance[i],false); } - VisualServer::get_singleton()->instance_geometry_set_flag(cursor_instance, VS::INSTANCE_FLAG_VISIBLE,false); + VisualServer::get_singleton()->instance_set_visible(cursor_instance,false); _clear_areas(); @@ -884,13 +884,11 @@ void GridMapEditor::edit(GridMap *p_gridmap) { { //update grids - indicator_mat = VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_UNSHADED, true ); - VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_ONTOP, false ); - - VisualServer::get_singleton()->fixed_material_set_param(indicator_mat,VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.8,0.5,0.1)); - VisualServer::get_singleton()->fixed_material_set_flag( indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true ); - VisualServer::get_singleton()->fixed_material_set_flag( indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY, true ); + indicator_mat.instance(); + indicator_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true); + indicator_mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true); + indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true); + indicator_mat->set_albedo(Color(0.8,0.5,0.1)); Vector<Vector3> grid_points[3]; @@ -937,8 +935,8 @@ void GridMapEditor::edit(GridMap *p_gridmap) { d.resize(VS::ARRAY_MAX); d[VS::ARRAY_VERTEX]=grid_points[i]; d[VS::ARRAY_COLOR]=grid_colors[i]; - VisualServer::get_singleton()->mesh_add_surface(grid[i],VisualServer::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(grid[i],0,indicator_mat); + VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i],VisualServer::PRIMITIVE_LINES,d); + VisualServer::get_singleton()->mesh_surface_set_material(grid[i],0,indicator_mat->get_rid()); } @@ -976,7 +974,7 @@ void GridMapEditor::update_grid() { for(int i=0;i<3;i++) { - VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_VISIBLE,i==edit_axis); + VisualServer::get_singleton()->instance_set_visible(grid_instance[i],i==edit_axis); } @@ -1103,7 +1101,7 @@ void GridMapEditor::_update_areas_display() { if (!node) { return; } - +#if 0 _clear_areas(); List<int> areas; node->get_area_list(&areas); @@ -1118,6 +1116,8 @@ void GridMapEditor::_update_areas_display() { color=Color(1,1,1,0.2); else color.set_hsv(Math::fmod(area*0.37,1),Math::fmod(area*0.75,1),1.0,0.2); + + RID material = VisualServer::get_singleton()->fixed_material_create(); VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_DIFFUSE,color ); VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_EMISSION,0.5 ); @@ -1149,7 +1149,7 @@ void GridMapEditor::_update_areas_display() { this->areas.push_back(ad); } - +#endif } void GridMapEditor::_edit_mode_changed(int p_what) { @@ -1295,7 +1295,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { hb->add_child(mode_list); mode_list->connect("pressed", this, "_set_display_mode", varray(DISPLAY_LIST)); - EDITOR_DEF("editors/grid_map/preview_size",64) + EDITOR_DEF("editors/grid_map/preview_size",64); display_mode = DISPLAY_THUMBNAIL; selected_area=-1; @@ -1387,52 +1387,36 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { Array d; d.resize(VS::ARRAY_MAX); - inner_mat = VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->fixed_material_set_param(inner_mat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.7,0.7,1.0,0.3)); - VisualServer::get_singleton()->material_set_flag(inner_mat,VS::MATERIAL_FLAG_ONTOP,true); - VisualServer::get_singleton()->material_set_flag(inner_mat,VS::MATERIAL_FLAG_UNSHADED,true); - VisualServer::get_singleton()->fixed_material_set_flag( inner_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true ); + inner_mat.instance(); + inner_mat->set_albedo(Color(0.7,0.7,1.0,0.3)); + inner_mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true); + inner_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true); + inner_mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true); d[VS::ARRAY_VERTEX]=triangles; - VisualServer::get_singleton()->mesh_add_surface(selection_mesh,VS::PRIMITIVE_TRIANGLES,d); - VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,0,inner_mat); + VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh,VS::PRIMITIVE_TRIANGLES,d); + VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,0,inner_mat->get_rid()); - outer_mat = VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->fixed_material_set_param(outer_mat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.7,0.7,1.0,0.8)); - VisualServer::get_singleton()->material_set_line_width(outer_mat,3.0); - VisualServer::get_singleton()->material_set_flag(outer_mat,VS::MATERIAL_FLAG_ONTOP,true); - VisualServer::get_singleton()->material_set_flag(outer_mat,VS::MATERIAL_FLAG_UNSHADED,true); - VisualServer::get_singleton()->fixed_material_set_flag( outer_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true ); + outer_mat.instance(); + outer_mat->set_albedo(Color(0.7,0.7,1.0,0.3)); + outer_mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true); + outer_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true); + outer_mat->set_line_width(3.0); + outer_mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true); d[VS::ARRAY_VERTEX]=lines; - VisualServer::get_singleton()->mesh_add_surface(selection_mesh,VS::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,1,outer_mat); - - - inner_mat_dup = VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->fixed_material_set_param(inner_mat_dup,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(1.0,0.7,0.7,0.3)); - VisualServer::get_singleton()->material_set_flag(inner_mat_dup,VS::MATERIAL_FLAG_ONTOP,true); - VisualServer::get_singleton()->material_set_flag(inner_mat_dup,VS::MATERIAL_FLAG_UNSHADED,true); - VisualServer::get_singleton()->fixed_material_set_flag( inner_mat_dup, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true ); - + VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh,VS::PRIMITIVE_LINES,d); + VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,1,outer_mat->get_rid()); d[VS::ARRAY_VERTEX]=triangles; - VisualServer::get_singleton()->mesh_add_surface(duplicate_mesh,VS::PRIMITIVE_TRIANGLES,d); - VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,0,inner_mat_dup); - - outer_mat_dup = VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->fixed_material_set_param(outer_mat_dup,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(1.0,0.7,0.7,0.8)); - VisualServer::get_singleton()->material_set_line_width(outer_mat_dup,3.0); - VisualServer::get_singleton()->material_set_flag(outer_mat_dup,VS::MATERIAL_FLAG_ONTOP,true); - VisualServer::get_singleton()->material_set_flag(outer_mat_dup,VS::MATERIAL_FLAG_UNSHADED,true); - VisualServer::get_singleton()->fixed_material_set_flag( outer_mat_dup, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true ); - + VisualServer::get_singleton()->mesh_add_surface_from_arrays(duplicate_mesh,VS::PRIMITIVE_TRIANGLES,d); + VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,0,inner_mat->get_rid()); d[VS::ARRAY_VERTEX]=lines; - VisualServer::get_singleton()->mesh_add_surface(duplicate_mesh,VS::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,1,outer_mat_dup); + VisualServer::get_singleton()->mesh_add_surface_from_arrays(duplicate_mesh,VS::PRIMITIVE_LINES,d); + VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,1,outer_mat->get_rid()); } @@ -1452,14 +1436,10 @@ GridMapEditor::~GridMapEditor() { VisualServer::get_singleton()->free(grid[i]); if (grid_instance[i].is_valid()) VisualServer::get_singleton()->free(grid_instance[i]); - if (cursor_instance) + if (cursor_instance.is_valid()) VisualServer::get_singleton()->free(cursor_instance); } - VisualServer::get_singleton()->free(inner_mat); - VisualServer::get_singleton()->free(outer_mat); - VisualServer::get_singleton()->free(inner_mat_dup); - VisualServer::get_singleton()->free(outer_mat_dup); VisualServer::get_singleton()->free(selection_mesh); if (selection_instance.is_valid()) diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index 2c0ff99dc6..66ec5dc4bc 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -112,12 +112,9 @@ class GridMapEditor : public VBoxContainer { RID duplicate_mesh; RID duplicate_instance; - RID indicator_mat; - - RID inner_mat; - RID outer_mat; - RID inner_mat_dup; - RID outer_mat_dup; + Ref<FixedSpatialMaterial> indicator_mat; + Ref<FixedSpatialMaterial> inner_mat; + Ref<FixedSpatialMaterial> outer_mat; bool updating; diff --git a/modules/openssl/stream_peer_openssl.h b/modules/openssl/stream_peer_openssl.h index 3d6875698c..84ae03fe07 100644 --- a/modules/openssl/stream_peer_openssl.h +++ b/modules/openssl/stream_peer_openssl.h @@ -31,7 +31,7 @@ #include <stdio.h> // If you don't know what this is for stop reading now. #include "io/stream_peer_ssl.h" -#include "globals.h" +#include "global_config.h" #include "os/file_access.h" #include "curl_hostcheck.h" diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index 9d2dfc7f56..2a7b2707bf 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "video_stream_theora.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" #include "yuv2rgb.h" diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index ec09335b7d..6941ed5486 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -2,7 +2,7 @@ #include "visual_script_nodes.h" #include "scene/main/node.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp index d2781c6dcc..93e395f0f2 100644 --- a/modules/visual_script/visual_script_flow_control.cpp +++ b/modules/visual_script/visual_script_flow_control.cpp @@ -1,6 +1,6 @@ #include "visual_script_flow_control.h" #include "os/keyboard.h" -#include "globals.h" +#include "global_config.h" ////////////////////////////////////////// diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index 5c8f52ebb1..fd91385f9c 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -4,7 +4,7 @@ #include "scene/main/node.h" #include "visual_script_nodes.h" #include "io/resource_loader.h" -#include "globals.h" +#include "global_config.h" ////////////////////////////////////////// ////////////////CALL////////////////////// diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 2b5a180bbe..d1ee5be378 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -1,6 +1,6 @@ #include "visual_script_nodes.h" #include "global_constants.h" -#include "globals.h" +#include "global_config.h" #include "scene/main/scene_main_loop.h" #include "os/os.h" #include "scene/main/node.h" diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index bdd97f1df7..d4995ad798 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -35,7 +35,7 @@ #include "../theora/yuv2rgb.h" #include "os/file_access.h" -#include "globals.h" +#include "global_config.h" #include <string.h> diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index e0e89e6344..415223c1da 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "audio_driver_jandroid.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" #include "thread_jandroid.h" diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 8e1fda74ed..1d1ee25622 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -29,11 +29,11 @@ #include "version.h" #include "export.h" #include "tools/editor/editor_settings.h" -#include "tools/editor/editor_import_export.h" +#include "tools/editor/editor_export.h" #include "tools/editor/editor_node.h" #include "io/zip_io.h" #include "io/marshalls.h" -#include "globals.h" +#include "global_config.h" #include "os/file_access.h" #include "os/os.h" #include "platform/android/logo.h" @@ -1892,9 +1892,11 @@ EditorExportPlatformAndroid::~EditorExportPlatformAndroid() { memdelete(device_thread); } +#endif void register_android_exporter() { +#if 0 String exe_ext=OS::get_singleton()->get_name()=="Windows"?"exe":""; EDITOR_DEF("export/android/adb",""); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"android/adb",PROPERTY_HINT_GLOBAL_FILE,exe_ext)); @@ -1913,6 +1915,6 @@ void register_android_exporter() { Ref<EditorExportPlatformAndroid> exporter = Ref<EditorExportPlatformAndroid>( memnew(EditorExportPlatformAndroid) ); EditorImportExport::get_singleton()->add_export_platform(exporter); - -} #endif +} + diff --git a/platform/android/globals/global_defaults.cpp b/platform/android/globals/global_defaults.cpp index bbf9bd5b0b..01daac9260 100644 --- a/platform/android/globals/global_defaults.cpp +++ b/platform/android/globals/global_defaults.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "global_defaults.h" -#include "globals.h" +#include "global_config.h" void register_android_global_defaults() { diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp index 3c7f7f5854..83d5a413c0 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -43,7 +43,7 @@ #include <unistd.h> #include <stdlib.h> #include "os_android.h" -#include "globals.h" +#include "global_config.h" #include "main/main.h" #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "godot", __VA_ARGS__)) #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "godot", __VA_ARGS__)) diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index dfbb437344..41558cf86a 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -36,7 +36,7 @@ #include "file_access_android.h" #include "dir_access_jandroid.h" #include "audio_driver_jandroid.h" -#include "globals.h" +#include "global_config.h" #include "thread_jandroid.h" #include "core/os/keyboard.h" #include "java_class_wrapper.h" diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 1095689a5b..2290571735 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -36,7 +36,7 @@ #include "servers/visual/visual_server_wrap_mt.h" #include "main/main.h" #include "file_access_android.h" -#include "core/globals.h" +#include "core/global_config.h" #ifdef ANDROID_NATIVE_ACTIVITY #include "file_access_android.h" diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp index 3e6dadb094..2643c96576 100644 --- a/platform/bb10/export/export.cpp +++ b/platform/bb10/export/export.cpp @@ -29,11 +29,11 @@ #include "version.h" #include "export.h" #include "tools/editor/editor_settings.h" -#include "tools/editor/editor_import_export.h" +#include "tools/editor/editor_export.h" #include "tools/editor/editor_node.h" #include "io/zip_io.h" #include "io/marshalls.h" -#include "globals.h" +#include "global_config.h" #include "os/file_access.h" #include "os/os.h" #include "platform/bb10/logo.h" @@ -803,9 +803,9 @@ EditorExportPlatformBB10::~EditorExportPlatformBB10() { memdelete(device_thread); } - +#endif void register_bb10_exporter() { - +#if 0 EDITOR_DEF("export/blackberry/host_tools",""); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"export/blackberry/host_tools",PROPERTY_HINT_GLOBAL_DIR)); EDITOR_DEF("export/blackberry/debug_token",""); @@ -824,7 +824,7 @@ void register_bb10_exporter() { Ref<EditorExportPlatformBB10> exporter = Ref<EditorExportPlatformBB10>( memnew(EditorExportPlatformBB10) ); EditorImportExport::get_singleton()->add_export_platform(exporter); - +#endif } -#endif + diff --git a/platform/bb10/os_bb10.cpp b/platform/bb10/os_bb10.cpp index c51f1c6092..728707628b 100644 --- a/platform/bb10/os_bb10.cpp +++ b/platform/bb10/os_bb10.cpp @@ -31,7 +31,7 @@ #include "drivers/gles2/rasterizer_gles2.h" #include "servers/visual/visual_server_raster.h" #include "core/os/dir_access.h" -#include "core/globals.h" +#include "core/global_config.h" #include "main/main.h" #include "bbutil.h" #include "core/os/keyboard.h" diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp index c6afe7a261..bd485214c8 100644 --- a/platform/haiku/audio_driver_media_kit.cpp +++ b/platform/haiku/audio_driver_media_kit.cpp @@ -30,7 +30,7 @@ #ifdef MEDIA_KIT_ENABLED -#include "globals.h" +#include "global_config.h" int32_t* AudioDriverMediaKit::samples_in = NULL; diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 740f1d7edc..1c47801b8e 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -30,7 +30,7 @@ #import "gl_view.h" #include "os_iphone.h" -#include "core/globals.h" +#include "core/global_config.h" #include "main/main.h" #ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index a3af8f4aa8..adc76a622e 100755 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -31,7 +31,7 @@ #import <OpenGLES/EAGLDrawable.h> #include "os_iphone.h" #include "core/os/keyboard.h" -#include "core/globals.h" +#include "core/global_config.h" #include "servers/audio_server.h" #import "gl_view.h" diff --git a/platform/iphone/globals/global_defaults.cpp b/platform/iphone/globals/global_defaults.cpp index 76b5c9aa01..bf716c36f0 100755 --- a/platform/iphone/globals/global_defaults.cpp +++ b/platform/iphone/globals/global_defaults.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "global_defaults.h" -#include "globals.h" +#include "global_config.h" void register_iphone_global_defaults() { diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index e34dbae017..816e456838 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -40,7 +40,7 @@ #include "core/os/dir_access.h" #include "core/os/file_access.h" #include "core/io/file_access_pack.h" -#include "core/globals.h" +#include "core/global_config.h" #include "sem_iphone.h" diff --git a/platform/iphone/rasterizer_iphone.cpp b/platform/iphone/rasterizer_iphone.cpp index ee0457cfb1..b8f3dd0d05 100644 --- a/platform/iphone/rasterizer_iphone.cpp +++ b/platform/iphone/rasterizer_iphone.cpp @@ -30,7 +30,7 @@ #include "rasterizer_iphone.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" #include <stdio.h> _FORCE_INLINE_ static void _gl_load_transform(const Transform& tr) { diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index a20c0f7a70..bd7b0c304d 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -2,6 +2,9 @@ Import('env') +env.Tool('textfile') +env.Tool('zip') + javascript_files = [ "os_javascript.cpp", "audio_driver_javascript.cpp", @@ -21,18 +24,26 @@ for x in javascript_files: env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""]) env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"']) -build = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html") -Depends(build, "godot_shell.html") - -def make_html_shell(target, source, env): - html_path = target[0].rstr() - assert html_path[:4] == 'bin/' - assert html_path[-5:] == '.html' - basename = html_path[4:-5] - with open(html_path, 'r+') as html_file: - fixed_html = html_file.read().replace('.html.mem', '.mem').replace(basename, '$GODOT_BASE') - html_file.seek(0) - html_file.truncate() - html_file.write(fixed_html) - -env.AddPostAction(build, Action(make_html_shell, "Creating HTML shell file")) +html_file = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html")[0] +Depends(html_file, "godot_shell.html") +basename = "godot" + env["PROGSUFFIX"] # output file name without file extension + +# Emscripten hardcodes file names, so replace common base name with +# placeholder while leaving extension; also change `.html.mem` to just `.mem` +fixup_html = env.Substfile(html_file, SUBST_DICT=[(basename, '$$GODOT_BASE'), ('.html.mem', '.mem')], SUBSTFILESUFFIX='.fixup.html') + +zip_dir = env.Dir('#bin/.javascript_zip') +zip_files = [] +js_file = env.SideEffect(html_file.File(basename+'.js'), html_file) +zip_files.append(env.InstallAs( + [zip_dir.File('godot.html'), zip_dir.File('godot.js'), zip_dir.File('godotfs.js')], + [fixup_html, js_file, '#misc/dist/html_fs/godotfs.js'])) + +if env['wasm'] == 'yes': + wasm_file = env.SideEffect(html_file.File(basename+'.wasm'), html_file) + zip_files.append(env.InstallAs(zip_dir.File('godot.wasm'), wasm_file)) +else: + asmjs_files = env.SideEffect([html_file.File(basename+'.asm.js'), html_file.File(basename+'.html.mem')], html_file) + zip_files.append(env.InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files)) + +Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX']+env['ZIPSUFFIX'], ZIPROOT=zip_dir) diff --git a/platform/javascript/audio_server_javascript.cpp b/platform/javascript/audio_server_javascript.cpp index d5940fb102..bb238ede0c 100644 --- a/platform/javascript/audio_server_javascript.cpp +++ b/platform/javascript/audio_server_javascript.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "audio_server_javascript.h" - +#if 0 #include "emscripten.h" AudioMixer *AudioServerJavascript::get_mixer() { @@ -847,3 +847,4 @@ AudioServerJavascript::AudioServerJavascript() { stream_volume_scale=1.0; } +#endif diff --git a/platform/javascript/audio_server_javascript.h b/platform/javascript/audio_server_javascript.h index f8c8774e4c..2f48e7e79e 100644 --- a/platform/javascript/audio_server_javascript.h +++ b/platform/javascript/audio_server_javascript.h @@ -28,7 +28,7 @@ /*************************************************************************/ #ifndef AUDIO_SERVER_JAVASCRIPT_H #define AUDIO_SERVER_JAVASCRIPT_H - +#if 0 #include "servers/audio_server.h" class AudioServerJavascript : public AudioServer { @@ -223,3 +223,4 @@ public: }; #endif // AUDIO_SERVER_JAVASCRIPT_H +#endif diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index a701823b2e..799b550899 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -12,8 +12,6 @@ def get_name(): def can_build(): - - import os return os.environ.has_key("EMSCRIPTEN_ROOT") @@ -35,31 +33,41 @@ def get_flags(): ] +def create(env): + # remove Windows' .exe suffix + return env.Clone(PROGSUFFIX='') + + +def escape_sources_backslashes(target, source, env, for_signature): + return [path.replace('\\','\\\\') for path in env.GetBuildPath(source)] + +def escape_target_backslashes(target, source, env, for_signature): + return env.GetBuildPath(target[0]).replace('\\','\\\\') + + def configure(env): env['ENV'] = os.environ - env.use_windows_spawn_fix('javascript') env.Append(CPPPATH=['#platform/javascript']) - em_path = os.environ["EMSCRIPTEN_ROOT"] - - env['ENV']['PATH'] = em_path + ":" + env['ENV']['PATH'] - env['CC'] = em_path + '/emcc' - env['CXX'] = em_path + '/emcc' - #env['AR'] = em_path+"/emar" - env['AR'] = em_path + "/emcc" - env['ARFLAGS'] = "-o" + env.PrependENVPath('PATH', os.environ['EMSCRIPTEN_ROOT']) + env['CC'] = 'emcc' + env['CXX'] = 'em++' + env['LINK'] = 'emcc' + env['RANLIB'] = 'emranlib' + # Emscripten's ar has issues with duplicate file names, so use cc + env['AR'] = 'emcc' + env['ARFLAGS'] = '-o' + if (os.name == 'nt'): + # use TempFileMunge on Windows since some commands get too long for + # cmd.exe even with spawn_fix + # need to escape backslashes for this + env['ESCAPED_SOURCES'] = escape_sources_backslashes + env['ESCAPED_TARGET'] = escape_target_backslashes + env['ARCOM'] = '${TEMPFILE("%s")}' % env['ARCOM'].replace('$SOURCES', '$ESCAPED_SOURCES').replace('$TARGET', '$ESCAPED_TARGET') -# env['RANLIB'] = em_path+"/emranlib" - env['RANLIB'] = em_path + "/emcc" env['OBJSUFFIX'] = '.bc' env['LIBSUFFIX'] = '.bc' - env['CCCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" - env['CXXCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" - -# env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2']) - -# env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ") if (env["target"] == "release"): env.Append(CCFLAGS=['-O2']) @@ -78,7 +86,6 @@ def configure(env): env.Append(CPPFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST', '-fno-rtti']) env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DNO_FCNTL', '-DMPC_FIXED_POINT', '-DTYPED_METHOD_BIND', '-DNO_THREADS']) env.Append(CPPFLAGS=['-DGLES3_ENABLED']) - env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS']) if env['wasm'] == 'yes': env.Append(LINKFLAGS=['-s', 'BINARYEN=1']) @@ -88,7 +95,7 @@ def configure(env): # what is set during compilation, check TOTAL_MEMORY in Emscripten's # src/settings.js for the default. env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1']) - env["PROGSUFFIX"] += ".webassembly" + env.extra_suffix = '.webassembly' + env.extra_suffix else: env.Append(CPPFLAGS=['-s', 'ASM_JS=1']) env.Append(LINKFLAGS=['-s', 'ASM_JS=1']) @@ -101,7 +108,4 @@ def configure(env): env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1']) # env.Append(LINKFLAGS=['-g4']) - # print "CCCOM is:", env.subst('$CCCOM') - # print "P: ", env['p'], " Platofrm: ", env['platform'] - import methods diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index e487383ef4..2657eaddb5 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -29,11 +29,11 @@ #include "version.h" #include "export.h" #include "tools/editor/editor_settings.h" -#include "tools/editor/editor_import_export.h" +#include "tools/editor/editor_export.h" #include "tools/editor/editor_node.h" #include "io/zip_io.h" #include "io/marshalls.h" -#include "globals.h" +#include "global_config.h" #include "os/file_access.h" #include "os/os.h" #include "platform/javascript/logo.h" @@ -417,14 +417,14 @@ EditorExportPlatformJavaScript::~EditorExportPlatformJavaScript() { } - +#endif void register_javascript_exporter() { - Ref<EditorExportPlatformJavaScript> exporter = Ref<EditorExportPlatformJavaScript>( memnew(EditorExportPlatformJavaScript) ); - EditorImportExport::get_singleton()->add_export_platform(exporter); + //Ref<EditorExportPlatformJavaScript> exporter = Ref<EditorExportPlatformJavaScript>( memnew(EditorExportPlatformJavaScript) ); + //EditorImportExport::get_singleton()->add_export_platform(exporter); } -#endif + diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index 94320d53c1..076f93f0df 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -151,16 +151,15 @@ int main(int argc, char *argv[]) { /* Initialize the window */ - printf("let it go!\n"); + printf("let it go dude!\n"); glutInit(&argc, argv); os = new OS_JavaScript(_gfx_init,NULL,NULL); #if 0 char *args[]={"-test","gui","-v",NULL}; Error err = Main::setup("apk",3,args); #else - //char *args[]={"-v",NULL};// - //Error err = Main::setup("",1,args); - Error err = Main::setup("",0,NULL); + char *args[]={"-main_pack","data.pck",NULL}; //pass location of main pack manually, because it wont get an executable name + Error err = Main::setup("",2,args); #endif ResourceLoader::set_abort_on_missing_resources(false); //ease up compatibility diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index b8c3dea3b4..201008b1db 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -34,7 +34,7 @@ #include "drivers/unix/dir_access_unix.h" #include "servers/visual/visual_server_raster.h" #include "main/main.h" -#include "core/globals.h" +#include "core/global_config.h" #include "dom_keys.h" #include <stdlib.h> @@ -282,6 +282,8 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int javascript_eval = memnew(JavaScript); GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("JavaScript", javascript_eval)); #endif + + visual_server->init(); } void OS_JavaScript::set_main_loop( MainLoop * p_main_loop ) { diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 3a97827c16..69973dc95d 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -29,12 +29,12 @@ #include "version.h" #include "export.h" #include "tools/editor/editor_settings.h" -#include "tools/editor/editor_import_export.h" +#include "tools/editor/editor_export.h" #include "tools/editor/editor_node.h" #include "io/zip_io.h" #include "io/marshalls.h" #include "io/resource_saver.h" -#include "globals.h" +#include "global_config.h" #include "os/file_access.h" #include "os/os.h" #include "platform/osx/logo.h" @@ -536,14 +536,14 @@ EditorExportPlatformOSX::~EditorExportPlatformOSX() { } - +#endif void register_osx_exporter() { - +#if 0 Ref<EditorExportPlatformOSX> exporter = Ref<EditorExportPlatformOSX>( memnew(EditorExportPlatformOSX) ); EditorImportExport::get_singleton()->add_export_platform(exporter); - +#endif } -#endif + diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index d74200c744..7108d94b5b 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1766,7 +1766,7 @@ OS_OSX* OS_OSX::singleton=NULL; OS_OSX::OS_OSX() { - mouse_mode=OS::MOUSE_MODE_VISIBLE + mouse_mode=OS::MOUSE_MODE_VISIBLE; main_loop=NULL; singleton=this; autoreleasePool = [[NSAutoreleasePool alloc] init]; diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 167a5831cf..4966489188 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -79,7 +79,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "io/sha256.h" #include "io/base64.h" #include "bind/core_bind.h" -#include "globals.h" +#include "global_config.h" #include "io/marshalls.h" #include <zlib.h> @@ -2384,10 +2384,11 @@ EditorExportPlatformUWP::EditorExportPlatformUWP() { EditorExportPlatformUWP::~EditorExportPlatformUWP() {} - +#endif void register_uwp_exporter() { - +#if 0 Ref<EditorExportPlatformUWP> exporter = Ref<EditorExportPlatformUWP>(memnew(EditorExportPlatformUWP)); EditorImportExport::get_singleton()->add_export_platform(exporter); -} #endif +} + diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 90c21e11a1..61b8a1c240 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -40,7 +40,7 @@ #include "servers/audio_server.h" //#include "servers/visual/visual_server_wrap_mt.h" #include "os/memory_pool_dynamic_prealloc.h" -#include "globals.h" +#include "global_config.h" #include "io/marshalls.h" #include "platform/windows/packet_peer_udp_winsock.h" #include "platform/windows/stream_peer_winsock.h" diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp index 88d534887b..1c827a93b0 100644 --- a/platform/windows/export/export.cpp +++ b/platform/windows/export/export.cpp @@ -28,10 +28,11 @@ /*************************************************************************/ #include "export.h" #include "platform/windows/logo.h" -#include "tools/editor/editor_import_export.h" -#if 0 +#include "tools/editor/editor_export.h" + void register_windows_exporter() { +#if 0 Image img(_windows_logo); Ref<ImageTexture> logo = memnew( ImageTexture ); logo->create_from_image(img); @@ -48,6 +49,6 @@ void register_windows_exporter() { EditorImportExport::get_singleton()->add_export_platform(exporter); } - -} #endif +} + diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 1e51c18b63..1afbfd5230 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -44,7 +44,7 @@ #include "packet_peer_udp_winsock.h" #include "stream_peer_winsock.h" #include "lang_table.h" -#include "globals.h" +#include "global_config.h" #include "io/marshalls.h" #include "joypad.h" diff --git a/platform/x11/export/export.cpp b/platform/x11/export/export.cpp index 5a4751b387..5c7f98c1f3 100644 --- a/platform/x11/export/export.cpp +++ b/platform/x11/export/export.cpp @@ -28,11 +28,27 @@ /*************************************************************************/ #include "export.h" #include "platform/x11/logo.h" -#include "tools/editor/editor_import_export.h" +#include "tools/editor/editor_export.h" #include "scene/resources/texture.h" -#if 0 + + + void register_x11_exporter() { + Ref<EditorExportPlatformPC> platform; + platform.instance(); + + Image img(_x11_logo); + Ref<ImageTexture> logo; + logo.instance(); + logo->create_from_image(img); + platform->set_logo(logo); + platform->set_name("Linux/X11"); + platform->set_extension(""); + + EditorExport::get_singleton()->add_export_platform(platform); + + #if 0 Image img(_x11_logo); Ref<ImageTexture> logo = memnew( ImageTexture ); logo->create_from_image(img); @@ -49,5 +65,6 @@ void register_x11_exporter() { EditorImportExport::get_singleton()->add_export_platform(exporter); } + #endif } -#endif + diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index e792d0465e..27df280927 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -464,6 +464,9 @@ void OS_X11::finalize() { memdelete(main_loop); main_loop=NULL; + for (int i = 0; i < get_audio_driver_count(); i++) { + AudioDriverManager::get_driver(i)->finish(); + } /* if (debugger_connection_console) { @@ -476,7 +479,6 @@ void OS_X11::finalize() { #endif memdelete(input); - visual_server->finish(); memdelete(visual_server); //memdelete(rasterizer); @@ -512,6 +514,7 @@ void OS_X11::finalize() { args.clear(); + } diff --git a/prop_renames.txt b/prop_renames.txt deleted file mode 100644 index e2156f2368..0000000000 --- a/prop_renames.txt +++ /dev/null @@ -1,524 +0,0 @@ -[Object] -script/script = script - -[Node] -pause/pause_mode = pause_mode - -[Control] - -anchor/left = anchor_left -anchor/right = anchor_right -anchor/bottom = anchor_bottom -anchor/top = anchor_top - -focus_neighbour/left=focus_neighbour_left -focus_neighbour/right=focus_neighbour_right -focus_neighbour/bottom=focus_neighbour_bottom -focus_neighbour/top=focus_neighbour_top -focus/ignore_mouse = focus_ignore_mouse -focus/stop_mouse = focus_stop_mouse - -size_flags/horizontal = size_flags_horizontal -size_flags/vertical = size_flags_vertical -size_flags/stretch_ratio = size_flags_stretch_ratio -theme/theme = theme - -[CanvasItem] - -visibility/visible = visible -visibility/behind_parent = show_behind_parent -visibility/on_top = show_on_top -visibility/light_mask = light_mask -material/material = material -material/use_parent = use_parent_material - - -[Resource] - -resource/path = resource_path -resource/name = resource_name - - -[Area2D] - -collision/layers = collision_layers -collision/mask = collision_mask - -[Camera2D] - -limit/left = limit_left -limit/right = limit_right -limit/bottom = limit_bottom -limit/top = limit_top -limit/smoothed = limit_smoothed - -draw_margin/h_enabled = draw_margin_h_enabled -draw_margin/v_enabled = draw_margin_v_enabled - -smoothing/enable = smoothing_enabled -smoothing/speed = smoothing_speed - -drag_margin/left = drag_margin_left -drag_margin/top = drag_margin_top -drag_margin/right = drag_margin_right -drag_margin/bottom = drag_margin_bottom - -[CollisionObject2D] - -input/pickable = input_pickable - -[Joint2D] - -bias/bias = bias -collision/exclude_nodes = disable_collision - -[Light2D] - -range/height = range_height -range/z_min = range_z_min -range/z_max = range_z_max -range/layer_max = range_layer_max -range/item_cull_mask = range_item_cull_max - -shadow/enabled = shadow_enabled -shadow/color = shadow_color -shadow/buffer_size = shadow_buffer_size -shadow/gradient_length = shadow_gradient_length -shadow/filter = shadow_filter -shadow/item_cull_mask = shadow_item_cull_mask - -[Node2D] - -transform/pos = position -transform/rot = rotation -transform/scale = scale -z/z = z -z/relative = z_as_relative - -[ParallaxBackground] - -scroll/offset = scroll_offset -scroll/base_offset = scroll_base_offset -scroll/base_scale = scroll_base_scale -scroll/limit_begin = scroll_limit_begin -scroll/limit_end = scroll_limit_end -scroll/ignore_camera_zoom = scroll_ignore_camera_zoom - -[ParallaxLayer] - -motion/scale = motion_scale -motion/offset = motion_offset -motion/mirroring = motion_mirroring - -[PhysicsBody2D] - -collision/layers = collision_layer -collision/mask = collision_mask - -[Polygon2D] - -texture/texture = texture -texture/offset = texture_offset -texture/rotation = texture_rotation -texture/scale = texture_scale - -invert/enable = invert_enable -invert/border = invert_border - -[SamplePlayer2D] - -config/polyphony = polyphony -config/samples = samples -config/pitch_random = random_pitch - -[SoundPlayer2D] - -params/volume_db = volume_db -params/pitch_scale = pitch_scale -params/attenuation/min_distance = attenuation_min_distance -params/attenuation/max_distance = attenuation_max_distance -params/attenuation/distance_exp = attenuation_distance_exp - -[TileMap] - -cell/size = cell_size -cell/quadrant_size = cell_quadrant_size -cell/half_offset = cell_half_offset -cell/tile_origin = cell_tile_origin -cell/y_sort = cell_y_sort - -collision/use_kinematic = collision_use_kinematic -collision/friction = collision_friction -collision/bounce = collision_bounce -collision/layers = collision_layers -collision/mask = collision_mask - -occluder/light_mask = occluder_light_mask - -[VisibilityEnabler2D] - -enabler/pause_animations = pause_animations -enabler/freeze_bodies = freeze_bodies -enabler/pause_particles = pause_particles -enabler/pause_animated_sprites = pause_animated_sprites -enabler/process_parent = process_parent -enabler/fixed_process_parent = fixed_process_parent - - -[YSort] - -sort/enabled = sort_enabled - - -[Area] - -collision/layers = collision_layers -collision/mask = collision_mask - - -[CollisionObject] - -input/ray_pickable = input_ray_pickable -input/capture_on_drag = input_capture_on_drag - -[Light] - -light/color = light_color -light/energy = light_energy -light/negative = light_negative -light/specular = light_specular -light/cull_mask = light_cull_mask - -shadow/enabled = shadow_enabled -shadow/color = shadow_color -shadow/bias = shadow_bias -shadow/max_distance = shadow_max_distance -editor/editor_only = editor_only - -[DirectionalLight] - -directional_shadow/mode = directional_shadow_mode -directional_shadow/split_1 = directional_shadow_split_1 -directional_shadow/split_2 = directional_shadow_split_2 -directional_shadow/split_3 = directional_shadow_split_3 -directional_shadow/blend_splits = directional_shadow_blend_splits -directional_shadow/normal_bias = directional_shadow_normal_bias -directional_shadow/bias_split_scale = directional_shadow_bias_split_scale - -[OmniLight] - -omni/range = omni_range -omni/attenuation = omni_attenuation -omni/shadow_mode = omni_shadow_mode -omni/shadow_detail = omni_shadow_detail - -[SpotLight] - -spot/range = spot_range -spot/attenuation = spot_attenuation -spot/angle = spot_angle -spot/spot_attenuation = spot_angle_attenuation - -[MeshInstance] - -mesh/mesh = mesh -mesh/skeleton = skeleton - - -[PhysicsBody] - -collision/layers = collision_layer -collision/mask = collision_mask - -[Quad] - -quad/axis = axis -quad/size = size -quad/offset = offset -quad/centered = centered - -[Spatial] - -transform/local = transform -transform/transiation = translation -transform/rotation = rotation -transform/scale = scale -visibility/visible = visible - -[SpatialPlayer] - -params/volume_db = volume_db -params/pitch_scale = pitch_scale -params/attenuation/min_distance = attenuation_min_distance -params/attenuation/max_distance = attenuation_max_distance -params/attenuation/distance_exp = attenuation_distance_exp -params/emission_cone/degrees = emission_cone_degrees -params/emission_cone/attenuation_db = emission_cone_attenuation_db - -[SpatialSamplePlayer] - -config/polyphony = polyphony -config/samples = samples - -[Sprite3D] - -flags/transparent = transparent -flags/shaded = shaded -flags/alpha_cut = alpha_cut - -[VehicleWheel] - -type/traction = use_as_traction -type/steering = use_as_steering - -wheel/radius = wheel_radius -wheel/rest_length = wheel_rest_length -wheel/friction_slip = wheel_friction_sleep - -suspension/travel = suspension_travel -suspension/stiffness = suspension_stiffness -suspension/max_force = suspension_max_force -damping/compression = damping_compression -damping/relaxation = damping_relaxation - -[VehicleBody] - -motion/engine_force = engine_force -motion/breake = breake -motion/steering = steering -body/mass = mass -body/friction = friction - -[VisibilityEnabler] - -enabler/pause_animations = pause_animations -enabler/freeze_bodies = freeze_bodies - -[GeometryInstance] - -geometry/material_override = material_override -geometry/cast_shadow = cast_shadow -geometry/extra_cull_margin = extra_cull_margin -geometry/billboard = use_as_billboard -geometry/billboard_y = use_as_y_billboard -geometry/depth_scale = use_depth_scale -geometry/visible_in_all_rooms = visible_in_all_rooms -geometry/use_baked_light = use_in_baked_light - - - -[AnimationPlayer] - -playback/process_mode = playback_process_mode -playback/default_blend_time = playback_default_blend_time -root/root = root_node - -[AnimationTreePlayer] - -playback/process_mode = playback_process_mode - -[EventPlayer] - -stream/stream = stream -stream/play = play -stream/loop = loop -stream/volume_db = volume_db -stream/pitch_scale = pitch_scale -stream/tempo_scale = tempo_scale -stream/autoplay = autoplay -stream/paused = paused - -[StreamPlayer] - -stream/stream = stream -stream/play = play -stream/loop = loop -stream/volume_db = volume_db -stream/autoplay = autoplay -stream/paused = paused -stream/loop_restart_time = loop_restart_time -stream/buffering_ms = buffering_ms - -[SpatialStreamPlayer] - -stream/stream = stream -stream/play = play -stream/loop = loop -stream/volume_db = volume_db -stream/autoplay = autoplay -stream/paused = paused -stream/loop_restart_time = loop_restart_time -stream/buffering_ms = buffering_ms - -[WindowDialog] - -window/title = window_title - -[AcceptDialog] - -dialog/text = dialog_text -dialog/hide_on_ok = dialog_hide_on_ok - -[LineEdit] - -placeholder/text = placeholder_text -placeholder/alpha = placeholder_alpha -caret/caret_blink = caret_blink -caret/caret_blink_speed = caret_blink_speed - -[Patch9Frame] - -patch_margin/left = patch_margin_left -patch_margin/right = patch_margin_right -patch_margin/top = patch_margin_top -patch_margin/bottom = patch_margin_bottom - - -[Popup] - -popup/exclusive = popup_exclusive - -[ProgressBar] - -percent/visible = percent_visible - -[Range] - -range/min = min_value -range/max = max_value -range/step = step -range/page = page -range/value = value -range/exp_edit = exp_edit -range/rounded = rounded - - -[RigidBody2D] - -velocity/linear = linear_velocity -velocity/angular = angular_velocity -damp_override_linear = linear_damp -damp_override_angular = angular_damp - - -[RigidBody] - -velocity/linear = linear_velocity -velocity/angular = angular_velocity -damp_override_linear = linear_damp -damp_override_angular = angular_damp - -[Tween] - -playback/process_mode = playback_process_mode - -[RichTextLabel] - -bbcode/enabled = bbcode_enabled -bbcode/bbcode = bbcode_text - -[ScrollContainer] - -scroll/horizontal = scroll_horizontal -scroll/vertical = scroll_vertical - -[SplitContainer] - -split/offset = split_offset -split/collapsed = collapsed -split/dragger_visibility = dragger_visibility - -[TextEdit] - -caret/block_caret = caret_block_mode -caret/caret_blink = caret_blink -caret/caret_blink_speed = caret_blink_speed - -[TextureButton] - -textures/normal = texture_normal -textures/pressed = texture_pressed -textures/hover = texture_hover -textures/disabled = texture_disabled -textures/focused = texture_focused -textures/click_mask = texture_click_mask -params/scale = texture_scale -params/modulate = self_modulate - -[TextureProgress] - -texture/under = texture_under -texture/over = texture_over -texture/progress = texture_progress -mode = fill_mode -radial_fill/initial_angle = radial_initial_angle -radial_fill/fill_degrees = radial_fill_degrees -radial_fill/center_offset = radial_center_offset - -[VideoPlayer] - -stream/audio_track = audio_track -stream/stream = stream -stream/volume_db = volume_db -stream/autoplay = stream_autoplay -stream/paused = stream_paused - -[DynamicFont] - -font/size = size -extra_spacing/top = extra_spacing_top -extra_spacing/bottom = extra_spacing_bottom -extra_spacing/char = extra_spacing_char -extra_spacing/space = extra_spacing_space -font/use_mipmaps = use_mipmaps -font/use_filter = use_filter -font/font=font_data - -[StyleBox] - -content_margin/left = content_margin_left -content_margin/right = content_margin_right -content_margin/bottom = content_margin_bottom -content_margin/top = content_margin_top - - -[StyleBoxTexture] - -margin/left = margin_left -margin/top = margin_top -margin/bottom = margin_bottom -margin/right = margin_right - -expand_margin/left = expand_margin_left -expand_margin/top = expand_margin_top -expand_margin/bottom = expand_margin_bottom -expand_margin/right = expand_margin_right - -modulate/color = modulate_color - - -[AnimatedSprite] - -modulate = self_modulate - -[Sprite] - -modulate = self_modulate - -[Patch9Frame] - -modulate = self_modulate - -[TextureRect] - -modulate = self_modulate - - - - - - - - - - diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 3574a39940..4f7acf7f97 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -747,12 +747,12 @@ float CanvasItem::draw_char(const Ref<Font>& p_font,const Point2& p_pos, const S void CanvasItem::_notify_transform(CanvasItem *p_node) { - if (p_node->xform_change.in_list() && p_node->global_invalid) + if (/*p_node->xform_change.in_list() &&*/ p_node->global_invalid) return; //nothing to do p_node->global_invalid=true; - if (notify_transform && !p_node->xform_change.in_list()) { + if (p_node->notify_transform && !p_node->xform_change.in_list()) { if (!p_node->block_transform_notify) { if (p_node->is_inside_tree()) get_tree()->xform_change_list.add(&p_node->xform_change); diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 7b935e0d59..f9e1cc0bd7 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -348,6 +348,8 @@ CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) { rid=p_rid; area=p_area; pickable=true; + set_notify_transform(true); + if (p_area) { Physics2DServer::get_singleton()->area_attach_object_instance_ID(rid,get_instance_ID()); diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index 09fe7cd2fc..32e60f0d57 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -334,6 +334,7 @@ CollisionObject::CollisionObject(RID p_rid, bool p_area) { area=p_area; capture_input_on_drag=false; ray_pickable=true; + set_notify_transform(true); if (p_area) { PhysicsServer::get_singleton()->area_attach_object_instance_ID(rid,get_instance_ID()); } else { diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 4ce714818f..e3c8ba09fc 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -64,6 +64,19 @@ float GIProbeData::get_energy() const{ } + +void GIProbeData::set_bias(float p_range) { + + VS::get_singleton()->gi_probe_set_bias(probe,p_range); +} + +float GIProbeData::get_bias() const{ + + return VS::get_singleton()->gi_probe_get_bias(probe); + +} + + void GIProbeData::set_propagation(float p_range) { VS::get_singleton()->gi_probe_set_propagation(probe,p_range); @@ -133,6 +146,9 @@ void GIProbeData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_energy","energy"),&GIProbeData::set_energy); ClassDB::bind_method(D_METHOD("get_energy"),&GIProbeData::get_energy); + ClassDB::bind_method(D_METHOD("set_bias","bias"),&GIProbeData::set_bias); + ClassDB::bind_method(D_METHOD("get_bias"),&GIProbeData::get_bias); + ClassDB::bind_method(D_METHOD("set_propagation","propagation"),&GIProbeData::set_propagation); ClassDB::bind_method(D_METHOD("get_propagation"),&GIProbeData::get_propagation); @@ -149,6 +165,7 @@ void GIProbeData::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY,"dynamic_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_dynamic_data","get_dynamic_data"); ADD_PROPERTY(PropertyInfo(Variant::INT,"dynamic_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_dynamic_range","get_dynamic_range"); ADD_PROPERTY(PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_energy","get_energy"); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"bias",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_bias","get_bias"); ADD_PROPERTY(PropertyInfo(Variant::REAL,"propagation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_propagation","get_propagation"); ADD_PROPERTY(PropertyInfo(Variant::BOOL,"interior",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_interior","is_interior"); ADD_PROPERTY(PropertyInfo(Variant::BOOL,"compress",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_compress","is_compressed"); @@ -230,6 +247,18 @@ float GIProbe::get_energy() const { return energy; } +void GIProbe::set_bias(float p_bias) { + + bias=p_bias; + if (probe_data.is_valid()) { + probe_data->set_bias(bias); + } +} +float GIProbe::get_bias() const { + + return bias; +} + void GIProbe::set_propagation(float p_propagation) { propagation=p_propagation; @@ -466,7 +495,8 @@ void GIProbe::_plot_face(int p_idx, int p_level,int p_x,int p_y,int p_z, const V int closest_axis; float closest_dot; - Vector3 normal = Plane(p_vtx[0],p_vtx[1],p_vtx[2]).normal; + Plane plane = Plane(p_vtx[0],p_vtx[1],p_vtx[2]); + Vector3 normal = plane.normal; for(int i=0;i<3;i++) { @@ -479,6 +509,7 @@ void GIProbe::_plot_face(int p_idx, int p_level,int p_x,int p_y,int p_z, const V } } + Vector3 axis; axis[closest_axis]=1.0; Vector3 t1; @@ -517,24 +548,23 @@ void GIProbe::_plot_face(int p_idx, int p_level,int p_x,int p_y,int p_z, const V Vector3 ray_from = from + (t1+t2)*0.5 - axis * p_aabb.size[closest_axis]; Vector3 ray_to = ray_from + axis * p_aabb.size[closest_axis]*2; + if (normal.dot(ray_from-ray_to)<0) { + SWAP(ray_from,ray_to); + } + Vector3 intersection; - if (!Geometry::ray_intersects_triangle(ray_from,ray_to,p_vtx[0],p_vtx[1],p_vtx[2],&intersection)) { - //no intersect? look in edges - - float closest_dist=1e20; - for(int j=0;j<3;j++) { - Vector3 c; - Vector3 inters; - Geometry::get_closest_points_between_segments(p_vtx[j],p_vtx[(j+1)%3],ray_from,ray_to,inters,c); - float d=c.distance_to(intersection); - if (j==0 || d<closest_dist) { - closest_dist=d; - intersection=inters; - } + if (!plane.intersects_segment(ray_from,ray_to,&intersection)) { + if (ABS(plane.distance_to(ray_from)) < ABS(plane.distance_to(ray_to))) { + intersection = plane.project(ray_from); + } else { + + intersection = plane.project(ray_to); } } + intersection=Face3(p_vtx[0],p_vtx[1],p_vtx[2]).get_closest_point_to(intersection); + Vector2 uv = get_uv(intersection,p_vtx,p_uv); @@ -856,6 +886,10 @@ Vector<Color> GIProbe::_get_bake_texture(Image &p_image,const Color& p_color) { return ret; } + if (p_image.is_compressed()) { + print_line("DECOMPRESSING!!!!"); + p_image.decompress(); + } p_image.convert(Image::FORMAT_RGBA8); p_image.resize(bake_texture_size,bake_texture_size,Image::INTERPOLATE_CUBIC); @@ -892,13 +926,14 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_mater if (mat.is_valid()) { - - Ref<ImageTexture> albedo_tex = mat->get_texture(FixedSpatialMaterial::TEXTURE_ALBEDO); + Ref<Texture> albedo_tex = mat->get_texture(FixedSpatialMaterial::TEXTURE_ALBEDO); Image img_albedo; if (albedo_tex.is_valid()) { img_albedo = albedo_tex->get_data(); + } else { + } mc.albedo=_get_bake_texture(img_albedo,mat->get_albedo()); @@ -950,6 +985,7 @@ void GIProbe::_plot_mesh(const Transform& p_xform, Ref<Mesh>& p_mesh, Baker *p_b src_material=p_materials[i]; } else { src_material=p_mesh->surface_get_material(i); + } Baker::MaterialCache material = _get_material_cache(src_material,p_baker); @@ -1056,6 +1092,31 @@ void GIProbe::_find_meshes(Node *p_at_node,Baker *p_baker){ } } + if (p_at_node->cast_to<Spatial>()) { + + Spatial *s = p_at_node->cast_to<Spatial>(); + Array meshes = p_at_node->call("get_meshes"); + for(int i=0;i<meshes.size();i+=2) { + + Transform mxf = meshes[i]; + Ref<Mesh> mesh = meshes[i+1]; + if (!mesh.is_valid()) + continue; + + Rect3 aabb = mesh->get_aabb(); + + Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf); + + if (Rect3(-extents,extents*2).intersects(xf.xform(aabb))) { + Baker::PlotMesh pm; + pm.local_xform=xf; + pm.mesh=mesh; + p_baker->mesh_list.push_back(pm); + + } + } + } + for(int i=0;i<p_at_node->get_child_count();i++) { Node *child = p_at_node->get_child(i); @@ -1208,26 +1269,30 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug){ } - Ref<GIProbeData> probe_data; - probe_data.instance(); - probe_data->set_bounds(Rect3(-extents,extents*2.0)); - probe_data->set_cell_size(baker.po2_bounds.size[longest_axis]/baker.axis_cell_size[longest_axis]); - probe_data->set_dynamic_data(data); - probe_data->set_dynamic_range(dynamic_range); - probe_data->set_energy(energy); - probe_data->set_interior(interior); - probe_data->set_compress(compress); - probe_data->set_to_cell_xform(baker.to_cell_space); - - set_probe_data(probe_data); + if (p_create_visual_debug) { + _create_debug_mesh(&baker); + } else { + Ref<GIProbeData> probe_data; + probe_data.instance(); + probe_data->set_bounds(Rect3(-extents,extents*2.0)); + probe_data->set_cell_size(baker.po2_bounds.size[longest_axis]/baker.axis_cell_size[longest_axis]); + probe_data->set_dynamic_data(data); + probe_data->set_dynamic_range(dynamic_range); + probe_data->set_energy(energy); + probe_data->set_bias(bias); + probe_data->set_propagation(propagation); + probe_data->set_interior(interior); + probe_data->set_compress(compress); + probe_data->set_to_cell_xform(baker.to_cell_space); - if (p_create_visual_debug) { - //_create_debug_mesh(&baker); + set_probe_data(probe_data); } + + } @@ -1399,6 +1464,9 @@ void GIProbe::_bind_methods() { ClassDB::bind_method(D_METHOD("set_energy","max"),&GIProbe::set_energy); ClassDB::bind_method(D_METHOD("get_energy"),&GIProbe::get_energy); + ClassDB::bind_method(D_METHOD("set_bias","max"),&GIProbe::set_bias); + ClassDB::bind_method(D_METHOD("get_bias"),&GIProbe::get_bias); + ClassDB::bind_method(D_METHOD("set_propagation","max"),&GIProbe::set_propagation); ClassDB::bind_method(D_METHOD("get_propagation"),&GIProbe::get_propagation); @@ -1417,6 +1485,7 @@ void GIProbe::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::INT,"dynamic_range",PROPERTY_HINT_RANGE,"1,16,1"),"set_dynamic_range","get_dynamic_range"); ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_RANGE,"0,16,0.01"),"set_energy","get_energy"); ADD_PROPERTY( PropertyInfo(Variant::REAL,"propagation",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_propagation","get_propagation"); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"bias",PROPERTY_HINT_RANGE,"0,4,0.001"),"set_bias","get_bias"); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"interior"),"set_interior","is_interior"); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"compress"),"set_compress","is_compressed"); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"data",PROPERTY_HINT_RESOURCE_TYPE,"GIProbeData"),"set_probe_data","get_probe_data"); @@ -1434,6 +1503,7 @@ GIProbe::GIProbe() { subdiv=SUBDIV_128; dynamic_range=4; energy=1.0; + bias=0.4; propagation=1.0; extents=Vector3(10,10,10); color_scan_cell_width=4; diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index f03a558908..0f003d7cb1 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -38,6 +38,9 @@ public: void set_energy(float p_range); float get_energy() const; + void set_bias(float p_range); + float get_bias() const; + void set_interior(bool p_enable); bool is_interior() const; @@ -137,6 +140,7 @@ private: Vector3 extents; int dynamic_range; float energy; + float bias; float propagation; bool interior; bool compress; @@ -176,6 +180,9 @@ public: void set_energy(float p_energy); float get_energy() const; + void set_bias(float p_bias); + float get_bias() const; + void set_propagation(float p_propagation); float get_propagation() const; diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 11eaa2ed33..473bca8d3b 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "light.h" -#include "globals.h" +#include "global_config.h" #include "scene/resources/surface_tool.h" #include "baked_light_instance.h" diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp index 44e4fb54da..19f1261238 100644 --- a/scene/3d/portal.cpp +++ b/scene/3d/portal.cpp @@ -29,7 +29,7 @@ #include "portal.h" #include "servers/visual_server.h" #include "scene/resources/surface_tool.h" -#include "globals.h" +#include "global_config.h" bool Portal::_set(const StringName& p_name, const Variant& p_value) { diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp index fbfc44ce90..b363c05ef7 100644 --- a/scene/3d/room_instance.cpp +++ b/scene/3d/room_instance.cpp @@ -31,7 +31,7 @@ #include "servers/visual_server.h" #include "geometry.h" -#include "globals.h" +#include "global_config.h" #include "scene/resources/surface_tool.h" diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index 1bb6d83393..04e82ba914 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -31,7 +31,7 @@ #include "message_queue.h" #include "scene/resources/surface_tool.h" -#include "core/globals.h" +#include "core/global_config.h" bool Skeleton::_set(const StringName& p_path, const Variant& p_value) { diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index e52afdffdf..cffe2ce218 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -30,7 +30,7 @@ #include "servers/visual_server.h" #include "scene/main/viewport.h" #include "scene/main/canvas_layer.h" -#include "globals.h" +#include "global_config.h" #include "print_string.h" #include "os/keyboard.h" diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 2f97ce2d51..72d3f0e8f8 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -272,7 +272,7 @@ void AcceptDialog::_update_child_rects() { if (!c) continue; - if (c==hbc || c==label || c==get_close_button()) + if (c==hbc || c==label || c==get_close_button() || c->is_set_as_toplevel()) continue; c->set_pos(cpos); @@ -299,7 +299,7 @@ Size2 AcceptDialog::get_minimum_size() const { if (!c) continue; - if (c==hbc || c==label || c==const_cast<AcceptDialog*>(this)->get_close_button()) + if (c==hbc || c==label || c==const_cast<AcceptDialog*>(this)->get_close_button() || c->is_set_as_toplevel()) continue; Size2 cminsize = c->get_combined_minimum_size(); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 4e10f1d622..a35df53e52 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "item_list.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" void ItemList::add_item(const String& p_item,const Ref<Texture>& p_texture,bool p_selectable) { @@ -1204,6 +1204,22 @@ int ItemList::get_item_at_pos(const Point2& p_pos, bool p_exact) const { return closest; } +bool ItemList::is_pos_at_end_of_items(const Point2& p_pos) const { + + if (items.empty()) + return true; + + Vector2 pos=p_pos; + Ref<StyleBox> bg = get_stylebox("bg"); + pos-=bg->get_offset(); + pos.y+=scroll_bar->get_value(); + + Rect2 endrect = items[items.size()-1].rect_cache; + return (pos.y > endrect.pos.y + endrect.size.y); + +} + + String ItemList::get_tooltip(const Point2& p_pos) const { int closest = get_item_at_pos(p_pos); diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index f4a864c782..35ffb1be9c 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -191,6 +191,7 @@ public: virtual String get_tooltip(const Point2& p_pos) const; int get_item_at_pos(const Point2& p_pos,bool p_exact=false) const; + bool is_pos_at_end_of_items(const Point2& p_pos) const; void set_icon_scale(real_t p_scale); real_t get_icon_scale() const; diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index dfcea30056..915eaa2f45 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "label.h" #include "print_string.h" -#include "globals.h" +#include "global_config.h" #include "translation.h" diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 2ad1f385db..f2c04d2f76 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -100,8 +100,6 @@ void SpinBox::_gui_input(const InputEvent& p_event) { if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed) { const InputEventMouseButton &mb=p_event.mouse_button; - if (mb.doubleclick) - return; //ignore doubleclick bool up = mb.y < (get_size().height/2); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index cacb79268c..3f2eab8bef 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -32,7 +32,7 @@ #include "os/input.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" #include "message_queue.h" #include "scene/main/viewport.h" diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 524ef2aae4..7bfc24079b 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -30,7 +30,7 @@ #include "print_string.h" #include "os/os.h" #include "os/keyboard.h" -#include "globals.h" +#include "global_config.h" #include "os/input.h" #include "scene/main/viewport.h" diff --git a/scene/io/resource_format_image.cpp b/scene/io/resource_format_image.cpp index 4d15ab86fd..8bb07adb5f 100644 --- a/scene/io/resource_format_image.cpp +++ b/scene/io/resource_format_image.cpp @@ -31,7 +31,7 @@ #if 0 #include "scene/resources/texture.h" #include "io/image_loader.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_original_path, Error *r_error) { diff --git a/scene/main/node.h b/scene/main/node.h index d88db8ecb0..93b250ab0f 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -29,7 +29,7 @@ #ifndef NODE_H #define NODE_H -#include "globals.h" +#include "global_config.h" #include "object.h" #include "path_db.h" #include "map.h" diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index 76f5ef7c96..418eb92ee2 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -32,7 +32,7 @@ #include "os/os.h" #include "message_queue.h" #include "node.h" -#include "globals.h" +#include "global_config.h" #include <stdio.h> #include "os/keyboard.h" //#include "servers/spatial_sound_2d_server.h" @@ -63,9 +63,19 @@ float SceneTreeTimer::get_time_left() const { return time_left; } +void SceneTreeTimer::set_pause_mode_process(bool p_pause_mode_process) { + if (process_pause != p_pause_mode_process) { + process_pause = p_pause_mode_process; + } +} + +bool SceneTreeTimer::is_pause_mode_process() { + return process_pause; +} SceneTreeTimer::SceneTreeTimer() { time_left=0; + process_pause = true; } @@ -602,7 +612,10 @@ bool SceneTree::idle(float p_time){ for (List<Ref<SceneTreeTimer> >::Element *E=timers.front();E;) { List<Ref<SceneTreeTimer> >::Element *N = E->next(); - + if (pause && !E->get()->is_pause_mode_process()) { + E=N; + continue; + } float time_left = E->get()->get_time_left(); time_left-=p_time; E->get()->set_time_left(time_left); @@ -1714,10 +1727,11 @@ void SceneTree::drop_files(const Vector<String>& p_files,int p_from_screen) { } -Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec) { +Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec, bool p_process_pause) { Ref<SceneTreeTimer> stt; stt.instance(); + stt->set_pause_mode_process(p_process_pause); stt->set_time_left(p_delay_sec); timers.push_back(stt); return stt; @@ -2243,7 +2257,7 @@ void SceneTree::_bind_methods() { ClassDB::bind_method(D_METHOD("is_paused"),&SceneTree::is_paused); ClassDB::bind_method(D_METHOD("set_input_as_handled"),&SceneTree::set_input_as_handled); - ClassDB::bind_method(D_METHOD("create_timer:SceneTreeTimer","time_sec"),&SceneTree::create_timer); + ClassDB::bind_method(D_METHOD("create_timer:SceneTreeTimer","time_sec", "pause_mode_process"),&SceneTree::create_timer, DEFVAL(true)); ClassDB::bind_method(D_METHOD("get_node_count"),&SceneTree::get_node_count); diff --git a/scene/main/scene_main_loop.h b/scene/main/scene_main_loop.h index f4271e5454..fec8534b40 100644 --- a/scene/main/scene_main_loop.h +++ b/scene/main/scene_main_loop.h @@ -56,6 +56,7 @@ class SceneTreeTimer : public Reference { GDCLASS(SceneTreeTimer,Reference); float time_left; + bool process_pause; protected: static void _bind_methods(); public: @@ -63,6 +64,9 @@ public: void set_time_left(float p_time); float get_time_left() const; + void set_pause_mode_process(bool p_pause_mode_process); + bool is_pause_mode_process(); + SceneTreeTimer(); }; @@ -430,7 +434,7 @@ public: Error change_scene_to(const Ref<PackedScene>& p_scene); Error reload_current_scene(); - Ref<SceneTreeTimer> create_timer(float p_delay_sec); + Ref<SceneTreeTimer> create_timer(float p_delay_sec, bool p_process_pause=true); //used by Main::start, don't use otherwise void add_current_scene(Node * p_current); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index f7bd98a002..ef39dcde4b 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -48,7 +48,7 @@ #include "scene/main/timer.h" #include "scene/scene_string_names.h" -#include "globals.h" +#include "global_config.h" void ViewportTexture::setup_local_to_scene() { diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index c0bd86382b..ffdc85301a 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "register_scene_types.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" #include "scene/io/resource_format_image.h" #include "scene/io/resource_format_wav.h" diff --git a/scene/resources/audio_stream_resampled.cpp b/scene/resources/audio_stream_resampled.cpp index 7b49ec0849..b2f314a55e 100644 --- a/scene/resources/audio_stream_resampled.cpp +++ b/scene/resources/audio_stream_resampled.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "audio_stream_resampled.h" -#include "globals.h" +#include "global_config.h" #if 0 diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index eb1a3b550a..f44b37f6f5 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "environment.h" #include "texture.h" -#include "globals.h" +#include "global_config.h" #include "servers/visual_server.h" RID Environment::get_rid() const { diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index b7c8b1664d..3780c466a5 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -339,7 +339,7 @@ void FixedSpatialMaterial::_update_shader() { code+="\tROUGHNESS = specular_tex.a * roughness;\n"; } else { code+="\tvec4 specular_tex = texture(texture_specular,UV);\n"; - code+="\tSPECULAR = vec3(metalness * specular_tex.r);\n"; + code+="\tSPECULAR = vec3(ALBEDO.rgb * metalness * specular_tex.r);\n"; code+="\tROUGHNESS = specular_tex.a * roughness;\n"; } diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 03d516329a..9990a6e796 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -128,8 +128,8 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) { if (d.has("arrays")) { //old format - ERR_FAIL_COND_V(!d.has("blend_shape_arrays"),false); - add_surface_from_arrays(PrimitiveType(int(d["primitive"])),d["arrays"],d["blend_shape_arrays"]); + ERR_FAIL_COND_V(!d.has("morph_arrays"),false); + add_surface_from_arrays(PrimitiveType(int(d["primitive"])),d["arrays"],d["morph_arrays"]); } else if (d.has("array_data")) { diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index ce755d90db..5e3347687a 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "packed_scene.h" -#include "globals.h" +#include "global_config.h" #include "io/resource_loader.h" #include "scene/3d/spatial.h" #include "scene/gui/control.h" @@ -177,6 +177,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const { node = obj->cast_to<Node>(); + } else { + print_line("wtf class is disabled for: "+itos(n.type)); + print_line("name: "+String(snames[n.type])); } @@ -196,6 +199,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { ERR_FAIL_INDEX_V( nprops[j].name, sname_count, NULL ); ERR_FAIL_INDEX_V( nprops[j].value, prop_count, NULL ); + if (snames[ nprops[j].name ]==CoreStringNames::get_singleton()->_script) { //work around to avoid old script variables from disappearing, should be the proper fix to: //https://github.com/godotengine/godot/issues/2958 @@ -357,7 +361,7 @@ static int _nm_get_string(const String& p_string, Map<StringName,int> &name_map) return idx; } -static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,VariantHasher> &variant_map) { +static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map) { if (variant_map.has(p_variant)) return variant_map[p_variant]; @@ -367,7 +371,7 @@ static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,Variant return idx; } -Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) { +Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) { // this function handles all the work related to properly packing scenes, be it @@ -743,7 +747,7 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S } -Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) { +Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) { if (p_node!=p_owner && p_node->get_owner() && p_node->get_owner()!=p_owner && !p_owner->is_editable_instance(p_node->get_owner())) return OK; @@ -948,7 +952,7 @@ Error SceneState::pack(Node *p_scene) { Node *scene = p_scene; Map<StringName,int> name_map; - HashMap<Variant,int,VariantHasher> variant_map; + HashMap<Variant,int,VariantHasher,VariantComparator> variant_map; Map<Node*,int> node_map; Map<Node*,int> nodepath_map; diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h index 381b356b1e..4a3841abe9 100644 --- a/scene/resources/packed_scene.h +++ b/scene/resources/packed_scene.h @@ -91,8 +91,8 @@ class SceneState : public Reference { Vector<ConnectionData> connections; - Error _parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map); - Error _parse_connections(Node *p_owner,Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map); + Error _parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map); + Error _parse_connections(Node *p_owner,Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map); String path; diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index 9719f321d6..3a254836a2 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "scene_format_text.h" -#include "globals.h" +#include "global_config.h" #include "version.h" #include "os/dir_access.h" diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 5e67a9e5b2..62feb7b37c 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -559,6 +559,11 @@ Error StreamTexture::_load_data(const String& p_path,int &tw,int &th,int& flags, int total_size=0; for(int i=0;i<mipmaps;i++) { + + if (i>0) { + size = f->get_32(); + } + PoolVector<uint8_t> pv; pv.resize(size); { @@ -754,6 +759,12 @@ bool StreamTexture::has_alpha() const { return false; } + +Image StreamTexture::get_data() const { + + return VS::get_singleton()->texture_get_data(texture); +} + void StreamTexture::set_flags(uint32_t p_flags){ } diff --git a/scene/resources/texture.h b/scene/resources/texture.h index f684aeb658..cae77ad5cf 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -76,7 +76,7 @@ public: virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const; virtual bool get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const; - + virtual Image get_data() const { return Image(); } Texture(); }; @@ -224,6 +224,8 @@ public: virtual bool has_alpha() const; virtual void set_flags(uint32_t p_flags); + virtual Image get_data() const; + StreamTexture(); ~StreamTexture(); diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp index b2713da569..6b745d5d35 100644 --- a/scene/resources/world_2d.cpp +++ b/scene/resources/world_2d.cpp @@ -30,11 +30,11 @@ #include "servers/visual_server.h" #include "servers/physics_2d_server.h" //#include "servers/spatial_sound_2d_server.h" -#include "globals.h" +#include "global_config.h" #include "scene/2d/visibility_notifier_2d.h" #include "scene/main/viewport.h" #include "scene/2d/camera_2d.h" -#include "globals.h" +#include "global_config.h" struct SpatialIndexer2D { diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h index a9110b3bd9..c02880e9ed 100644 --- a/scene/resources/world_2d.h +++ b/scene/resources/world_2d.h @@ -31,7 +31,7 @@ #include "resource.h" #include "servers/physics_2d_server.h" -#include "globals.h" +#include "global_config.h" class SpatialIndexer2D; class VisibilityNotifier2D; diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp index 6e0c0089ca..6c12957851 100644 --- a/servers/audio/audio_driver_dummy.cpp +++ b/servers/audio/audio_driver_dummy.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "audio_driver_dummy.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index edc7f36ff2..192d958a64 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "audio_server.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" #include "servers/audio/effects/audio_effect_compressor.h" #include "io/resource_loader.h" diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index 21f336958d..0bc11041de 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -26,7 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "globals.h" +#include "global_config.h" #include "space_sw.h" #include "collision_solver_sw.h" #include "physics_server_sw.h" diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h index 51d5db3d8e..208831914f 100644 --- a/servers/physics/space_sw.h +++ b/servers/physics/space_sw.h @@ -37,7 +37,7 @@ #include "area_pair_sw.h" #include "broad_phase_sw.h" #include "collision_object_sw.h" -#include "globals.h" +#include "global_config.h" class PhysicsDirectSpaceStateSW : public PhysicsDirectSpaceState { diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp index 8b7a410b3d..06eead64cd 100644 --- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp +++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "broad_phase_2d_hash_grid.h" -#include "globals.h" +#include "global_config.h" #define LARGE_ELEMENT_FI 1.01239812 diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index a92d653b4b..920742ea0b 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -30,7 +30,7 @@ #include "broad_phase_2d_basic.h" #include "broad_phase_2d_hash_grid.h" #include "collision_solver_2d_sw.h" -#include "globals.h" +#include "global_config.h" #include "script_language.h" #include "os/os.h" diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h index 0f633e2550..f8b533080e 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.h +++ b/servers/physics_2d/physics_2d_server_wrap_mt.h @@ -33,7 +33,7 @@ #include "servers/physics_2d_server.h" #include "command_queue_mt.h" #include "os/thread.h" -#include "globals.h" +#include "global_config.h" #ifdef DEBUG_SYNC #define SYNC_DEBUG print_line("sync on: "+String(__FUNCTION__)); diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index e45a6c6f29..9bced50061 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -622,6 +622,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co Transform2D body_transform = p_from; + { //STEP 1, FREE BODY IF STUCK @@ -645,6 +646,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co bool collided=false; + int amount = _cull_aabb_for_body(p_body,body_aabb); for(int j=0;j<p_body->get_shape_count();j++) { @@ -682,11 +684,13 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co } - if (!collided) + if (!collided) { break; + } Vector2 recover_motion; + for(int i=0;i<cbk.amount;i++) { Vector2 a = sr[i*2+0]; diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h index eaa385c3bb..071aa7bdfb 100644 --- a/servers/physics_2d/space_2d_sw.h +++ b/servers/physics_2d/space_2d_sw.h @@ -37,7 +37,7 @@ #include "area_pair_2d_sw.h" #include "broad_phase_2d_sw.h" #include "collision_object_2d_sw.h" -#include "globals.h" +#include "global_config.h" class Physics2DDirectSpaceStateSW : public Physics2DDirectSpaceState { diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index 01f8ffa504..0d0619e880 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "register_server_types.h" -#include "globals.h" +#include "global_config.h" #include "visual_server.h" #include "audio_server.h" diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 21f7f0769f..dd22986865 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -432,6 +432,9 @@ public: virtual void gi_probe_set_energy(RID p_probe,float p_range)=0; virtual float gi_probe_get_energy(RID p_probe) const=0; + virtual void gi_probe_set_bias(RID p_probe,float p_range)=0; + virtual float gi_probe_get_bias(RID p_probe) const=0; + virtual void gi_probe_set_propagation(RID p_probe,float p_range)=0; virtual float gi_probe_get_propagation(RID p_probe) const=0; @@ -519,6 +522,8 @@ public: virtual bool has_os_feature(const String& p_feature) const=0; + virtual void update_dirty_resources()=0; + static RasterizerStorage*base_signleton; RasterizerStorage(); virtual ~RasterizerStorage() {} diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 8f87425212..3a5ffda8f5 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "visual_server_raster.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" #include "default_mouse_cursor.xpm" #include "sort.h" #include "io/marshalls.h" diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index ad0cb664c5..7d547e1862 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -825,6 +825,9 @@ public: BIND2(gi_probe_set_energy,RID,float) BIND1RC(float,gi_probe_get_energy,RID) + BIND2(gi_probe_set_bias,RID,float) + BIND1RC(float,gi_probe_get_bias,RID) + BIND2(gi_probe_set_propagation,RID,float) BIND1RC(float,gi_probe_get_propagation,RID) diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index c54f3dbca5..6f7b2e3aed 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -1556,9 +1556,11 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance,const cull_count--; SWAP(instance_shadow_cull_result[j],instance_shadow_cull_result[cull_count]); j--; + continue; } + instance->transformed_aabb.project_range_in_plane(Plane(z_vec,0),min,max); if (max>z_max) z_max=max; @@ -3475,6 +3477,7 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) { } else if (p_instance->base_type==VS::INSTANCE_MULTIMESH) { RID mesh = VSG::storage->multimesh_get_mesh(p_instance->base); if (mesh.is_valid()) { + bool cast_shadows=false; int sc = VSG::storage->mesh_get_surface_count(mesh); @@ -3491,6 +3494,7 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) { cast_shadows=true; break; } + } if (!cast_shadows) { @@ -3538,6 +3542,8 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) { void VisualServerScene::update_dirty_instances() { + VSG::storage->update_dirty_resources(); + while(_instance_update_list.first()) { _update_dirty_instance( _instance_update_list.first()->self() ); diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp index d2ee32f9cc..d32c4dd6bf 100644 --- a/servers/visual/visual_server_viewport.cpp +++ b/servers/visual/visual_server_viewport.cpp @@ -2,7 +2,7 @@ #include "visual_server_global.h" #include "visual_server_canvas.h" #include "visual_server_scene.h" -#include "globals.h" +#include "global_config.h" diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 68767da4ce..5d231d208e 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "visual_server.h" -#include "globals.h" +#include "global_config.h" #include "method_bind_ext.inc" VisualServer *VisualServer::singleton=NULL; @@ -712,7 +712,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t } break; case VS::ARRAY_BONES: { - ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_INT_ARRAY, ERR_INVALID_PARAMETER ); + ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_INT_ARRAY && p_arrays[ai].get_type() != Variant::POOL_REAL_ARRAY, ERR_INVALID_PARAMETER ); PoolVector<int> array = p_arrays[ai]; diff --git a/servers/visual_server.h b/servers/visual_server.h index 5c835c2287..08cf34a653 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -475,6 +475,9 @@ public: virtual void gi_probe_set_energy(RID p_probe,float p_range)=0; virtual float gi_probe_get_energy(RID p_probe) const=0; + virtual void gi_probe_set_bias(RID p_probe,float p_range)=0; + virtual float gi_probe_get_bias(RID p_probe) const=0; + virtual void gi_probe_set_propagation(RID p_probe,float p_range)=0; virtual float gi_probe_get_propagation(RID p_probe) const=0; diff --git a/tools/editor/SCsub b/tools/editor/SCsub index 710dac3ea7..76eb65748a 100644 --- a/tools/editor/SCsub +++ b/tools/editor/SCsub @@ -137,7 +137,7 @@ if (env["tools"] == "yes"): reg_exporters = 'void register_exporters() {\n' for e in env.platform_exporters: env.editor_sources.append("#platform/" + e + "/export/export.cpp") - reg_exporters += '\t//register_' + e + '_exporter();\n' + reg_exporters += '\tregister_' + e + '_exporter();\n' reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n' reg_exporters += '}\n' f = open("register_exporters.cpp", "wb") diff --git a/tools/editor/collada/collada.h b/tools/editor/collada/collada.h index fd7ad4920d..2de2d22935 100644 --- a/tools/editor/collada/collada.h +++ b/tools/editor/collada/collada.h @@ -33,7 +33,7 @@ #include "scene/resources/material.h" -#include "globals.h" +#include "global_config.h" #include "io/xml_parser.h" #include "map.h" diff --git a/tools/editor/doc/doc_data.cpp b/tools/editor/doc/doc_data.cpp index d51dc886b2..e0a4750862 100644 --- a/tools/editor/doc/doc_data.cpp +++ b/tools/editor/doc/doc_data.cpp @@ -30,7 +30,7 @@ #include "version.h" #include "global_constants.h" -#include "globals.h" +#include "global_config.h" #include "script_language.h" #include "io/marshalls.h" #include "io/compression.h" diff --git a/tools/editor/editor_autoload_settings.cpp b/tools/editor/editor_autoload_settings.cpp index 0038ab48d5..3e3362f515 100644 --- a/tools/editor/editor_autoload_settings.cpp +++ b/tools/editor/editor_autoload_settings.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "editor_autoload_settings.h" -#include "globals.h" +#include "global_config.h" #include "global_constants.h" #include "editor_node.h" diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp index 2a3c55229a..d2fa40e08c 100644 --- a/tools/editor/editor_data.cpp +++ b/tools/editor/editor_data.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "editor_data.h" -#include "globals.h" +#include "global_config.h" #include "editor_settings.h" #include "os/dir_access.h" #include "io/resource_loader.h" diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_export.cpp index 320c45776d..a67b583868 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_export.cpp @@ -26,12 +26,937 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "editor_import_export.h" +#include "editor_export.h" +#include "version.h" +#include "script_language.h" +#include "global_config.h" +#include "os/file_access.h" +#include "os/dir_access.h" +#include "tools/editor/editor_file_system.h" +#include "io/resource_loader.h" +#include "editor_node.h" +#include "editor_settings.h" +#include "io/config_file.h" +#include "io/resource_saver.h" +#include "io/md5.h" +#include "tools/editor/plugins/script_editor_plugin.h" +#include "io/zip_io.h" + +static int _get_pad(int p_alignment, int p_n) { + + int rest = p_n % p_alignment; + int pad = 0; + if (rest > 0) { + pad = p_alignment - rest; + }; + + return pad; +}; + +#define PCK_PADDING 16 + +bool EditorExportPreset::_set(const StringName& p_name, const Variant& p_value) { + + if (values.has(p_name)) { + values[p_name]=p_value; + EditorExport::singleton->save_presets(); + return true; + } + + return false; +} + +bool EditorExportPreset::_get(const StringName& p_name,Variant &r_ret) const{ + + if (values.has(p_name)) { + r_ret=values[p_name]; + return true; + } + + return false; +} +void EditorExportPreset::_get_property_list( List<PropertyInfo> *p_list) const{ + + for (const List<PropertyInfo>::Element *E=properties.front();E;E=E->next()) { + + p_list->push_back(E->get()); + } +} + +Ref<EditorExportPlatform> EditorExportPreset::get_platform() const { + + return platform; +} + +Vector<String> EditorExportPreset::get_files_to_export() const { + + Vector<String> files; + for(Set<String>::Element *E=selected_files.front();E;E=E->next()) { + files.push_back(E->get()); + } + return files; +} + +void EditorExportPreset::set_name(const String& p_name) { + name=p_name; + EditorExport::singleton->save_presets(); + +} + +String EditorExportPreset::get_name() const { + return name; + +} + +void EditorExportPreset::set_runnable(bool p_enable) { + + runnable=p_enable; + EditorExport::singleton->save_presets(); +} + +bool EditorExportPreset::is_runnable() const { + + return runnable; +} + +void EditorExportPreset::set_export_filter(ExportFilter p_filter) { + + export_filter=p_filter; + EditorExport::singleton->save_presets(); + +} + +EditorExportPreset::ExportFilter EditorExportPreset::get_export_filter() const { + return export_filter; +} + +void EditorExportPreset::set_include_filter(const String& p_include) { + + include_filter=p_include; + EditorExport::singleton->save_presets(); + +} + +String EditorExportPreset::get_include_filter() const { + + return include_filter; +} + +void EditorExportPreset::set_exclude_filter(const String& p_exclude) { + + exclude_filter=p_exclude; + EditorExport::singleton->save_presets(); +} + +String EditorExportPreset::get_exclude_filter() const { + + return exclude_filter; +} + +void EditorExportPreset::add_export_file(const String& p_path) { + + selected_files.insert(p_path); + EditorExport::singleton->save_presets(); +} + +void EditorExportPreset::remove_export_file(const String& p_path) { + selected_files.erase(p_path); + EditorExport::singleton->save_presets(); +} + +bool EditorExportPreset::has_export_file(const String& p_path) { + + return selected_files.has(p_path); +} + +void EditorExportPreset::add_patch(const String& p_path,int p_at_pos) { + + if (p_at_pos<0) + patches.push_back(p_path); + else + patches.insert(p_at_pos,p_path); + EditorExport::singleton->save_presets(); +} + +void EditorExportPreset::remove_patch(int p_idx) { + patches.remove(p_idx); + EditorExport::singleton->save_presets(); +} + +void EditorExportPreset::set_patch(int p_index,const String& p_path) { + ERR_FAIL_INDEX(p_index,patches.size()); + patches[p_index]=p_path; + EditorExport::singleton->save_presets(); +} +String EditorExportPreset::get_patch(int p_index) { + + ERR_FAIL_INDEX_V(p_index,patches.size(),String()); + return patches[p_index]; +} + +Vector<String> EditorExportPreset::get_patches() const { + return patches; +} + +EditorExportPreset::EditorExportPreset() { + + export_filter=EXPORT_ALL_RESOURCES; + runnable=false; +} + + +/////////////////////////////////// + +void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) { + + String host = EditorSettings::get_singleton()->get("network/debug_host"); + + if (p_flags&DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST) + host="localhost"; + + if (p_flags&DEBUG_FLAG_DUMB_CLIENT) { + int port = EditorSettings::get_singleton()->get("filesystem/file_server/port"); + String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password"); + r_flags.push_back("-rfs"); + r_flags.push_back(host+":"+itos(port)); + if (passwd!="") { + r_flags.push_back("-rfs_pass"); + r_flags.push_back(passwd); + } + } + + if (p_flags&DEBUG_FLAG_REMOTE_DEBUG) { + + r_flags.push_back("-rdebug"); + + r_flags.push_back(host+":"+String::num(GLOBAL_DEF("network/debug/remote_port", 6007))); + + List<String> breakpoints; + ScriptEditor::get_singleton()->get_breakpoints(&breakpoints); + + + if (breakpoints.size()) { + + r_flags.push_back("-bp"); + String bpoints; + for(const List<String>::Element *E=breakpoints.front();E;E=E->next()) { + + bpoints+=E->get().replace(" ","%20"); + if (E->next()) + bpoints+=","; + } + + r_flags.push_back(bpoints); + } + + } + + if (p_flags&DEBUG_FLAG_VIEW_COLLISONS) { + + r_flags.push_back("-debugcol"); + } + + if (p_flags&DEBUG_FLAG_VIEW_NAVIGATION) { + + r_flags.push_back("-debugnav"); + } +} + +Error EditorExportPlatform::_save_pack_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total) { + + PackData *pd = (PackData*)p_userdata; + + SavedData sd; + sd.path_utf8=p_path.utf8(); + sd.ofs = pd->f->get_pos(); + sd.size = p_data.size(); + + pd->f->store_buffer(p_data.ptr(),p_data.size()); + int pad = _get_pad(PCK_PADDING,sd.size); + for(int i=0;i<pad;i++) { + pd->f->store_8(0); + } + + { + MD5_CTX ctx; + MD5Init(&ctx); + MD5Update(&ctx,(unsigned char*)p_data.ptr(),p_data.size()); + MD5Final(&ctx); + sd.md5.resize(16); + for(int i=0;i<16;i++) { + sd.md5[i]=ctx.digest[i]; + } + } + + pd->file_ofs.push_back(sd); + + pd->ep->step(TTR("Storing File:")+" "+p_path,2+p_file*100/p_total,false); + + return OK; +} + +Error EditorExportPlatform::_save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total) { + + + String path=p_path.replace_first("res://",""); + + ZipData *zd = (ZipData*)p_userdata; + + zipFile zip=(zipFile)zd->zip; + + zipOpenNewFileInZip(zip, + path.utf8().get_data(), + NULL, + NULL, + 0, + NULL, + 0, + NULL, + Z_DEFLATED, + Z_DEFAULT_COMPRESSION); + + zipWriteInFileInZip(zip,p_data.ptr(),p_data.size()); + zipCloseFileInZip(zip); + + zd->ep->step(TTR("Storing File:")+" "+p_path,2+p_file*100/p_total,false); + + return OK; +} + +String EditorExportPlatform::find_export_template(String template_file_name, String *err) const { + + String user_file = EditorSettings::get_singleton()->get_settings_path() + +"/templates/"+itos(VERSION_MAJOR)+"."+itos(VERSION_MINOR)+"."+_MKSTR(VERSION_STATUS)+"/"+template_file_name; + String system_file=OS::get_singleton()->get_installed_templates_path(); + bool has_system_path=(system_file!=""); + system_file+=template_file_name; + + // Prefer user file + if (FileAccess::exists(user_file)) { + return user_file; + } + + // Now check system file + if (has_system_path) { + if (FileAccess::exists(system_file)) { + return system_file; + } + } + + // Not found + if (err) { + *err+="No export template found at \""+user_file+"\""; + if (has_system_path) + *err+="\n or \""+system_file+"\"."; + else + *err+="."; + } + return ""; +} + +Ref<EditorExportPreset> EditorExportPlatform::create_preset() { + + Ref<EditorExportPreset> preset; + preset.instance(); + preset->platform=Ref<EditorExportPlatform>(this); + + List<ExportOption> options; + get_export_options(&options); + + for (List<ExportOption>::Element *E=options.front();E;E=E->next()) { + + preset->properties.push_back(E->get().option); + preset->values[E->get().option.name]=E->get().default_value; + } + + return preset; + +} + +void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir,Set<String>& p_paths) { + + for(int i=0;i<p_dir->get_subdir_count();i++) { + _export_find_resources(p_dir->get_subdir(i),p_paths); + } + + for(int i=0;i<p_dir->get_file_count();i++) { + p_paths.insert(p_dir->get_file_path(i)); + } +} + + +void EditorExportPlatform::_export_find_dependencies(const String& p_path,Set<String>& p_paths) { + + if (p_paths.has(p_path)) + return; + + p_paths.insert(p_path); + + EditorFileSystemDirectory *dir; + int file_idx; + dir = EditorFileSystem::get_singleton()->find_file(p_path,&file_idx); + if (!dir) + return; + + Vector<String> deps = dir->get_file_deps(file_idx); + + for(int i=0;i<deps.size();i++) { + + _export_find_dependencies(deps[i],p_paths); + } +} + + +Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset>& p_preset,EditorExportSaveFunction p_func, void* p_udata) { + + Ref<EditorExportPlatform> platform = p_preset->get_platform(); + List<String> feature_list; + platform->get_preset_features(p_preset,&feature_list); + //figure out features + Set<String> features; + for (List<String>::Element *E=feature_list.front();E;E=E->next()) { + features.insert(E->get()); + } + + //figure out paths of files that will be exported + Set<String> paths; + + if (p_preset->get_export_filter()==EditorExportPreset::EXPORT_ALL_RESOURCES) { + //find stuff + _export_find_resources(EditorFileSystem::get_singleton()->get_filesystem(),paths); + } else { + bool scenes_only = p_preset->get_export_filter()==EditorExportPreset::EXPORT_SELECTED_SCENES; + + Vector<String> files = p_preset->get_files_to_export(); + for(int i=0;i<files.size();i++) { + if (scenes_only && ResourceLoader::get_resource_type(files[i])!="PackedScene") + continue; + + _export_find_dependencies(files[i],paths); + } + } + + //store everything in the export medium + int idx = 0; + int total=paths.size(); + + for(Set<String>::Element *E=paths.front();E;E=E->next()) { + + String path = E->get(); + + if (FileAccess::exists(path+".import")) { + //file is imported, replace by what it imports + Ref<ConfigFile> config; + config.instance(); + Error err = config->load(path+".import"); + if (err!=OK) { + ERR_PRINTS("Could not parse: '"+path+"', not exported."); + continue; + } + + List<String> remaps; + config->get_section_keys("remap",&remaps); + + for(List<String>::Element *F=remaps.front();F;F=F->next()) { + + String remap=F->get(); + if (remap=="path") { + String remapped_path=config->get_value("remap",remap); + Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path); + p_func(p_udata,remapped_path,array,idx,total); + } else if (remap.begins_with("path.")) { + String feature = remap.get_slice(".",1); + if (features.has(feature)) { + String remapped_path=config->get_value("remap",remap); + Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path); + p_func(p_udata,remapped_path,array,idx,total); + } + } + } + + //also save the .import file + Vector<uint8_t> array = FileAccess::get_file_as_array(path+".import"); + p_func(p_udata,path+".import",array,idx,total); + + } else { + //just store it as it comes + Vector<uint8_t> array = FileAccess::get_file_as_array(path); + p_func(p_udata,path,array,idx,total); + } + + idx++; + } + + //save config! + + String config_file="godot.cfb"; + String engine_cfb =EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmp"+config_file; + GlobalConfig::get_singleton()->save_custom(engine_cfb); + Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb); + + p_func(p_udata,"res://"+config_file,data,idx,total); + + return OK; +} + +Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset>& p_preset,const String& p_path) { + + EditorProgress ep("savepack",TTR("Packing"),102); + + String tmppath = EditorSettings::get_singleton()->get_settings_path()+"/tmp/packtmp"; + FileAccess *ftmp = FileAccess::open(tmppath,FileAccess::WRITE); + ERR_FAIL_COND_V(!ftmp,ERR_CANT_CREATE) + + PackData pd; + pd.ep=&ep; + pd.f=ftmp; + + Error err = export_project_files(p_preset,_save_pack_file,&pd); + + memdelete(ftmp); //close tmp file + + if (err) + return err; + + pd.file_ofs.sort(); //do sort, so we can do binary search later + + + FileAccess *f = FileAccess::open(p_path,FileAccess::WRITE); + ERR_FAIL_COND_V(!f,ERR_CANT_CREATE) + f->store_32(0x43504447); //GDPK + f->store_32(1); //pack version + f->store_32(VERSION_MAJOR); + f->store_32(VERSION_MINOR); + f->store_32(0); //hmph + for(int i=0;i<16;i++) { + //reserved + f->store_32(0); + } + + f->store_32(pd.file_ofs.size()); //amount of files + + size_t header_size = f->get_pos(); + + //precalculate header size + + for(int i=0;i<pd.file_ofs.size();i++) { + header_size += 4; // size of path string (32 bits is enough) + uint32_t string_len = pd.file_ofs[i].path_utf8.length(); + header_size += string_len + _get_pad(4,string_len); ///size of path string + header_size += 8; // offset to file _with_ header size included + header_size += 8; // size of file + header_size +=16; // md5 + + } + + size_t header_padding = _get_pad(PCK_PADDING,header_size); + + + for(int i=0;i<pd.file_ofs.size();i++) { + + uint32_t string_len = pd.file_ofs[i].path_utf8.length(); + uint32_t pad = _get_pad(4,string_len);; + f->store_32(string_len+pad); + f->store_buffer((const uint8_t*)pd.file_ofs[i].path_utf8.get_data(),string_len); + for(uint32_t j=0;j<pad;j++) { + f->store_8(0); + } + + f->store_64(pd.file_ofs[i].ofs + header_padding + header_size); + f->store_64(pd.file_ofs[i].size); // pay attention here, this is where file is + f->store_buffer(pd.file_ofs[i].md5.ptr(),16); //also save md5 for file + } + + for(uint32_t j=0;j<header_padding;j++) { + f->store_8(0); + } + + //save the rest of the data + + ftmp = FileAccess::open(tmppath,FileAccess::READ); + if (!ftmp) { + memdelete(f); + ERR_FAIL_COND_V(!ftmp,ERR_CANT_CREATE) + } + + const int bufsize=16384; + uint8_t buf[bufsize]; + + while(true) { + + int got = ftmp->get_buffer(buf,bufsize); + if (got<=0) + break; + f->store_buffer(buf,got); + } + + memdelete(ftmp); + + f->store_32(0x43504447); //GDPK + memdelete(f); + + return OK; +} + +Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset>& p_preset,const String& p_path) { + + EditorProgress ep("savezip",TTR("Packing"),102); + + //FileAccess *tmp = FileAccess::open(tmppath,FileAccess::WRITE); + + FileAccess *src_f; + zlib_filefunc_def io = zipio_create_io_from_file(&src_f); + zipFile zip=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io); + + ZipData zd; + zd.ep=&ep; + zd.zip=zip; + + + Error err = export_project_files(p_preset,_save_zip_file,&zd); + + zipClose(zip,NULL); + + return OK; +} + +EditorExportPlatform::EditorExportPlatform() { + + +} + + +//// + +EditorExport *EditorExport::singleton=NULL; + + +void EditorExport::_save() { + + + Ref<ConfigFile> config; + config.instance(); + for(int i=0;i<export_presets.size();i++) { + + Ref<EditorExportPreset> preset = export_presets[i]; + String section="preset."+itos(i); + + config->set_value(section,"name",preset->get_name()); + config->set_value(section,"platform",preset->get_platform()->get_name()); + config->set_value(section,"runnable",preset->is_runnable()); + bool save_files=false; + switch(preset->get_export_filter()) { + case EditorExportPreset::EXPORT_ALL_RESOURCES: { + config->set_value(section,"export_filter","all_resources"); + } break; + case EditorExportPreset::EXPORT_SELECTED_SCENES: { + config->set_value(section,"export_filter","scenes"); + save_files=true; + } break; + case EditorExportPreset::EXPORT_SELECTED_RESOURCES: { + config->set_value(section,"export_filter","resources"); + save_files=true; + } break; + + + } + + if (save_files) { + Vector<String> export_files = preset->get_files_to_export(); + config->set_value(section,"export_files",export_files); + } + config->set_value(section,"include_filter",preset->get_include_filter()); + config->set_value(section,"exclude_filter",preset->get_exclude_filter()); + config->set_value(section,"patch_list",preset->get_patches()); + + String option_section="preset."+itos(i)+".options"; + + for (const List<PropertyInfo>::Element *E=preset->get_properties().front();E;E=E->next()) { + config->set_value(option_section,E->get().name,preset->get(E->get().name)); + } + } + + config->save("res://export_presets.cfg"); + + print_line("saved ok"); + +} + + +void EditorExport::save_presets() { + + print_line("save presets"); + if (block_save) + return; + save_timer->start(); +} + +void EditorExport::_bind_methods() { + + ClassDB::bind_method("_save",&EditorExport::_save); +} + +void EditorExport::add_export_platform(const Ref<EditorExportPlatform>& p_platform) { + + export_platforms.push_back(p_platform); +} + +int EditorExport::get_export_platform_count() { + + return export_platforms.size(); +} + +Ref<EditorExportPlatform> EditorExport::get_export_platform(int p_idx) { + + ERR_FAIL_INDEX_V(p_idx,export_platforms.size(),Ref<EditorExportPlatform>()); + + return export_platforms[p_idx]; +} + + +void EditorExport::add_export_preset(const Ref<EditorExportPreset>& p_preset,int p_at_pos) { + + if (p_at_pos<0) + export_presets.push_back(p_preset); + else + export_presets.insert(p_at_pos,p_preset); + + +} + +int EditorExport::get_export_preset_count() const { + + return export_presets.size(); +} + +Ref<EditorExportPreset> EditorExport::get_export_preset(int p_idx) { + + ERR_FAIL_INDEX_V( p_idx, export_presets.size(),Ref<EditorExportPreset>() ); + return export_presets[p_idx]; +} + +void EditorExport::remove_export_preset(int p_idx) { + + export_presets.remove(p_idx); +} + +void EditorExport::_notification(int p_what) { + + if (p_what==NOTIFICATION_ENTER_TREE) { + load_config(); + } +} + +void EditorExport::load_config() { + + Ref<ConfigFile> config; + config.instance(); + Error err = config->load("res://export_presets.cfg"); + if (err!=OK) + return; + + block_save=true; + + int index=0; + while(true) { + + String section = "preset."+itos(index); + if (!config->has_section(section)) + break; + + String platform=config->get_value(section,"platform"); + + Ref<EditorExportPreset> preset; + + for(int i=0;i<export_platforms.size();i++) { + if (export_platforms[i]->get_name()==platform) { + preset = export_platforms[i]->create_preset(); + break; + } + } + + if (!preset.is_valid()) { + index++; + ERR_CONTINUE(!preset.is_valid()); + } + + preset->set_name( config->get_value(section,"name") ); + preset->set_runnable( config->get_value(section,"runnable") ); + + String export_filter = config->get_value(section,"export_filter"); + + bool get_files=false; + + if (export_filter=="all_resources") { + preset->set_export_filter(EditorExportPreset::EXPORT_ALL_RESOURCES); + } else if (export_filter=="scenes") { + preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_SCENES); + get_files=true; + } else if (export_filter=="resources") { + preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_RESOURCES); + get_files=true; + } + + if (get_files) { + + Vector<String> files = config->get_value(section,"export_files"); + + for(int i=0;i<files.size();i++) { + preset->add_export_file(files[i]); + } + } + + preset->set_include_filter( config->get_value(section,"include_filter") ); + preset->set_exclude_filter( config->get_value(section,"exclude_filter") ); + + + Vector<String> patch_list = config->get_value(section,"patch_list"); + + for(int i=0;i<patch_list.size();i++) { + preset->add_patch(patch_list[i]); + } + + String option_section="preset."+itos(index)+".options"; + + List<String> options; + + config->get_section_keys(option_section,&options); + + for (List<String>::Element *E=options.front();E;E=E->next()) { + + Variant value = config->get_value(option_section,E->get()); + + preset->set(E->get(),value); + } + + add_export_preset(preset); + index++; + } + + block_save=false; + +} + + + +EditorExport::EditorExport() { + + save_timer = memnew( Timer ); + add_child(save_timer); + save_timer->set_wait_time(0.8); + save_timer->set_one_shot(true); + save_timer->connect("timeout",this,"_save"); + block_save=false; + + singleton=this; +} + +EditorExport::~EditorExport() { + + +} + + +////////// + +void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset>& p_preset,List<String>* r_features) { + + if (p_preset->get("texture_format/s3tc")) { + r_features->push_back("s3tc"); + } + if (p_preset->get("texture_format/etc")) { + r_features->push_back("etc"); + } + if (p_preset->get("texture_format/etc2")) { + r_features->push_back("etc2"); + } +} + +void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) { + + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL,"texture_format/s3tc"),true)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL,"texture_format/etc"),false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL,"texture_format/etc2"),false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL,"binary_format/64_bits"),true)); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING,"custom_template/release",PROPERTY_HINT_GLOBAL_FILE),"")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING,"custom_template/debug",PROPERTY_HINT_GLOBAL_FILE),"")); +} + +String EditorExportPlatformPC::get_name() const { + + return name; +} +Ref<Texture> EditorExportPlatformPC::get_logo() const { + + return logo; +} + +bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset>& p_preset,String &r_error, bool &r_missing_templates) const { + + r_missing_templates=false; + + if (find_export_template(release_file_32)==String()) { + r_missing_templates=true; + } else if (find_export_template(debug_file_32)==String()) { + r_missing_templates=true; + } else if (find_export_template(release_file_64)==String()) { + r_missing_templates=true; + } else if (find_export_template(debug_file_64)==String()) { + r_missing_templates=true; + } + return !r_missing_templates; +} + +String EditorExportPlatformPC::get_binary_extension() const { + return extension; +} + +Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset>& p_preset, bool p_debug, const String& p_path, int p_flags) { + + return OK; +} + +void EditorExportPlatformPC::set_extension(const String& p_extension) { + extension=p_extension; +} + +void EditorExportPlatformPC::set_name(const String& p_name) { + name=p_name; +} + +void EditorExportPlatformPC::set_logo(const Ref<Texture>& p_logo) { + logo=p_logo; +} + +void EditorExportPlatformPC::set_release_64(const String& p_file) { + + release_file_64=p_file; +} + +void EditorExportPlatformPC::set_release_32(const String& p_file){ + + release_file_32=p_file; +} +void EditorExportPlatformPC::set_debug_64(const String& p_file){ + + debug_file_64=p_file; +} +void EditorExportPlatformPC::set_debug_32(const String& p_file){ + + debug_file_32=p_file; + +} + +EditorExportPlatformPC::EditorExportPlatformPC() { + +} + +//////// #if 0 #include "version.h" #include "script_language.h" -#include "globals.h" +#include "global_config.h" #include "os/file_access.h" #include "os/dir_access.h" #include "tools/editor/editor_file_system.h" diff --git a/tools/editor/editor_export.h b/tools/editor/editor_export.h new file mode 100644 index 0000000000..8a9dc965e5 --- /dev/null +++ b/tools/editor/editor_export.h @@ -0,0 +1,297 @@ +/*************************************************************************/ +/* editor_import_export.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef EDITOR_EXPORT_H +#define EDITOR_EXPORT_H + + + +#include "resource.h" +#include "scene/main/node.h" +#include "scene/resources/texture.h" +#include "scene/main/timer.h" + +class EditorProgress; +class FileAccess; +class EditorExportPlatform; +class EditorFileSystemDirectory; + +class EditorExportPreset : public Reference { + + GDCLASS( EditorExportPreset,Reference ) +public: + enum ExportFilter { + EXPORT_ALL_RESOURCES, + EXPORT_SELECTED_SCENES, + EXPORT_SELECTED_RESOURCES, + }; + +private: + + Ref<EditorExportPlatform> platform; + ExportFilter export_filter; + String include_filter; + String exclude_filter; + + String exporter; + Set<String> selected_files; + bool runnable; + + Vector<String> patches; + + +friend class EditorExport; +friend class EditorExportPlatform; + + List<PropertyInfo> properties; + Map<StringName,Variant> values; + + String name; +protected: + bool _set(const StringName& p_name, const Variant& p_value); + bool _get(const StringName& p_name,Variant &r_ret) const; + void _get_property_list( List<PropertyInfo> *p_list) const; + +public: + + Ref<EditorExportPlatform> get_platform() const; + bool has(const StringName& p_property) const { return values.has(p_property); } + + Vector<String> get_files_to_export() const; + + void add_export_file(const String& p_path); + void remove_export_file(const String& p_path); + bool has_export_file(const String& p_path); + + void set_name(const String& p_name); + String get_name() const; + + void set_runnable(bool p_enable); + bool is_runnable() const; + + void set_export_filter(ExportFilter p_filter); + ExportFilter get_export_filter() const; + + void set_include_filter(const String& p_include); + String get_include_filter() const; + + void set_exclude_filter(const String& p_exclude); + String get_exclude_filter() const; + + void add_patch(const String& p_path,int p_at_pos=-1); + void set_patch(int p_index,const String& p_path); + String get_patch(int p_index); + void remove_patch(int p_idx); + Vector<String> get_patches() const; + + const List<PropertyInfo>& get_properties() const { return properties; } + + EditorExportPreset(); +}; + + +class EditorExportPlatform : public Reference { + + GDCLASS( EditorExportPlatform,Reference ) + +public: + + typedef Error (*EditorExportSaveFunction)(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total); + +private: + + struct SavedData { + + uint64_t ofs; + uint64_t size; + Vector<uint8_t> md5; + CharString path_utf8; + + bool operator<(const SavedData& p_data) const { + return path_utf8 < p_data.path_utf8; + } + }; + + struct PackData { + + FileAccess *f; + Vector<SavedData> file_ofs; + EditorProgress *ep; + }; + + struct ZipData { + + void* zip; + EditorProgress *ep; + + }; + + void _export_find_resources(EditorFileSystemDirectory *p_dir,Set<String>& p_paths); + void _export_find_dependencies(const String& p_path,Set<String>& p_paths); + + void gen_debug_flags(Vector<String> &r_flags, int p_flags); + static Error _save_pack_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total); + static Error _save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total); + + +protected: + + virtual void get_preset_features(const Ref<EditorExportPreset>& p_preset,List<String> *r_features)=0; + String find_export_template(String template_file_name, String *err=NULL) const; + +public: + + + struct ExportOption { + PropertyInfo option; + Variant default_value; + + ExportOption(const PropertyInfo& p_info,const Variant& p_default) { option=p_info; default_value=p_default; } + ExportOption() {} + }; + + virtual Ref<EditorExportPreset> create_preset(); + + virtual void get_export_options(List<ExportOption> *r_options)=0; + virtual String get_name() const =0; + virtual Ref<Texture> get_logo() const =0; + + + Error export_project_files(const Ref<EditorExportPreset>& p_preset,EditorExportSaveFunction p_func, void* p_udata); + + Error save_pack(const Ref<EditorExportPreset>& p_preset,const String& p_path); + Error save_zip(const Ref<EditorExportPreset>& p_preset,const String& p_path); + + + virtual bool poll_devices() { return false; } + virtual int get_device_count() const { return 0; } + virtual String get_device_name(int p_device) const { return ""; } + virtual String get_device_info(int p_device) const { return ""; } + + enum DebugFlags { + DEBUG_FLAG_DUMB_CLIENT=1, + DEBUG_FLAG_REMOTE_DEBUG=2, + DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST=4, + DEBUG_FLAG_VIEW_COLLISONS=8, + DEBUG_FLAG_VIEW_NAVIGATION=16, + }; + + virtual Error run(int p_device,int p_debug_flags) { return OK; } + + virtual bool can_export(const Ref<EditorExportPreset>& p_preset,String &r_error,bool &r_missing_templates) const=0; + + virtual String get_binary_extension() const=0; + virtual Error export_project(const Ref<EditorExportPreset>& p_preset,bool p_debug,const String& p_path,int p_flags=0)=0; + + EditorExportPlatform(); +}; + + +class EditorExport : public Node { + GDCLASS(EditorExport,Node); + + Vector<Ref<EditorExportPlatform> > export_platforms; + Vector<Ref<EditorExportPreset> > export_presets; + + Timer *save_timer; + bool block_save; + + static EditorExport *singleton; + + void _save(); +protected: + +friend class EditorExportPreset; + void save_presets(); + + void _notification(int p_what); + static void _bind_methods(); +public: + + static EditorExport * get_singleton() { return singleton; } + + void add_export_platform(const Ref<EditorExportPlatform>& p_platform); + int get_export_platform_count(); + Ref<EditorExportPlatform> get_export_platform(int p_idx); + + + void add_export_preset(const Ref<EditorExportPreset>& p_preset,int p_at_pos=-1); + int get_export_preset_count() const; + Ref<EditorExportPreset> get_export_preset(int p_idx); + void remove_export_preset(int p_idx); + + void load_config(); + + EditorExport(); + ~EditorExport(); +}; + + + + +class EditorExportPlatformPC : public EditorExportPlatform { + + GDCLASS( EditorExportPlatformPC,EditorExportPlatform ) + + Ref<ImageTexture> logo; + String name; + String extension; + + String release_file_32; + String release_file_64; + String debug_file_32; + String debug_file_64; + +public: + + virtual void get_preset_features(const Ref<EditorExportPreset>& p_preset,List<String>* r_features); + + virtual void get_export_options(List<ExportOption> *r_options); + + virtual String get_name() const; + virtual Ref<Texture> get_logo() const; + + virtual bool can_export(const Ref<EditorExportPreset>& p_preset,String &r_error,bool &r_missing_templates) const; + virtual String get_binary_extension() const; + virtual Error export_project(const Ref<EditorExportPreset>& p_preset,bool p_debug,const String& p_path,int p_flags=0); + + void set_extension(const String& p_extension); + void set_name(const String& p_name); + + void set_logo(const Ref<Texture>& p_loco); + + void set_release_64(const String& p_file); + void set_release_32(const String& p_file); + void set_debug_64(const String& p_file); + void set_debug_32(const String& p_file); + + EditorExportPlatformPC(); +}; + + +#endif // EDITOR_IMPORT_EXPORT_H diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp index b9b8345282..cd151cd90b 100644 --- a/tools/editor/editor_file_system.cpp +++ b/tools/editor/editor_file_system.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "editor_file_system.h" -#include "globals.h" +#include "global_config.h" #include "io/resource_loader.h" #include "os/os.h" #include "os/file_access.h" diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h deleted file mode 100644 index 2654a4ea33..0000000000 --- a/tools/editor/editor_import_export.h +++ /dev/null @@ -1,425 +0,0 @@ -/*************************************************************************/ -/* editor_import_export.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef EDITOR_IMPORT_EXPORT_H -#define EDITOR_IMPORT_EXPORT_H - -#if 0 - -#include "resource.h" -#include "scene/main/node.h" -#include "scene/resources/texture.h" - - -class EditorExportPlatform; -class FileAccess; -struct EditorProgress; - -class EditorImportPlugin : public Reference { - - GDCLASS( EditorImportPlugin, Reference); - -protected: - - static void _bind_methods(); - - String _validate_source_path(const String& p_path); - String _expand_source_path(const String& p_path); - - -public: - - - static String validate_source_path(const String& p_path); - static String expand_source_path(const String& p_path); - - virtual String get_name() const; - virtual String get_visible_name() const; - virtual void import_dialog(const String& p_from=""); - virtual Error import(const String& p_path, const Ref<ResourceImportMetadata>& p_from); - virtual void import_from_drop(const Vector<String>& p_drop,const String& p_dest_path); - virtual void reimport_multiple_files(const Vector<String>& p_list); - virtual bool can_reimport_multiple_files() const; - virtual Vector<uint8_t> custom_export(const String& p_path,const Ref<EditorExportPlatform> &p_platform); - - EditorImportPlugin(); -}; - -class EditorExportPlugin : public Reference { - - GDCLASS( EditorExportPlugin, Reference); - -protected: - static void _bind_methods(); - -public: - - virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform); - - EditorExportPlugin(); -}; - -class EditorExportPlatform : public Reference { - - GDCLASS( EditorExportPlatform,Reference ); - -public: - - typedef Error (*EditorExportSaveFunction)(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total); - -private: - - bool debugging_enabled; - -protected: - - bool _set(const StringName& p_name, const Variant& p_value); - bool _get(const StringName& p_name,Variant &r_ret) const; - void _get_property_list( List<PropertyInfo> *p_list) const; - - 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; - virtual String find_export_template(String template_file_name, String *err=NULL) const; - virtual bool exists_export_template(String template_file_name, String *err=NULL) const; - - struct TempData { - - uint64_t pos; - uint64_t ofs; - uint64_t size; - }; - - struct PackData { - - FileAccess *ftmp; - FileAccess *f; - Vector<TempData> file_ofs; - EditorProgress *ep; - int count; - int alignment; - - }; - - struct ZipData { - - void* zip; - EditorProgress *ep; - int count; - - }; - - void gen_export_flags(Vector<String> &r_flags, int p_flags); - static Error save_pack_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total); - static Error save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total); - -public: - - enum ImageCompression { - - IMAGE_COMPRESSION_NONE, - IMAGE_COMPRESSION_INDEXED, // used for older hardware - IMAGE_COMPRESSION_BC, // directx compression format - IMAGE_COMPRESSION_PVRTC, // powervr compression format - IMAGE_COMPRESSION_PVRTC_SQUARE, // powervr compression format, square (ios) - IMAGE_COMPRESSION_ETC1, // ericsson compression format (alpha is uncompressed) - IMAGE_COMPRESSION_ETC2, // ericsson new compression format (can handle alpha) - }; - - enum ExportFlags { - EXPORT_DUMB_CLIENT=1, - EXPORT_REMOTE_DEBUG=2, - EXPORT_REMOTE_DEBUG_LOCALHOST=4, - EXPORT_VIEW_COLLISONS=8, - EXPORT_VIEW_NAVIGATION=16, - }; - - bool is_debugging_enabled() const; - void set_debugging_enabled( bool p_enabled ); - - Error export_project_files(EditorExportSaveFunction p_func, void* p_udata,bool p_make_bundles); - - Error save_pack(FileAccess *p_where, bool p_make_bundles=false, int p_alignment = 1); - Error save_zip(const String& p_path, bool p_make_bundles=false); - - virtual String get_name() const =0; - virtual ImageCompression get_image_compression() const=0; - virtual Ref<Texture> get_logo() const =0; - - virtual bool poll_devices() { return false; } - virtual int get_device_count() const { return 0; } - virtual String get_device_name(int p_device) const { return ""; } - virtual String get_device_info(int p_device) const { return ""; } - virtual Error run(int p_device,int p_flags) { return OK; } - - virtual bool can_export(String *r_error=NULL) const=0; - - - virtual bool requires_password(bool p_debug) const { return false; } - virtual String get_binary_extension() const=0; - virtual Error export_project(const String& p_path,bool p_debug,int p_flags=0)=0; - - EditorExportPlatform(); -}; - -class EditorExportPlatformPC : public EditorExportPlatform { - - GDCLASS( EditorExportPlatformPC,EditorExportPlatform ); - -public: - - enum ExportMode { - EXPORT_EXE, - EXPORT_PACK, - EXPORT_ZIP - }; - - -private: - - - String binary_extension; - String platform; - - String custom_release_binary; - String custom_debug_binary; - String release_binary32; - String debug_binary32; - String release_binary64; - String debug_binary64; - String name; - bool use64; - - Ref<Texture> logo; - - ExportMode export_mode; - bool bundle; -protected: - - bool _set(const StringName& p_name, const Variant& p_value); - bool _get(const StringName& p_name,Variant &r_ret) const; - void _get_property_list( List<PropertyInfo> *p_list) const; - -public: - - virtual String get_name() const { return name; } - virtual Ref<Texture> get_logo() const { return logo; } - virtual ImageCompression get_image_compression() const { return IMAGE_COMPRESSION_BC; } - - virtual String get_binary_extension() const { return binary_extension; } - virtual Error export_project(const String& p_path, bool p_debug, int p_flags=0); - virtual void set_release_binary32(const String& p_binary) { release_binary32=p_binary; } - virtual void set_debug_binary32(const String& p_binary) { debug_binary32=p_binary; } - virtual void set_release_binary64(const String& p_binary) { release_binary64=p_binary; } - virtual void set_debug_binary64(const String& p_binary) { debug_binary64=p_binary; } - virtual void set_name(const String& p_name) { name=p_name; } - virtual void set_logo(const Ref<Texture>& p_logo) { logo=p_logo; } - - virtual bool can_export(String *r_error=NULL) const; - - void set_binary_extension(const String& p_extension); - - EditorExportPlatformPC(); -}; - - -class EditorImportExport : public Node { - GDCLASS(EditorImportExport,Node); -public: - - enum FileAction { - - ACTION_NONE, - ACTION_COPY, - ACTION_BUNDLE - }; - - enum ExportFilter { - EXPORT_SELECTED, - EXPORT_RESOURCES, - EXPORT_ALL, - - }; - - enum ImageAction { - IMAGE_ACTION_NONE, - IMAGE_ACTION_COMPRESS_DISK, - IMAGE_ACTION_COMPRESS_RAM, - IMAGE_ACTION_KEEP //for group - - }; - - enum ScriptAction { - SCRIPT_ACTION_NONE, - SCRIPT_ACTION_COMPILE, - SCRIPT_ACTION_ENCRYPT - }; - - enum SampleAction { - - SAMPLE_ACTION_NONE, - SAMPLE_ACTION_COMPRESS_RAM, - }; - -protected: - - struct ImageGroup { - - ImageAction action; - bool make_atlas; - float lossy_quality; - float shrink; - }; - - Vector<Ref<EditorExportPlugin> > export_plugins; - Vector<Ref<EditorImportPlugin> > plugins; - Map<String,int> by_idx; - ImageAction image_action; - float image_action_compress_quality; - float image_shrink; - Set<String> image_formats; - - ExportFilter export_filter; - String export_custom_filter, export_custom_filter_exclude; - Map<StringName,FileAction> files; - Map<StringName,Ref<EditorExportPlatform> > exporters; - Map<StringName,ImageGroup> image_groups; - Map<StringName,StringName> image_group_files; - Vector<String> diff_packs; - - ScriptAction script_action; - String script_key; - - SampleAction sample_action; - int sample_action_max_hz; - bool sample_action_trim; - - bool convert_text_scenes; - - static EditorImportExport* singleton; - - PoolVector<String> _get_export_file_list(); - PoolVector<String> _get_export_platforms(); - - static void _bind_methods(); -public: - - static EditorImportExport* get_singleton() { return singleton; } - - void add_import_plugin(const Ref<EditorImportPlugin>& p_plugin); - void remove_import_plugin(const Ref<EditorImportPlugin>& p_plugin); - int get_import_plugin_count() const; - Ref<EditorImportPlugin> get_import_plugin(int p_idx) const; - Ref<EditorImportPlugin> get_import_plugin_by_name(const String& p_string) const; - - void add_export_plugin(const Ref<EditorExportPlugin>& p_plugin); - void remove_export_plugin(const Ref<EditorExportPlugin>& p_plugin); - int get_export_plugin_count() const; - Ref<EditorExportPlugin> get_export_plugin(int p_idx) const; - - bool poll_export_platforms(); - - void set_export_file_action(const StringName& p_export_file, FileAction p_action); - FileAction get_export_file_action(const StringName& p_export_file) const; - void get_export_file_list(List<StringName> *p_export_files); - - void add_export_platform(const Ref<EditorExportPlatform>& p_export); - Ref<EditorExportPlatform> get_export_platform(const StringName& p_platform); - void get_export_platforms(List<StringName> *r_platforms); - - void set_export_filter(ExportFilter p_enable); - ExportFilter get_export_filter() const; - - void set_export_custom_filter(const String& p_custom_filter); - void set_export_custom_filter_exclude(const String& p_custom_filter); - String get_export_custom_filter() const; - String get_export_custom_filter_exclude() const; - - void set_export_image_action(ImageAction p_action); - ImageAction get_export_image_action() const; - - void set_export_image_shrink(float p_shrink); - float get_export_image_shrink() const; - - void set_export_image_quality(float p_quality); - float get_export_image_quality() const; - - Vector<String>& get_diff_packs() { return diff_packs; } - - void image_export_group_create(const StringName& p_name); - void image_export_group_remove(const StringName& p_name); - bool image_export_has_group(const StringName& p_name) const; - void image_export_get_groups(List<StringName> *r_name) const; - void image_export_group_set_image_action(const StringName& p_export_group,ImageAction p_action); - ImageAction image_export_group_get_image_action(const StringName& p_export_group) const; - void image_export_group_set_make_atlas(const StringName& p_export_group,bool p_make); - bool image_export_group_get_make_atlas(const StringName& p_export_group) const; - void image_export_group_set_shrink(const StringName& p_export_group,float p_amount); - float image_export_group_get_shrink(const StringName& p_export_group) const; - void image_export_group_set_lossy_quality(const StringName& p_export_group,float p_quality); - float image_export_group_get_lossy_quality(const StringName& p_export_group) const; - - void image_add_to_export_group(const StringName& p_image,const StringName& p_export_group); - StringName image_get_export_group(const StringName& p_image) const; - void image_export_get_images_in_group(const StringName& p_group, List<StringName> *r_images) const; - - Set<String>& get_image_formats() { return image_formats; } - - void script_set_action(ScriptAction p_action); - ScriptAction script_get_action() const; - - void script_set_encryption_key(const String& p_key); - String script_get_encryption_key() const; - - void sample_set_action(SampleAction p_action); - SampleAction sample_get_action() const; - - void sample_set_max_hz(int p_hz); - int sample_get_max_hz() const; - - void sample_set_trim(bool p_trim); - bool sample_get_trim() const; - - void set_convert_text_scenes(bool p_convert); - bool get_convert_text_scenes() const; - - void load_config(); - void save_config(); - - EditorImportExport(); - ~EditorImportExport(); -}; - -VARIANT_ENUM_CAST(EditorImportExport::FileAction); -VARIANT_ENUM_CAST(EditorImportExport::ExportFilter); -VARIANT_ENUM_CAST(EditorImportExport::ImageAction); -VARIANT_ENUM_CAST(EditorImportExport::ScriptAction); -VARIANT_ENUM_CAST(EditorImportExport::SampleAction); - -#endif -#endif // EDITOR_IMPORT_EXPORT_H diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index da9138e5d9..5e2d6e7d6b 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -37,7 +37,7 @@ #include "servers/physics_2d_server.h" #include "scene/resources/packed_scene.h" #include "editor_settings.h" -#include "globals.h" +#include "global_config.h" #include <stdio.h> #include "class_db.h" #include "os/keyboard.h" @@ -2209,25 +2209,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { case FILE_EXPORT_PROJECT: { - //project_export_settings->popup_export(); - /* - String target = export_db->get_current_platform(); - Ref<EditorExporter> exporter = export_db->get_exporter(target); - if (exporter.is_null()) { - accept->set_text("No exporter for platform '"+target+"' yet."); - accept->popup_centered(Size2(300,70)); - return; - } - - String extension = exporter->get_binary_extension(); - print_line("for target: "+target+" extension: "+extension); - file_export_password->set_editable( exporter->requieres_password(file_export_check->is_pressed())); - - file_export->clear_filters(); - if (extension!="") { - file_export->add_filter("*."+extension); - } - file_export->popup_centered_ratio();*/ + project_export->popup_export(); } break; case FILE_EXPORT_MESH_LIBRARY: { @@ -5236,6 +5218,9 @@ EditorNode::EditorNode() { EditorFileDialog::register_func=_editor_file_dialog_register; EditorFileDialog::unregister_func=_editor_file_dialog_unregister; + editor_export = memnew( EditorExport ); + add_child(editor_export); + register_exporters(); @@ -6156,8 +6141,8 @@ EditorNode::EditorNode() { //gui_base->add_child(optimized_save); //optimized_save->connect("confirmed",this,"_save_optimized"); - //project_export = memnew( ProjectExport(&editor_data) ); - //gui_base->add_child(project_export); + project_export = memnew( ProjectExportDialog ); + gui_base->add_child(project_export); //project_export_settings = memnew( ProjectExportDialog(this) ); //gui_base->add_child(project_export_settings); @@ -6302,6 +6287,7 @@ EditorNode::EditorNode() { + add_editor_plugin( memnew( AnimationPlayerEditorPlugin(this) ) ); add_editor_plugin( memnew( CanvasItemEditorPlugin(this) ) ); add_editor_plugin( memnew( SpatialEditorPlugin(this) ) ); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 7ac2760a5c..41c1012ff0 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -73,7 +73,7 @@ #include "tools/editor/quick_open.h" #include "tools/editor/project_export.h" #include "tools/editor/editor_sub_scene.h" -#include "editor_import_export.h" +#include "editor_export.h" #include "editor_reimport_dialog.h" #include "tools/editor/editor_plugin.h" #include "tools/editor/editor_name_dialog.h" @@ -365,7 +365,7 @@ private: String _tmp_import_path; - EditorImportExport *editor_import_export; + EditorExport *editor_export; Object *current; @@ -395,7 +395,7 @@ private: EditorRun editor_run; EditorSelection *editor_selection; // ProjectExport *project_export; -// ProjectExportDialog *project_export_settings; + ProjectExportDialog *project_export; EditorResourcePreview *resource_preview; EditorFileServer *file_server; diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h index cf998dd55b..13d8ab0343 100644 --- a/tools/editor/editor_plugin.h +++ b/tools/editor/editor_plugin.h @@ -43,7 +43,7 @@ class EditorNode; class Spatial; class Camera; class EditorSelection; -class EditorImportExport; +class EditorExport; class EditorSettings; class SpatialEditorGizmo; class EditorImportPlugin; diff --git a/tools/editor/editor_plugin_settings.cpp b/tools/editor/editor_plugin_settings.cpp index 2b6828e82f..2d879e38cf 100644 --- a/tools/editor/editor_plugin_settings.cpp +++ b/tools/editor/editor_plugin_settings.cpp @@ -32,7 +32,7 @@ #include "io/config_file.h" #include "os/file_access.h" #include "os/main_loop.h" -#include "globals.h" +#include "global_config.h" #include "editor_node.h" void EditorPluginSettings::_notification(int p_what) { diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp index b6cf24e527..ab2226e79a 100644 --- a/tools/editor/editor_resource_preview.cpp +++ b/tools/editor/editor_resource_preview.cpp @@ -32,7 +32,7 @@ #include "os/file_access.h" #include "io/resource_loader.h" #include "io/resource_saver.h" -#include "globals.h" +#include "global_config.h" #include "editor_scale.h" #include "message_queue.h" diff --git a/tools/editor/editor_run.cpp b/tools/editor/editor_run.cpp index 813a8ee5b7..a5d39db6be 100644 --- a/tools/editor/editor_run.cpp +++ b/tools/editor/editor_run.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "editor_run.h" -#include "globals.h" +#include "global_config.h" #include "editor_settings.h" EditorRun::Status EditorRun::get_status() const { diff --git a/tools/editor/editor_run_native.cpp b/tools/editor/editor_run_native.cpp index 25cb41befc..60a9f53b94 100644 --- a/tools/editor/editor_run_native.cpp +++ b/tools/editor/editor_run_native.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "editor_run_native.h" -#include "editor_import_export.h" +#include "editor_export.h" void EditorRunNative::_notification(int p_what) { diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 2e32cfe38b..f977a40243 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -39,7 +39,7 @@ #include "scene/main/viewport.h" #include "io/config_file.h" #include "editor_node.h" -#include "globals.h" +#include "global_config.h" #include "translations.h" #include "io/file_access_memory.h" #include "io/translation_loader_po.h" diff --git a/tools/editor/file_type_cache.cpp b/tools/editor/file_type_cache.cpp index aff99fbc05..891669db13 100644 --- a/tools/editor/file_type_cache.cpp +++ b/tools/editor/file_type_cache.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "file_type_cache.h" -#include "globals.h" +#include "global_config.h" #include "os/file_access.h" FileTypeCache* FileTypeCache::singleton=NULL; diff --git a/tools/editor/filesystem_dock.cpp b/tools/editor/filesystem_dock.cpp index c6c1a02f3f..f5e4ef661a 100644 --- a/tools/editor/filesystem_dock.cpp +++ b/tools/editor/filesystem_dock.cpp @@ -30,7 +30,7 @@ #include "os/dir_access.h" #include "os/file_access.h" -#include "globals.h" +#include "global_config.h" #include "io/resource_loader.h" #include "os/os.h" #include "editor_node.h" diff --git a/tools/editor/io_plugins/editor_export_scene.cpp b/tools/editor/io_plugins/editor_export_scene.cpp index f4ab9880ff..265526aace 100644 --- a/tools/editor/io_plugins/editor_export_scene.cpp +++ b/tools/editor/io_plugins/editor_export_scene.cpp @@ -34,7 +34,7 @@ #include "os/file_access.h" #include "tools/editor/editor_settings.h" #include "scene/resources/packed_scene.h" -#include "globals.h" +#include "global_config.h" Vector<uint8_t> EditorSceneExportPlugin::custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) { diff --git a/tools/editor/io_plugins/editor_export_scene.h b/tools/editor/io_plugins/editor_export_scene.h index 191029bd84..c067e835a3 100644 --- a/tools/editor/io_plugins/editor_export_scene.h +++ b/tools/editor/io_plugins/editor_export_scene.h @@ -29,7 +29,7 @@ #ifndef EDITOR_EXPORT_SCENE_H #define EDITOR_EXPORT_SCENE_H -#include "tools/editor/editor_import_export.h" +#include "tools/editor/editor_export.h" #if 0 class EditorSceneExportPlugin : public EditorExportPlugin { diff --git a/tools/editor/io_plugins/editor_font_import_plugin.h b/tools/editor/io_plugins/editor_font_import_plugin.h index a5b265736f..bed1463aeb 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.h +++ b/tools/editor/io_plugins/editor_font_import_plugin.h @@ -29,7 +29,7 @@ #ifndef EDITOR_FONT_IMPORT_PLUGIN_H #define EDITOR_FONT_IMPORT_PLUGIN_H -#include "tools/editor/editor_import_export.h" +#include "tools/editor/editor_export.h" #include "scene/resources/font.h" #if 0 class EditorNode; diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index bffccb9072..957072c20a 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "editor_scene_import_plugin.h" #if 0 -#include "globals.h" +#include "global_config.h" #include "tools/editor/editor_node.h" #include "scene/resources/packed_scene.h" #include "scene/resources/box_shape.h" diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index c41199f291..cc8d47c6a9 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -35,7 +35,7 @@ #include "tools/editor/editor_settings.h" #include "io/md5.h" #include "io/marshalls.h" -#include "globals.h" +#include "global_config.h" #include "scene/gui/check_button.h" #include "scene/gui/button_group.h" #include "scene/gui/margin_container.h" diff --git a/tools/editor/io_plugins/editor_translation_import_plugin.h b/tools/editor/io_plugins/editor_translation_import_plugin.h index 4884ea71c5..22065599b9 100644 --- a/tools/editor/io_plugins/editor_translation_import_plugin.h +++ b/tools/editor/io_plugins/editor_translation_import_plugin.h @@ -29,7 +29,7 @@ #ifndef EDITOR_TRANSLATION_IMPORT_PLUGIN_H #define EDITOR_TRANSLATION_IMPORT_PLUGIN_H -#include "tools/editor/editor_import_export.h" +#include "tools/editor/editor_export.h" #include "scene/resources/font.h" #if 0 class EditorNode; diff --git a/tools/editor/multi_node_edit.cpp b/tools/editor/multi_node_edit.cpp index 97a996fe48..27bb6d66fc 100644 --- a/tools/editor/multi_node_edit.cpp +++ b/tools/editor/multi_node_edit.cpp @@ -38,8 +38,8 @@ bool MultiNodeEdit::_set(const StringName& p_name, const Variant& p_value){ String name = p_name; - if (name=="scripts/script") { // script/script set is intercepted at object level (check Variant Object::get() ) ,so use a different name - name="script/script"; + if (name=="scripts") { // script set is intercepted at object level (check Variant Object::get() ) ,so use a different name + name="script"; } UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); @@ -80,8 +80,8 @@ bool MultiNodeEdit::_get(const StringName& p_name,Variant &r_ret) const { return false; String name=p_name; - if (name=="scripts/script") { // script/script set is intercepted at object level (check Variant Object::get() ) ,so use a different name - name="script/script"; + if (name=="scripts") { // script set is intercepted at object level (check Variant Object::get() ) ,so use a different name + name="script"; } for (const List<NodePath>::Element *E=nodes.front();E;E=E->next()) { @@ -129,7 +129,7 @@ void MultiNodeEdit::_get_property_list( List<PropertyInfo> *p_list) const{ for(List<PropertyInfo>::Element *F=plist.front();F;F=F->next()) { - if (F->get().name=="script/script") + if (F->get().name=="script") continue; //added later manually, since this is intercepted before being set (check Variant Object::get() ) if (!usage.has(F->get().name)) { PLData pld; @@ -152,7 +152,7 @@ void MultiNodeEdit::_get_property_list( List<PropertyInfo> *p_list) const{ } } - p_list->push_back(PropertyInfo(Variant::OBJECT,"scripts/script",PROPERTY_HINT_RESOURCE_TYPE,"Script")); + p_list->push_back(PropertyInfo(Variant::OBJECT,"scripts",PROPERTY_HINT_RESOURCE_TYPE,"Script")); } diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp index 7d6598bd4b..71173038e9 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.cpp +++ b/tools/editor/plugins/animation_player_editor_plugin.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "animation_player_editor_plugin.h" -#include "globals.h" +#include "global_config.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/keyboard.h" diff --git a/tools/editor/plugins/animation_tree_editor_plugin.cpp b/tools/editor/plugins/animation_tree_editor_plugin.cpp index 1ed52d2df6..988136d475 100644 --- a/tools/editor/plugins/animation_tree_editor_plugin.cpp +++ b/tools/editor/plugins/animation_tree_editor_plugin.cpp @@ -32,7 +32,7 @@ #include "scene/gui/panel.h" #include "scene/main/viewport.h" #include "core/io/resource_loader.h" -#include "core/globals.h" +#include "core/global_config.h" #include "os/input.h" #include "os/keyboard.h" diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp index 52220839d9..4219e791d1 100644 --- a/tools/editor/plugins/baked_light_baker.cpp +++ b/tools/editor/plugins/baked_light_baker.cpp @@ -1334,7 +1334,7 @@ void BakedLightBaker::_make_octree_texture() { base<<=16; base|=int((pos.z+cell_size*0.5)/cell_size); - uint32_t hash = HashMapHahserDefault::hash(base); + uint32_t hash = HashMapHasherDefault::hash(base); uint32_t idx = hash % hash_table_size; octhashptr[oct_idx].next=hashptr[idx]; octhashptr[oct_idx].hash=hash; @@ -1362,7 +1362,7 @@ void BakedLightBaker::_make_octree_texture() { base<<=16; base|=int((pos.z+cell_size*0.5)/cell_size); - uint32_t hash = HashMapHahserDefault::hash(base); + uint32_t hash = HashMapHasherDefault::hash(base); uint32_t idx = hash % hash_table_size; uint32_t bucket = hashptr[idx]; diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 0830556ac1..8af925db7a 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -38,7 +38,7 @@ #include "scene/2d/particles_2d.h" #include "scene/2d/polygon_2d.h" #include "scene/2d/screen_button.h" -#include "globals.h" +#include "global_config.h" #include "os/input.h" #include "tools/editor/editor_settings.h" #include "scene/gui/grid_container.h" diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.cpp b/tools/editor/plugins/resource_preloader_editor_plugin.cpp index cfdfbdc1c6..de2245d98f 100644 --- a/tools/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/tools/editor/plugins/resource_preloader_editor_plugin.cpp @@ -29,7 +29,7 @@ #include "resource_preloader_editor_plugin.h" #include "io/resource_loader.h" -#include "globals.h" +#include "global_config.h" #include "tools/editor/editor_settings.h" diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp index cb60134c2c..9445095771 100644 --- a/tools/editor/plugins/sample_editor_plugin.cpp +++ b/tools/editor/plugins/sample_editor_plugin.cpp @@ -30,7 +30,7 @@ #if 0 #include "io/resource_loader.h" -#include "globals.h" +#include "global_config.h" #include "tools/editor/editor_settings.h" diff --git a/tools/editor/plugins/sample_library_editor_plugin.cpp b/tools/editor/plugins/sample_library_editor_plugin.cpp index d0ff33c881..b996cafd1f 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.cpp +++ b/tools/editor/plugins/sample_library_editor_plugin.cpp @@ -31,7 +31,7 @@ #include "sample_library_editor_plugin.h" #include "io/resource_loader.h" -#include "globals.h" +#include "global_config.h" #include "tools/editor/editor_settings.h" #include "scene/main/viewport.h" #include "sample_editor_plugin.h" diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 0a880de35b..b7d8cc2ba9 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -35,7 +35,7 @@ #include "os/os.h" #include "tools/editor/editor_node.h" #include "tools/editor/script_editor_debugger.h" -#include "globals.h" +#include "global_config.h" #include "os/file_access.h" #include "scene/main/viewport.h" #include "os/keyboard.h" diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 5e425ef3c4..ef971034cd 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -38,7 +38,7 @@ #include "tools/editor/editor_settings.h" #include "scene/resources/surface_tool.h" #include "tools/editor/spatial_editor_gizmos.h" -#include "globals.h" +#include "global_config.h" #include "tools/editor/plugins/animation_player_editor_plugin.h" #include "tools/editor/animation_editor.h" diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.cpp b/tools/editor/plugins/sprite_frames_editor_plugin.cpp index 48808d9e04..c3c68e471e 100644 --- a/tools/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/tools/editor/plugins/sprite_frames_editor_plugin.cpp @@ -29,7 +29,7 @@ #include "sprite_frames_editor_plugin.h" #include "io/resource_loader.h" -#include "globals.h" +#include "global_config.h" #include "tools/editor/editor_settings.h" #include "scene/3d/sprite_3d.h" diff --git a/tools/editor/plugins/texture_editor_plugin.cpp b/tools/editor/plugins/texture_editor_plugin.cpp index 1bfc05e2a7..90a798667f 100644 --- a/tools/editor/plugins/texture_editor_plugin.cpp +++ b/tools/editor/plugins/texture_editor_plugin.cpp @@ -29,7 +29,7 @@ #include "texture_editor_plugin.h" #include "io/resource_loader.h" -#include "globals.h" +#include "global_config.h" #include "tools/editor/editor_settings.h" void TextureEditor::_gui_input(InputEvent p_event) { diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index c760e45025..f6593a4895 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -27,16 +27,16 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "project_export.h" -#if 0 #include "os/dir_access.h" #include "os/file_access.h" -#include "globals.h" +#include "global_config.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/os.h" #include "scene/gui/box_container.h" #include "scene/gui/tab_container.h" #include "scene/gui/scroll_container.h" +#include "scene/gui/margin_container.h" #include "editor_data.h" #include "io/image_loader.h" #include "compressed_translation.h" @@ -44,2087 +44,772 @@ #include "io_plugins/editor_texture_import_plugin.h" #include "editor_settings.h" -const char *ProjectExportDialog::da_string[ProjectExportDialog::ACTION_MAX]={ - "", - "Copy", - "Bundle" -}; - -bool ProjectExportDialog::_create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_dir) { - - TreeItem *item = tree->create_item(p_parent); - item->set_text(0,p_dir->get_name()+"/"); - item->set_icon(0,get_icon("Folder","EditorIcons")); - - - bool has_items=false; - - for(int i=0;i<p_dir->get_subdir_count();i++) { - - if (_create_tree(item,p_dir->get_subdir(i))) - has_items=true; - } - - //int cc = p_options.get_slice_count(","); - - for (int i=0;i<p_dir->get_file_count();i++) { - - TreeItem *fitem = tree->create_item(item); - //fitem->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); - //fitem->set_editable(0,true); - //fitem->set_checked(0,isfave); - fitem->set_text(0,p_dir->get_file(i)); - String path = p_dir->get_file_path(i); - fitem->set_tooltip(0,path); - fitem->set_metadata(0,path); - Ref<Texture> 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); - fitem->set_range_config(1,0,2,1); - fitem->set_text(1,expopt); - fitem->set_editable(1,true); - - EditorImportExport::FileAction fa = EditorImportExport::get_singleton()->get_export_file_action(path); - fitem->set_range(1,fa); - - has_items=true; - - } - - if (!has_items) { +void ProjectExportDialog::_notification(int p_what) { - memdelete(item); - return false; + if (p_what==NOTIFICATION_READY) { + delete_preset->set_icon(get_icon("Del","EditorIcons")); + connect("confirmed",this,"_export_pck_zip"); } - - return true; } -void ProjectExportDialog::_tree_changed() { - - TreeItem *t=tree->get_selected(); - if (!t) - return; - - String selected = t->get_metadata(0); - - EditorImportExport::get_singleton()->set_export_file_action(selected,EditorImportExport::FileAction(int(t->get_range(1)))); - _save_export_cfg(); - - //editor->save_import_export(true); - //EditorImportDB::get_singleton()->save_settings(); - -} - void ProjectExportDialog::popup_export() { - popup_centered_ratio(); - if (pending_update_tree) { - _update_tree(); - _update_group_tree(); - pending_update_tree=false; - } -} -void ProjectExportDialog::_update_tree() { + add_preset->get_popup()->clear(); + for(int i=0;i<EditorExport::get_singleton()->get_export_platform_count();i++) { + Ref<EditorExportPlatform> plat = EditorExport::get_singleton()->get_export_platform(i); + add_preset->get_popup()->add_icon_item(plat->get_logo(),plat->get_name()); - updating_tree=true; - tree->clear(); - EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem(); - - if (efsd) { - _create_tree(NULL,efsd); } - updating_tree=false; + _update_presets(); + popup_centered_ratio(); } +void ProjectExportDialog::_add_preset(int p_platform) { + Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_platform(p_platform)->create_preset(); + ERR_FAIL_COND(!preset.is_valid()); + String name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name(); + bool make_runnable=true; + int attempt=1; + while(true) { -void ProjectExportDialog::_update_platform() { - - _validate_platform(); - TreeItem *selected = platforms->get_selected(); - if (!selected) - return; - - String platform = selected->get_metadata(0); - Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(platform); - platform_options->edit( exporter.ptr() ); -} - -void ProjectExportDialog::_platform_selected() { + bool valid=true; - String p =platforms->get_selected()->get_metadata(0); - _update_platform(); - //editor->save_import_export(); - //EditorFileSystem::get_singleton()->scan(); + for(int i=0;i<EditorExport::get_singleton()->get_export_preset_count();i++) { + Ref<EditorExportPreset> p = EditorExport::get_singleton()->get_export_preset(i); + if (p->get_platform()==preset->get_platform() && p->is_runnable()) { + make_runnable=false; + } + if (p->get_name()==name) { + valid=false; + break; + } -} + } -void ProjectExportDialog::_scan_finished() { + if (valid) + break; -/* print_line("**********SCAN DONEEE********"); - print_line("**********SCAN DONEEE********"); - print_line("**********SCAN DONEEE********"); - print_line("**********SCAN DONEEE********");*/ + attempt++; + name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name()+" "+itos(attempt); - if (!is_visible_in_tree()) { - pending_update_tree=true; - return; } - _update_tree(); - _update_group_tree(); -} - -void ProjectExportDialog::_rescan() { - - EditorFileSystem::get_singleton()->scan(); - -} - -void ProjectExportDialog::_update_exporter() { - - -} - - -void ProjectExportDialog::_save_export_cfg() { - - EditorImportExport::get_singleton()->save_config(); -} - -void ProjectExportDialog::_prop_edited(String what) { - - _save_export_cfg(); - - _validate_platform(); + preset->set_name(name); + if (make_runnable) + preset->set_runnable(make_runnable); + EditorExport::get_singleton()->add_export_preset(preset); + _update_presets(); + _edit_preset(EditorExport::get_singleton()->get_export_preset_count()-1); } -void ProjectExportDialog::_filters_edited(String what) { - EditorImportExport::get_singleton()->set_export_custom_filter(what); - _save_export_cfg(); -} +void ProjectExportDialog::_update_presets() { -void ProjectExportDialog::_filters_exclude_edited(String what) { - EditorImportExport::get_singleton()->set_export_custom_filter_exclude(what); - _save_export_cfg(); -} - -void ProjectExportDialog::_quality_edited(float what) { - - EditorImportExport::get_singleton()->set_export_image_quality(what); - _save_export_cfg(); -} - -void ProjectExportDialog::_shrink_edited(float what) { - - EditorImportExport::get_singleton()->set_export_image_shrink(what); - _save_export_cfg(); -} - -void ProjectExportDialog::_image_export_edited(int what) { - - EditorImportExport::get_singleton()->set_export_image_action(EditorImportExport::ImageAction(what)); - _save_export_cfg(); -} - -void ProjectExportDialog::_format_toggled() { + updating=true; - EditorImportExport::get_singleton()->get_image_formats().clear(); + Ref<EditorExportPreset> current; + if (presets->get_current()>=0 && presets->get_current()<presets->get_item_count()) + current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); - for(int i=0;i<formats.size();i++) { - if (formats[i]->is_checked(0)) - EditorImportExport::get_singleton()->get_image_formats().insert( formats[i]->get_text(0)); + int current_idx=-1; + presets->clear(); + for(int i=0;i<EditorExport::get_singleton()->get_export_preset_count();i++) { + Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(i); + if (preset==current) { + current_idx=i; + } + String name = preset->get_name(); + if (preset->is_runnable()) + name+=" ("+TTR("Runnable")+")"; + presets->add_item(name,preset->get_platform()->get_logo()); } - _save_export_cfg(); -} - - -void ProjectExportDialog::_script_edited(Variant v) { - if (updating_script) - return; - updating_script=true; - EditorNode::get_undo_redo()->create_action(TTR("Edit Script Options")); - EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"script_set_action",script_mode->get_selected()); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"script_set_action",EditorImportExport::get_singleton()->script_get_action()); - EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"script_set_encryption_key",script_key->get_text()); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"script_set_encryption_key",EditorImportExport::get_singleton()->script_get_encryption_key()); - EditorNode::get_undo_redo()->add_do_method(this,"_update_script"); - EditorNode::get_undo_redo()->add_undo_method(this,"_update_script"); - EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg"); - EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg"); - EditorNode::get_undo_redo()->commit_action(); - updating_script=false; - - -} + if (current_idx!=-1) { + presets->select(current_idx); + //_edit_preset(current_idx); + } -void ProjectExportDialog::_sample_convert_edited(int what) { - EditorImportExport::get_singleton()->sample_set_action( EditorImportExport::SampleAction(sample_mode->get_selected())); - EditorImportExport::get_singleton()->sample_set_max_hz( sample_max_hz->get_value() ); - EditorImportExport::get_singleton()->sample_set_trim( sample_trim->is_pressed() ); - _save_export_cfg(); + updating=false; } -void ProjectExportDialog::_notification(int p_what) { - - switch(p_what) { +void ProjectExportDialog::_edit_preset(int p_index) { - case NOTIFICATION_ENTER_TREE: { - - - CenterContainer *cc = memnew( CenterContainer ); - TextureRect *tf = memnew( TextureRect); - tf->set_texture(get_icon("ErrorSign","EditorIcons")); - cc->add_child(tf); - plat_errors->add_child(cc); - platform_error_string->raise(); + if (p_index<0 || p_index>=presets->get_item_count()) { + name->set_text(""); + name->set_editable(false); + runnable->set_disabled(true); + parameters->edit(NULL); + delete_preset->set_disabled(true); + sections->hide(); + patches->clear(); + return; + } - TreeItem *root = platforms->create_item(NULL); - List<StringName> ep; - EditorImportExport::get_singleton()->get_export_platforms(&ep); - ep.sort_custom<StringName::AlphCompare>(); - for(List<StringName>::Element *E=ep.front();E;E=E->next()) { + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(p_index); + ERR_FAIL_COND(current.is_null()); - Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(E->get()); - TreeItem *p = platforms->create_item(root); - p->set_text(0,eep->get_name()); - p->set_icon(0,eep->get_logo()); - p->set_metadata(0,eep->get_name()); - if (eep->get_name()==OS::get_singleton()->get_name()) - p->select(0); + updating=true; - } + presets->select(p_index); + sections->show(); + + name->set_editable(true); + delete_preset->set_disabled(false); + name->set_text(current->get_name()); + runnable->set_disabled(false); + runnable->set_pressed(current->is_runnable()); + parameters->edit(current.ptr()); + + export_filter->select(current->get_export_filter()); + include_filters->set_text(current->get_include_filter()); + exclude_filters->set_text(current->get_exclude_filter()); + + + patches->clear(); + TreeItem *patch_root = patches->create_item(); + Vector<String> patchlist = current->get_patches(); + for(int i=0;i<patchlist.size();i++) { + TreeItem *patch = patches->create_item(patch_root); + patch->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); + String file = patchlist[i].get_file(); + patch->set_editable(0,true); + patch->set_text(0,file.get_file().replace("*","")); + if (file.ends_with("*")) + patch->set_checked(0,true); + patch->set_tooltip(0,patchlist[i]); + patch->set_metadata(0,i); + patch->add_button(0,get_icon("Del","EditorIcons"),0); + patch->add_button(0,get_icon("folder","FileDialog"),1); + } + + TreeItem *patch_add = patches->create_item(patch_root); + patch_add->set_metadata(0,patchlist.size()); + if (patchlist.size()==0) + patch_add->set_text(0,"Add initial export.."); + else + patch_add->set_text(0,"Add previous patches.."); - EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"_scan_finished"); - //_rescan(); - _update_platform(); - export_mode->select( EditorImportExport::get_singleton()->get_export_filter() ); - convert_text_scenes->set_pressed( EditorImportExport::get_singleton()->get_convert_text_scenes() ); - filters->set_text( EditorImportExport::get_singleton()->get_export_custom_filter() ); - filters_exclude->set_text( EditorImportExport::get_singleton()->get_export_custom_filter_exclude() ); - if (EditorImportExport::get_singleton()->get_export_filter()!=EditorImportExport::EXPORT_SELECTED) - tree_vb->hide(); - else - tree_vb->show(); - - image_action->select(EditorImportExport::get_singleton()->get_export_image_action()); - image_quality->set_value(EditorImportExport::get_singleton()->get_export_image_quality()); - image_shrink->set_value(EditorImportExport::get_singleton()->get_export_image_shrink()); - _update_script(); - - - image_quality->connect("value_changed",this,"_quality_edited"); - image_shrink->connect("value_changed",this,"_shrink_edited"); - image_action->connect("item_selected",this,"_image_export_edited"); - - script_mode->connect("item_selected",this,"_script_edited"); - script_key->connect("text_changed",this,"_script_edited"); - - for(int i=0;i<formats.size();i++) { - if (EditorImportExport::get_singleton()->get_image_formats().has(formats[i]->get_text(0))) - formats[i]->set_checked(0,true); - } - image_formats->connect("item_edited",this,"_format_toggled"); - group_add->set_icon(get_icon("Add","EditorIcons")); - //group_del->set_icon(get_icon("Del","EditorIcons")); + patch_add->add_button(0,get_icon("folder","FileDialog"),1); - _update_group_list(); - _update_group(); - _update_group_tree(); + _fill_resource_tree(); - sample_mode->select( EditorImportExport::get_singleton()->sample_get_action() ); - sample_max_hz->set_value( EditorImportExport::get_singleton()->sample_get_max_hz() ); - sample_trim->set_pressed( EditorImportExport::get_singleton()->sample_get_trim() ); + updating=false; - sample_mode->connect("item_selected",this,"_sample_convert_edited"); - sample_max_hz->connect("value_changed",this,"_sample_convert_edited"); - sample_trim->connect("toggled",this,"_sample_convert_edited"); +} +void ProjectExportDialog::_patch_button_pressed(Object* p_item,int p_column,int p_id) { - } break; - case NOTIFICATION_EXIT_TREE: { - } break; - case MainLoop::NOTIFICATION_WM_FOCUS_IN: { - //something may have changed - _validate_platform(); + TreeItem *ti = (TreeItem*)p_item; - } break; - case NOTIFICATION_VISIBILITY_CHANGED: { - if (is_visible_in_tree()) - _validate_platform(); + patch_index=ti->get_metadata(0); - } break; - case NOTIFICATION_PROCESS: { + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + ERR_FAIL_COND(current.is_null()); - } break; + if (p_id==0) { + Vector<String> patches = current->get_patches(); + ERR_FAIL_INDEX(patch_index,patches.size()); + patch_erase->set_text(vformat(TTR("Delete patch '"+patches[patch_index].get_file()+"' from list?"))); + patch_erase->popup_centered_minsize(); + } else { + patch_dialog->popup_centered_ratio(); } - } +void ProjectExportDialog::_patch_edited() { -void ProjectExportDialog::_validate_platform() { - - get_ok()->set_disabled(true); - button_export->set_disabled(true); - TreeItem *selected = platforms->get_selected(); - plat_errors->hide(); - if (!selected) { - return; - } - - String platform = selected->get_metadata(0); - Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(platform); - if (!exporter.is_valid()) { + TreeItem *item = patches->get_edited(); + if (!item) return; - } + int index = item->get_metadata(0); - String err; - if (!exporter->can_export(&err)) { - Vector<String> items = err.strip_edges().split("\n"); - err=""; - for(int i=0;i<items.size();i++) { - if (i!=0) - err+="\n"; - err+=" -"+items[i]; - } + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + ERR_FAIL_COND(current.is_null()); - platform_error_string->set_text(err); - plat_errors->show(); - return; - } + Vector<String> patches = current->get_patches(); - List<String> pl; - EditorFileSystem::get_singleton()->get_changed_sources(&pl); + ERR_FAIL_INDEX(index,patches.size()); - if (false && pl.size()) { - if (pl.size()==1) - platform_error_string->set_text(" -One Resource is pending re-import."); - else - platform_error_string->set_text(" "+itos(pl.size())+" Resources are pending re-import."); + String patch = patches[index].replace("*",""); - plat_errors->show(); - return; + if (item->is_checked(0)) { + patch+="*"; } - get_ok()->set_disabled(false); - button_export->set_disabled(false); - -} - -void ProjectExportDialog::_export_mode_changed(int p_idx) { - - if (EditorImportExport::get_singleton()->get_export_filter()==p_idx) - return; - EditorImportExport::get_singleton()->set_export_filter(EditorImportExport::ExportFilter(p_idx)); + current->set_patch(index,patch); - if (p_idx!=EditorImportExport::EXPORT_SELECTED) - tree_vb->hide(); - else - tree_vb->show(); - - EditorImportExport::get_singleton()->set_convert_text_scenes( convert_text_scenes->is_pressed() ); - _save_export_cfg(); } -void ProjectExportDialog::_export_action(const String& p_file) { +void ProjectExportDialog::_patch_selected(const String& p_path) { - String location = GlobalConfig::get_singleton()->globalize_path(p_file).get_base_dir().replace("\\","/"); - - while(true) { + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + ERR_FAIL_COND(current.is_null()); - print_line("TESTING: "+location.plus_file("godot.cfg")); - if (FileAccess::exists(location.plus_file("godot.cfg"))) { + Vector<String> patches = current->get_patches(); - error->set_text(TTR("Please export outside the project folder!")); - error->popup_centered_minsize(); - return; - } - String nl = (location+"/..").simplify_path(); - if (nl.find("/")==location.find_last("/")) - break; - location=nl; - } + if (patch_index >=patches.size()) { - /* Checked if the export location is outside the project directory, - * now will check if a file name has been entered */ - if (p_file.ends_with("/")) { + current->add_patch(GlobalConfig::get_singleton()->get_resource_path().path_to(p_path)+"*"); + } else { + String enabled = patches[patch_index].ends_with("*") ? String("*") : String(); + current->set_patch(patch_index,GlobalConfig::get_singleton()->get_resource_path().path_to(p_path)+enabled); - error->set_text("Please enter a file name!"); - error->popup_centered_minsize(); - return; } - TreeItem *selected = platforms->get_selected(); - if (!selected) - return; - - String platform = selected->get_metadata(0); - bool debugging_enabled = EditorImportExport::get_singleton()->get_export_platform(platform)->is_debugging_enabled(); - Error err = export_platform(platform,p_file,debugging_enabled,file_export_password->get_text(),false); - if (err!=OK) { - error->set_text(TTR("Error exporting project!")); - error->popup_centered_minsize(); - } + _edit_preset(presets->get_current()); } -void ProjectExportDialog::_export_action_pck(const String& p_file) { - - TreeItem *selected = platforms->get_selected(); - if (!selected) - return; - - Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(selected->get_metadata(0)); - if (exporter.is_null()) { - ERR_PRINT("Invalid platform for export of PCK"); - return; - } - - if (p_file.ends_with(".pck")) { - FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE); - if (!f) { - error->set_text(TTR("Error writing the project PCK!")); - error->popup_centered_minsize(); - } - ERR_FAIL_COND(!f); - - Error err = exporter->save_pack(f,false); - memdelete(f); +void ProjectExportDialog::_patch_deleted() { - if (err!=OK) { - error->set_text(TTR("Error exporting project!")); - error->popup_centered_minsize(); - return; - } - } else if (p_file.ends_with(".zip")) { + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + ERR_FAIL_COND(current.is_null()); - Error err = exporter->save_zip(p_file,false); + Vector<String> patches = current->get_patches(); + if (patch_index <patches.size()) { - if (err!=OK) { - error->set_text(TTR("Error exporting project!")); - error->popup_centered_minsize(); - return; - } + current->remove_patch(patch_index); + _edit_preset(presets->get_current()); } -} +} -Error ProjectExportDialog::export_platform(const String& p_platform, const String& p_path, bool p_debug,const String& p_password, bool p_quit_after) { +void ProjectExportDialog::_runnable_pressed() { - Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(p_platform); - if (exporter.is_null()) { - ERR_PRINT("Invalid platform for export"); + if (updating) + return; - List<StringName> platforms; - EditorImportExport::get_singleton()->get_export_platforms(&platforms); - print_line("Valid export plaftorms are:"); - for (List<StringName>::Element *E=platforms.front();E;E=E->next()) - print_line(" \""+E->get()+"\""); + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + ERR_FAIL_COND(current.is_null()); - if (p_quit_after) { - OS::get_singleton()->set_exit_code(255); - get_tree()->quit(); - } + if (runnable->is_pressed()) { - return ERR_INVALID_PARAMETER; - } - Error err = exporter->export_project(p_path,p_debug); - if (err!=OK) { - error->set_text(TTR("Error exporting project!")); - error->popup_centered_minsize(); - ERR_PRINT("Exporting failed!"); - if (p_quit_after) { - OS::get_singleton()->set_exit_code(255); - get_tree()->quit(); + for(int i=0;i<EditorExport::get_singleton()->get_export_preset_count();i++) { + Ref<EditorExportPreset> p = EditorExport::get_singleton()->get_export_preset(i); + if (p->get_platform()==current->get_platform()) { + p->set_runnable(current==p); + } } - return ERR_CANT_CREATE; } else { - if (p_quit_after) { - get_tree()->quit(); - } - } - - return OK; - -} -void ProjectExportDialog::ok_pressed() { - //export pck - pck_export->popup_centered_ratio(); + current->set_runnable(false); + } + _update_presets(); } -void ProjectExportDialog::custom_action(const String&) { - //real export - - TreeItem *selected = platforms->get_selected(); - if (!selected) - return; - String platform = selected->get_metadata(0); - Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(platform); +void ProjectExportDialog::_name_changed(const String& p_string) { - if (exporter.is_null()) { - error->set_text(vformat(TTR("No exporter for platform '%s' yet."),platform)); - error->popup_centered_minsize(); - return; - } - - if (platform.to_lower()=="android" && _check_android_setting(exporter)==false){ - // not filled all field for Android release + if (updating) return; - } - - String extension = exporter->get_binary_extension(); - file_export_password->set_editable( exporter->requires_password(exporter->is_debugging_enabled()) ); + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + ERR_FAIL_COND(current.is_null()); - file_export->clear_filters(); - if (extension!="") { - file_export->add_filter("*."+extension); - } - file_export->popup_centered_ratio(); + current->set_name(p_string); + _update_presets(); } -LineEdit* ProjectExportDialog::_create_keystore_input(Control* container, const String& p_label, const String& name) { - - HBoxContainer* hb=memnew(HBoxContainer); - Label* lb=memnew(Label); - LineEdit* input=memnew(LineEdit); +void ProjectExportDialog::_delete_preset() { - lb->set_text(p_label); - lb->set_custom_minimum_size(Size2(140*EDSCALE,0)); - lb->set_align(Label::ALIGN_RIGHT); - - input->set_custom_minimum_size(Size2(170*EDSCALE,0)); - input->set_name(name); - - hb->add_constant_override("separation", 10*EDSCALE); - hb->add_child(lb); - hb->add_child(input); - container->add_child(hb); + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + if (current.is_null()) + return; - return input; + delete_confirm->set_text(vformat(TTR("Delete preset '%s'?"),current->get_name())); + delete_confirm->popup_centered_minsize(); } -void ProjectExportDialog::_create_android_keystore_window() { - - keystore_file_dialog = memnew( EditorFileDialog ); - add_child(keystore_file_dialog); - keystore_file_dialog->set_mode(EditorFileDialog::MODE_OPEN_DIR); - keystore_file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - keystore_file_dialog->set_current_dir( "res://" ); - - keystore_file_dialog->set_title(TTR("Target Path:")); - keystore_file_dialog->connect("dir_selected", this,"_keystore_dir_selected"); - - keystore_create_dialog=memnew(ConfirmationDialog); - VBoxContainer* vb=memnew(VBoxContainer); - vb->set_size(Size2(340*EDSCALE,0)); - keystore_create_dialog->set_title(TTR("Create Android keystore")); - - _create_keystore_input(vb, TTR("Full name"), "name"); - _create_keystore_input(vb, TTR("Organizational unit"), "unit"); - _create_keystore_input(vb, TTR("Organization"), "org"); - _create_keystore_input(vb, TTR("City"), "city"); - _create_keystore_input(vb, TTR("State"), "state"); - _create_keystore_input(vb, TTR("2 letter country code"), "code"); - _create_keystore_input(vb, TTR("User alias"), "alias"); - LineEdit* pass=_create_keystore_input(vb, TTR("Password"), "pass"); - pass->set_placeholder(TTR("at least 6 characters")); - _create_keystore_input(vb, TTR("File name"), "file"); - - Label* lb_path=memnew(Label); - LineEdit* path=memnew(LineEdit); - Button* btn=memnew(Button); - HBoxContainer* hb=memnew(HBoxContainer); - - lb_path->set_text(TTR("Path : (better to save outside of project)")); - path->set_h_size_flags(SIZE_EXPAND_FILL); - path->set_name("path"); - btn->set_text(" .. "); - btn->connect("pressed", keystore_file_dialog, "popup_centered_ratio"); - - vb->add_spacer(); - vb->add_child(lb_path); - hb->add_child(path); - hb->add_child(btn); - vb->add_child(hb); - - keystore_create_dialog->add_child(vb); - //keystore_create_dialog->set_child_rect(vb); - add_child(keystore_create_dialog); - - keystore_create_dialog->connect("confirmed", this, "_create_android_keystore"); - path->connect("text_changed", this, "_check_keystore_path"); - - confirm_keystore = memnew(ConfirmationDialog); - confirm_keystore->connect("confirmed", keystore_create_dialog, "popup_centered_minsize"); - add_child(confirm_keystore); +void ProjectExportDialog::_delete_preset_confirm() { + int idx = presets->get_current(); + parameters->edit(NULL);//to avoid crash + EditorExport::get_singleton()->remove_export_preset(idx); + _update_presets(); + _edit_preset(-1); } -void ProjectExportDialog::_keystore_dir_selected(const String& path) { - - LineEdit* edit=keystore_create_dialog->find_node("path", true, false)->cast_to<LineEdit>(); - edit->set_text(path.simplify_path()); -} +Variant ProjectExportDialog::get_drag_data_fw(const Point2& p_point,Control* p_from) { -void ProjectExportDialog::_keystore_created() { + if (p_from==presets) { + int pos = presets->get_item_at_pos(p_point,true); - if (error->is_connected("popup_hide", this, "_keystore_created")){ - error->disconnect("popup_hide", this, "_keystore_created"); - } - custom_action("export_pck"); + if (pos>=0) { + Dictionary d; + d["type"]="export_preset"; + d["preset"]=pos; -} + HBoxContainer *drag = memnew( HBoxContainer); + TextureRect *tr = memnew(TextureRect); + tr->set_texture(presets->get_item_icon(pos)); + drag->add_child(tr); + Label *label = memnew( Label ); + label->set_text(presets->get_item_text(pos)); + drag->add_child(label); -void ProjectExportDialog::_check_keystore_path(const String& path) { + set_drag_preview(drag); - LineEdit* edit=keystore_create_dialog->find_node("path", true, false)->cast_to<LineEdit>(); - bool exists = DirAccess::exists(path); - if (!exists) { - edit->add_color_override("font_color", Color(1,0,0,1)); - } else { - edit->add_color_override("font_color", Color(0,1,0,1)); - } + return d; -} + } + } else if (p_from==patches) { -void ProjectExportDialog::_create_android_keystore() { + TreeItem *item = patches->get_item_at_pos(p_point); - Vector<String> names=String("name,unit,org,city,state,code,alias,pass").split(","); - String path=keystore_create_dialog->find_node("path", true, false)->cast_to<LineEdit>()->get_text(); - String file=keystore_create_dialog->find_node("file", true, false)->cast_to<LineEdit>()->get_text(); + if (item && item->get_cell_mode(0)==TreeItem::CELL_MODE_CHECK) { - if (file.ends_with(".keystore")==false) { - file+=".keystore"; - } - String fullpath=path.plus_file(file); - String info="CN=$name, OU=$unit, O=$org, L=$city, S=$state, C=$code"; - Dictionary dic; - - for (int i=0;i<names.size();i++){ - LineEdit* edit = keystore_create_dialog->find_node(names[i], true, false)->cast_to<LineEdit>(); - dic[names[i]]=edit->get_text(); - info=info.replace("$"+names[i], edit->get_text()); - } + int metadata = item->get_metadata(0); + Dictionary d; + d["type"]="export_patch"; + d["patch"]=metadata; - String jarsigner=EditorSettings::get_singleton()->get("export/android/jarsigner"); - String keytool=jarsigner.get_base_dir().plus_file("keytool"); - String os_name=OS::get_singleton()->get_name(); - if (os_name.to_lower()=="windows") { - keytool+=".exe"; - } + Label *label = memnew( Label ); + label->set_text(item->get_text(0)); + set_drag_preview(label); - bool exist=FileAccess::exists(keytool); - if (!exist) { - error->set_text("Can't find 'keytool'"); - error->popup_centered_minsize(); - return; - } + return d; + } - List<String> args; - args.push_back("-genkey"); - args.push_back("-v"); - args.push_back("-keystore"); - args.push_back(fullpath); - args.push_back("-alias"); - args.push_back(dic["alias"]); - args.push_back("-storepass"); - args.push_back(dic["pass"]); - args.push_back("-keypass"); - args.push_back(dic["pass"]); - args.push_back("-keyalg"); - args.push_back("RSA"); - args.push_back("-keysize"); - args.push_back("2048"); - args.push_back("-validity"); - args.push_back("10000"); - args.push_back("-dname"); - args.push_back(info); - int retval; - OS::get_singleton()->execute(keytool,args,true,NULL,NULL,&retval); - - if (retval==0) { // success - platform_options->_edit_set("keystore/release", fullpath); - platform_options->_edit_set("keystore/release_user", dic["alias"]); - platform_options->_edit_set("keystore/release_password", dic["pass"]); - - error->set_text("Android keystore created at \n"+fullpath); - error->connect("popup_hide", this, "_keystore_created"); - error->popup_centered_minsize(); - } else { // fail - error->set_text("Fail to create android keystore at \n"+fullpath); - error->popup_centered_minsize(); } + return Variant(); } -bool ProjectExportDialog::_check_android_setting(const Ref<EditorExportPlatform>& exporter) { - - bool is_debugging = exporter->get("debug/debugging_enabled"); - String release = exporter->get("keystore/release"); - String user = exporter->get("keystore/release_user"); - String password = exporter->get("keystore/release_password"); - - if (!is_debugging && (release=="" || user=="" || password=="")){ - if (release==""){ - confirm_keystore->set_text(TTR("Release keystore is not set.\nDo you want to create one?")); - confirm_keystore->popup_centered_minsize(); - } else { - error->set_text(TTR("Fill Keystore/Release User and Release Password")); - error->popup_centered_minsize(); - } - return false; - } - - return true; +bool ProjectExportDialog::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{ -} + if (p_from==presets) { + Dictionary d = p_data; + if (!d.has("type") || String(d["type"])!="export_preset") + return false; -void ProjectExportDialog::_group_selected() { + if (presets->get_item_at_pos(p_point,true)<0 && !presets->is_pos_at_end_of_items(p_point)) + return false; + } else if (p_from==patches) { - _update_group(); //? + Dictionary d = p_data; + if (!d.has("type") || String(d["type"])!="export_patch") + return false; - _update_group_tree(); -} + patches->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM); -String ProjectExportDialog::_get_selected_group() { + TreeItem *item = patches->get_item_at_pos(p_point); - TreeItem *sel = groups->get_selected(); - if (!sel) - return String(); + if (!item) { - return sel->get_text(0); + return false; + } + } + return true; } -void ProjectExportDialog::_update_group_list() { - - String current = _get_selected_group(); +void ProjectExportDialog::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){ - groups->clear(); - List<StringName> grouplist; - EditorImportExport::get_singleton()->image_export_get_groups(&grouplist); - grouplist.sort_custom<StringName::AlphCompare>(); + if (p_from==presets) { + Dictionary d=p_data; + int from_pos = d["preset"]; - TreeItem *r = groups->create_item(); - for (List<StringName>::Element *E=grouplist.front();E;E=E->next()) { + int to_pos=-1; - TreeItem *ti = groups->create_item(r); - ti->set_text(0,E->get()); - ti->add_button(0,get_icon("Remove","EditorIcons")); - if (E->get()==current) { - ti->select(0); + if (presets->get_item_at_pos(p_point,true)>=0) { + to_pos = presets->get_item_at_pos(p_point,true); } - } - - _update_group(); -} - -void ProjectExportDialog::_select_group(const String& p_by_name) { - - TreeItem *c = groups->get_root(); - if (!c) - return; - c=c->get_children(); - if (!c) - return; - - while(c) { + if (to_pos==-1 && !presets->is_pos_at_end_of_items(p_point)) + return; - if (c->get_text(0)==p_by_name) { - c->select(0); - _update_group(); + if (to_pos==from_pos) return; + else if (to_pos>from_pos) { + to_pos--; } - c=c->get_next(); - } -} - -void ProjectExportDialog::_update_group() { - - if (updating) - return; - updating=true; - if (_get_selected_group()=="") { - group_options->hide(); - //group_del->set_disabled(true); + Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(from_pos); + EditorExport::get_singleton()->remove_export_preset(from_pos); + EditorExport::get_singleton()->add_export_preset(preset,to_pos); - } else { - group_options->show(); - //group_del->set_disabled(false); - StringName name = _get_selected_group(); - group_image_action->select(EditorImportExport::get_singleton()->image_export_group_get_image_action(name)); - group_atlas->set_pressed(EditorImportExport::get_singleton()->image_export_group_get_make_atlas(name)); - group_shrink->set_value(EditorImportExport::get_singleton()->image_export_group_get_shrink(name)); - group_lossy_quality->set_value(EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(name)); - if (group_atlas->is_pressed()) - atlas_preview->show(); + _update_presets(); + if (to_pos>=0) + _edit_preset(to_pos); else - atlas_preview->hide(); - - } - - _update_group_tree(); - - updating=false; + _edit_preset(presets->get_item_count()-1); + } else if (p_from==patches) { + Dictionary d = p_data; + if (!d.has("type") || String(d["type"])!="export_patch") + return; -} + int from_pos = d["patch"]; -bool ProjectExportDialog::_update_group_treef(TreeItem *p_parent,EditorFileSystemDirectory *p_dir,const Set<String>& p_extensions,const String& p_groups,const Map<StringName,int>& p_group_index) { + TreeItem *item = patches->get_item_at_pos(p_point); + if (!item) + return; - TreeItem *ti = group_images->create_item(p_parent); - ti->set_text(0,p_dir->get_name()+"/"); - bool has_child=false; - for(int i=0;i<p_dir->get_subdir_count();i++) { + int to_pos = item->get_cell_mode(0)==TreeItem::CELL_MODE_CHECK ? int(item->get_metadata(0)) : -1; - if (_update_group_treef(ti,p_dir->get_subdir(i),p_extensions,p_groups,p_group_index)) { - has_child=true; + if (to_pos==from_pos) + return; + else if (to_pos>from_pos) { + to_pos--; } - } - - String filter=group_images_filter->get_text(); - StringName current_group = _get_selected_group(); - String check_text=TTR("Include"); - - for(int i=0;i<p_dir->get_file_count();i++) { - - String fname = p_dir->get_file(i); - if (p_extensions.has(fname.to_lower().get_extension())) { - String path = p_dir->get_file_path(i); - - if (filter!=String() && path.find(filter)==-1) - continue; - - has_child=true; - TreeItem *file = group_images->create_item(ti); - file->set_text(0,fname); - StringName g = EditorImportExport::get_singleton()->image_get_export_group(path); - - if (current_group==g || g==StringName()) { - - file->set_cell_mode(1,TreeItem::CELL_MODE_CHECK); - file->set_text(1,check_text); - file->set_editable(1,true); - file->set_checked(1,current_group==g); - } else { - - file->set_text(1,g); - file->set_editable(1,false); - file->set_selectable(1,false); - } + Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + String patch = preset->get_patch(from_pos); + preset->remove_patch(from_pos); + preset->add_patch(patch,to_pos); - file->set_metadata(0,path); - } - } + _edit_preset(presets->get_current()); - if (!has_child) { - memdelete(ti); - return false; } - return true; - } -void ProjectExportDialog::_update_group_tree() { + +void ProjectExportDialog::_export_type_changed(int p_which) { if (updating) return; - group_images->clear(); - - if (_get_selected_group()=="") + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + if (current.is_null()) return; + current->set_export_filter(EditorExportPreset::ExportFilter(p_which)); updating=true; - print_line("****UGT"); - List<String> img_extensions; - ImageLoader::get_recognized_extensions(&img_extensions); - Set<String> extensions; - for(List<String>::Element *E=img_extensions.front();E;E=E->next()) { - - extensions.insert(E->get()); - } - - List<StringName> grouplist; - EditorImportExport::get_singleton()->image_export_get_groups(&grouplist); - grouplist.sort_custom<StringName::AlphCompare>(); - Map<StringName,int> group_index; - group_index[StringName()]=0; - int idx=1; - String groupenum="--"; - for(List<StringName>::Element *E=grouplist.front();E;E=E->next()) { - - group_index[E->get()]=idx++; - groupenum+=","+String(E->get()); - } - + _fill_resource_tree(); updating=false; - - _update_group_treef(NULL,EditorFileSystem::get_singleton()->get_filesystem(),extensions,groupenum,group_index); - } -void ProjectExportDialog::_group_changed(Variant v) { +void ProjectExportDialog::_filter_changed(const String& p_filter) { if (updating) return; - if (_get_selected_group()=="") - return; - updating=true; - StringName name = _get_selected_group(); - EditorNode::get_undo_redo()->create_action(TTR("Change Image Group")); - EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_set_image_action",name,group_image_action->get_selected()); - EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_set_make_atlas",name,group_atlas->is_pressed()); - EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_set_shrink",name,group_shrink->get_value()); - EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_set_lossy_quality",name,group_lossy_quality->get_value()); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_image_action",name,EditorImportExport::get_singleton()->image_export_group_get_image_action(name)); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_make_atlas",name,EditorImportExport::get_singleton()->image_export_group_get_make_atlas(name)); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_shrink",name,EditorImportExport::get_singleton()->image_export_group_get_shrink(name)); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_lossy_quality",name,EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(name)); - EditorNode::get_undo_redo()->add_do_method(this,"_update_group"); - EditorNode::get_undo_redo()->add_undo_method(this,"_update_group"); - EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg"); - EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg"); - EditorNode::get_undo_redo()->commit_action(); - updating=false; - // update atlas preview button - _update_group(); -} - -void ProjectExportDialog::_group_item_edited() { - TreeItem *item = group_images->get_edited(); - if (!item) - return; - if (_get_selected_group()==String()) + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + if (current.is_null()) return; - StringName path = item->get_metadata(0); - String group; - if (item->is_checked(1)) { - group=_get_selected_group(); - } else { - group=String(); - } + current->set_include_filter(include_filters->get_text()); + current->set_exclude_filter(exclude_filters->get_text()); + - print_line("changed "+path+" to group: "+group); - EditorNode::get_undo_redo()->create_action(TTR("Change Image Group")); - EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_add_to_export_group",path,group); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_add_to_export_group",path,EditorImportExport::get_singleton()->image_get_export_group(path)); - EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_tree"); - EditorNode::get_undo_redo()->add_do_method(this,"_update_group_tree"); - EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg"); - EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg"); - EditorNode::get_undo_redo()->commit_action(); } -void ProjectExportDialog::_group_add() { +void ProjectExportDialog::_fill_resource_tree() { - String name = group_new_name->get_text(); + include_files->clear(); + include_label->hide(); + include_margin->hide(); - if (name=="") { - group_new_name_error->show(); - group_new_name_error->set_text(TTR("Group name can't be empty!")); - return; - } - if (name.find("/")!=-1 || name.find(":")!=-1 || name.find(",")!=-1 || name.find("-")!=-1) { - group_new_name_error->set_text(TTR("Invalid character in group name!")); - group_new_name_error->show(); + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + if (current.is_null()) return; - } - if (EditorImportExport::get_singleton()->image_export_has_group(name)) { - group_new_name_error->set_text(TTR("Group name already exists!")); - group_new_name_error->show(); + EditorExportPreset::ExportFilter f = current->get_export_filter(); + + if (f==EditorExportPreset::EXPORT_ALL_RESOURCES) { return; } - group_new_name_error->hide(); - String current=_get_selected_group(); + include_label->show(); + include_margin->show(); + TreeItem *root = include_files->create_item(); - EditorNode::get_undo_redo()->create_action(TTR("Add Image Group")); - EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_create",name); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_remove",name); - EditorNode::get_undo_redo()->add_do_method(this,"_update_group_list"); - EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_list"); - EditorNode::get_undo_redo()->add_do_method(this,"_select_group",name); - if (current!="") - EditorNode::get_undo_redo()->add_undo_method(this,"_select_group",current); - EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_tree"); - EditorNode::get_undo_redo()->add_do_method(this,"_update_group_tree"); - EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg"); - EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg"); - - EditorNode::get_undo_redo()->commit_action(); + _fill_tree(EditorFileSystem::get_singleton()->get_filesystem(),root,current,f==EditorExportPreset::EXPORT_SELECTED_SCENES); } -void ProjectExportDialog::_group_del(Object *p_item, int p_column, int p_button){ +bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir,TreeItem *p_item,Ref<EditorExportPreset> ¤t,bool p_only_scenes) { - TreeItem *item = p_item->cast_to<TreeItem>(); - if (!item) - return; - String name = item->get_text(0); - - EditorNode::get_undo_redo()->create_action(TTR("Delete Image Group")); - List<StringName> images_used; - EditorImportExport::get_singleton()->image_export_get_images_in_group(name,&images_used); - for (List<StringName>::Element*E=images_used.front();E;E=E->next()) { + p_item->set_icon(0,get_icon("folder","FileDialog")); + p_item->set_text(0,p_dir->get_name()+"/"); - EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_add_to_export_group",E->get(),StringName()); - - } - EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_remove",name); - - - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_create",name); - for (List<StringName>::Element*E=images_used.front();E;E=E->next()) { - - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_add_to_export_group",E->get(),name); + bool used=false; + for(int i=0;i<p_dir->get_subdir_count();i++) { + TreeItem *subdir = include_files->create_item(p_item); + if (_fill_tree(p_dir->get_subdir(i),subdir,current,p_only_scenes)==false) { + memdelete(subdir); + } else { + used=true; + } } - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_image_action",name,EditorImportExport::get_singleton()->image_export_group_get_image_action(name)); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_make_atlas",name,EditorImportExport::get_singleton()->image_export_group_get_make_atlas(name)); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_shrink",name,EditorImportExport::get_singleton()->image_export_group_get_shrink(name)); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_lossy_quality",name,EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(name)); - EditorNode::get_undo_redo()->add_do_method(this,"_update_group_list"); - EditorNode::get_undo_redo()->add_do_method(this,"_update_group"); - EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_list"); - EditorNode::get_undo_redo()->add_undo_method(this,"_select_group",name); - EditorNode::get_undo_redo()->add_do_method(this,"_update_group_tree"); - EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_tree"); - EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg"); - EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg"); - EditorNode::get_undo_redo()->commit_action(); - -} - -void ProjectExportDialog::_group_select_all() { - - - String group = _get_selected_group(); - if (group=="") - return; - - TreeItem *item = group_images->get_root(); - if (!item) - return; - - List<StringName> items; - while(item) { + for(int i=0;i<p_dir->get_file_count();i++) { - if (item->get_cell_mode(1)==TreeItem::CELL_MODE_CHECK && !item->is_checked(1)) - items.push_back(item->get_metadata(0)); - item=item->get_next_visible(); - } + String type = p_dir->get_file_type(i); + if (p_only_scenes && type!="PackedScene") + continue; + TreeItem *file = include_files->create_item(p_item); + file->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); + file->set_text(0,p_dir->get_file(i)); - if (items.size()==0) - return; + Ref<Texture> tex; + if (has_icon(type,editor_icons)) { + tex = get_icon(type,editor_icons); + } else { + tex = get_icon("Object",editor_icons); + } - EditorNode::get_undo_redo()->create_action(TTR("Select All")); + String path = p_dir->get_file_path(i); - for (List<StringName>::Element *E=items.front();E;E=E->next()) { + file->set_icon(0,tex); + file->set_editable(0,true); + file->set_checked(0,current->has_export_file(path)); + file->set_metadata(0,path); - EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_add_to_export_group",E->get(),group); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_add_to_export_group",E->get(),String()); + used=true; } - EditorNode::get_undo_redo()->add_do_method(this,"_update_group_tree"); - EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_tree"); - EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg"); - EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg"); - - EditorNode::get_undo_redo()->commit_action(); + return used; } -void ProjectExportDialog::_group_select_none(){ +void ProjectExportDialog::_tree_changed() { - String group = _get_selected_group(); - if (group=="") + if (updating) return; - TreeItem *item = group_images->get_root(); - if (!item) + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + if (current.is_null()) return; - List<StringName> items; - while(item) { - - if (item->get_cell_mode(1)==TreeItem::CELL_MODE_CHECK && item->is_checked(1)) - items.push_back(item->get_metadata(0)); - item=item->get_next_visible(); - } - - - if (items.size()==0) + TreeItem *item = include_files->get_edited(); + if (!item) return; - EditorNode::get_undo_redo()->create_action(TTR("Select All")); + String path = item->get_metadata(0); + bool added = item->is_checked(0); - for (List<StringName>::Element *E=items.front();E;E=E->next()) { - - EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_add_to_export_group",E->get(),String()); - EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_add_to_export_group",E->get(),group); + if (added) { + current->add_export_file(path); + } else { + current->remove_export_file(path); } - EditorNode::get_undo_redo()->add_do_method(this,"_update_group_tree"); - EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_tree"); - EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg"); - EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg"); - - EditorNode::get_undo_redo()->commit_action(); - } -void ProjectExportDialog::_group_atlas_preview() { - - StringName group = _get_selected_group(); - if (!group) - return; - - atlas_preview_frame->set_texture(Ref<Texture>()); //clear previous - - List<StringName> images; - EditorImportExport::get_singleton()->image_export_get_images_in_group(group,&images); - images.sort_custom<StringName::AlphCompare>(); - String dst_file = EditorSettings::get_singleton()->get_settings_path()+"/tmp/atlas-preview.tex"; - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - //imd->set_editor(); - - for (List<StringName>::Element *F=images.front();F;F=F->next()) { - - imd->add_source(EditorImportPlugin::validate_source_path(F->get())); - } - - - int flags=0; - - if (GlobalConfig::get_singleton()->get("image_loader/filter")) - flags|=EditorTextureImportPlugin::IMAGE_FLAG_FILTER; - if (!GlobalConfig::get_singleton()->get("image_loader/gen_mipmaps")) - flags|=EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS; - if (!GlobalConfig::get_singleton()->get("image_loader/repeat")) - flags|=EditorTextureImportPlugin::IMAGE_FLAG_REPEAT; - - flags|=EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA; - - imd->set_option("format",EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS); - imd->set_option("flags",flags); - imd->set_option("quality",0.7); - imd->set_option("atlas",true); - imd->set_option("crop",true); - - Ref<EditorTextureImportPlugin> plugin = EditorImportExport::get_singleton()->get_import_plugin_by_name("texture"); - Error err = plugin->import2(dst_file,imd,EditorExportPlatform::IMAGE_COMPRESSION_NONE,true); - if (err) { - - EditorNode::add_io_error(TTR("Error saving atlas:")+" "+dst_file.get_file()); - return; - } - - Ref<Texture> tex = ResourceLoader::load(dst_file); - atlas_preview_frame->set_texture(tex); //clear previous - atlas_preview_dialog->set_title(TTR("Atlas Preview")+" ("+itos(tex->get_width())+"x"+itos(tex->get_height())+")"); - atlas_preview_dialog->popup_centered_ratio(0.9); +void ProjectExportDialog::_export_pck_zip() { + export_pck_zip->popup_centered_ratio(); } -void ProjectExportDialog::_update_script() { +void ProjectExportDialog::_export_pck_zip_selected(const String& p_path) { - if (updating_script) - return; - updating_script=true; - script_mode->select(EditorImportExport::get_singleton()->script_get_action()); - script_key->set_text(EditorImportExport::get_singleton()->script_get_encryption_key()); - updating_script=false; + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + ERR_FAIL_COND (current.is_null()); + Ref<EditorExportPlatform> platform = current->get_platform(); + ERR_FAIL_COND( platform.is_null() ); + if (p_path.ends_with(".zip")) { + platform->save_zip(current,p_path); + } else if (p_path.ends_with(".pck")) { + platform->save_pack(current,p_path); + } } -void ProjectExportDialog::_image_filter_changed(String) { - - _update_group_tree(); -} void ProjectExportDialog::_bind_methods() { - - ClassDB::bind_method(D_METHOD("_rescan"),&ProjectExportDialog::_rescan); - ClassDB::bind_method(D_METHOD("_tree_changed"),&ProjectExportDialog::_tree_changed); - ClassDB::bind_method(D_METHOD("_scan_finished"),&ProjectExportDialog::_scan_finished); - ClassDB::bind_method(D_METHOD("_platform_selected"),&ProjectExportDialog::_platform_selected); - ClassDB::bind_method(D_METHOD("_prop_edited"),&ProjectExportDialog::_prop_edited); - ClassDB::bind_method(D_METHOD("_export_mode_changed"),&ProjectExportDialog::_export_mode_changed); - ClassDB::bind_method(D_METHOD("_filters_edited"),&ProjectExportDialog::_filters_edited); - ClassDB::bind_method(D_METHOD("_filters_exclude_edited"),&ProjectExportDialog::_filters_exclude_edited); - ClassDB::bind_method(D_METHOD("_export_action"),&ProjectExportDialog::_export_action); - ClassDB::bind_method(D_METHOD("_export_action_pck"),&ProjectExportDialog::_export_action_pck); - ClassDB::bind_method(D_METHOD("_quality_edited"),&ProjectExportDialog::_quality_edited); - ClassDB::bind_method(D_METHOD("_shrink_edited"),&ProjectExportDialog::_shrink_edited); - ClassDB::bind_method(D_METHOD("_image_export_edited"),&ProjectExportDialog::_image_export_edited); - ClassDB::bind_method(D_METHOD("_format_toggled"),&ProjectExportDialog::_format_toggled); - ClassDB::bind_method(D_METHOD("_group_changed"),&ProjectExportDialog::_group_changed); - ClassDB::bind_method(D_METHOD("_group_add"),&ProjectExportDialog::_group_add); - ClassDB::bind_method(D_METHOD("_group_del"),&ProjectExportDialog::_group_del); - ClassDB::bind_method(D_METHOD("_group_selected"),&ProjectExportDialog::_group_selected); - ClassDB::bind_method(D_METHOD("_update_group"),&ProjectExportDialog::_update_group); - ClassDB::bind_method(D_METHOD("_update_group_list"),&ProjectExportDialog::_update_group_list); - ClassDB::bind_method(D_METHOD("_select_group"),&ProjectExportDialog::_select_group); - ClassDB::bind_method(D_METHOD("_update_group_tree"),&ProjectExportDialog::_update_group_tree); - ClassDB::bind_method(D_METHOD("_group_item_edited"),&ProjectExportDialog::_group_item_edited); - ClassDB::bind_method(D_METHOD("_save_export_cfg"),&ProjectExportDialog::_save_export_cfg); - ClassDB::bind_method(D_METHOD("_image_filter_changed"),&ProjectExportDialog::_image_filter_changed); - ClassDB::bind_method(D_METHOD("_group_atlas_preview"),&ProjectExportDialog::_group_atlas_preview); - ClassDB::bind_method(D_METHOD("_group_select_all"),&ProjectExportDialog::_group_select_all); - ClassDB::bind_method(D_METHOD("_group_select_none"),&ProjectExportDialog::_group_select_none); - ClassDB::bind_method(D_METHOD("_script_edited"),&ProjectExportDialog::_script_edited); - ClassDB::bind_method(D_METHOD("_update_script"),&ProjectExportDialog::_update_script); - ClassDB::bind_method(D_METHOD("_sample_convert_edited"),&ProjectExportDialog::_sample_convert_edited); - - - ClassDB::bind_method(D_METHOD("export_platform"),&ProjectExportDialog::export_platform); - ClassDB::bind_method(D_METHOD("_create_android_keystore"),&ProjectExportDialog::_create_android_keystore); - ClassDB::bind_method(D_METHOD("_check_keystore_path"),&ProjectExportDialog::_check_keystore_path); - ClassDB::bind_method(D_METHOD("_keystore_dir_selected"),&ProjectExportDialog::_keystore_dir_selected); - ClassDB::bind_method(D_METHOD("_keystore_created"),&ProjectExportDialog::_keystore_created); - - - //ADD_SIGNAL(MethodInfo("instance")); - //ADD_SIGNAL(MethodInfo("open")); - -} - - -ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { - - editor=p_editor; - set_title(TTR("Project Export Settings")); - - sections = memnew( TabContainer ); - add_child(sections); - //set_child_rect(sections); - - VBoxContainer *pvbox = memnew( VBoxContainer ); - sections->add_child(pvbox); - pvbox->set_name(TTR("Target")); - - HBoxContainer *phbox = memnew( HBoxContainer ); - pvbox->add_child(phbox); - phbox->set_v_size_flags(SIZE_EXPAND_FILL); - - plat_errors = memnew( HBoxContainer ); - pvbox->add_child(plat_errors); - platform_error_string = memnew( Label ); - platform_error_string->set_h_size_flags(SIZE_EXPAND_FILL); - plat_errors->add_child(platform_error_string); - - VBoxContainer *vb = memnew( VBoxContainer ); - vb->set_h_size_flags(SIZE_EXPAND_FILL); - vb->set_v_size_flags(SIZE_EXPAND_FILL); - phbox->add_child(vb); - platforms = memnew( Tree ); - platforms->set_hide_root(true); - vb->add_margin_child(TTR("Export to Platform"),platforms,true); - - platforms->connect("cell_selected",this,"_platform_selected"); - - - vb = memnew(VBoxContainer ); - phbox->add_child(vb); - vb->set_h_size_flags(SIZE_EXPAND_FILL); - vb->set_v_size_flags(SIZE_EXPAND_FILL); - platform_options = memnew( PropertyEditor() ); - platform_options->hide_top_label(); - vb->add_margin_child(TTR("Options"),platform_options,true); - platform_options->connect("property_edited",this,"_prop_edited"); - - - - ////////////////// - - vb = memnew( VBoxContainer ); - vb->set_name(TTR("Resources")); - sections->add_child(vb); - - export_mode = memnew( OptionButton ); - export_mode->add_item(TTR("Export selected resources (including dependencies).")); - export_mode->add_item(TTR("Export all resources in the project.")); - export_mode->add_item(TTR("Export all files in the project directory.")); - export_mode->connect("item_selected",this,"_export_mode_changed"); - - vb->add_margin_child(TTR("Export Mode:"),export_mode); - - - - tree_vb = memnew( VBoxContainer ); - vb->add_child(tree_vb); - tree_vb->set_v_size_flags(SIZE_EXPAND_FILL); - - tree = memnew( Tree ); - tree_vb->add_margin_child(TTR("Resources to Export:"),tree,true); - - tree->set_v_size_flags(SIZE_EXPAND_FILL); - tree->connect("item_edited",this,"_tree_changed"); - tree->set_columns(2); - tree->set_column_titles_visible(true); - tree->set_column_title(0,TTR("File")); - tree->set_column_title(1,TTR("Action")); - tree->set_column_expand(1,false); - tree->set_column_min_width(1,90); - - filters = memnew( LineEdit ); - vb->add_margin_child(TTR("Filters to export non-resource files (comma-separated, e.g.: *.json, *.txt):"),filters); - filters->connect("text_changed",this,"_filters_edited"); - filters_exclude = memnew( LineEdit ); - vb->add_margin_child(TTR("Filters to exclude from export (comma-separated, e.g.: *.json, *.txt):"),filters_exclude); - filters_exclude->connect("text_changed",this,"_filters_exclude_edited"); - - convert_text_scenes = memnew( CheckButton ); - convert_text_scenes->set_text(TTR("Convert text scenes to binary on export.")); - vb->add_child(convert_text_scenes); - convert_text_scenes->connect("toggled",this,"_export_mode_changed"); - - image_vb = memnew( VBoxContainer ); - image_vb->set_name(TTR("Images")); - image_action = memnew( OptionButton ); - image_action->add_item(TTR("Keep Original")); - image_action->add_item(TTR("Compress for Disk (Lossy, WebP)")); - image_action->add_item(TTR("Compress for RAM (BC/PVRTC/ETC)")); - image_vb->add_margin_child(TTR("Convert Images (*.png):"),image_action); - HBoxContainer *qhb = memnew( HBoxContainer ); - image_quality = memnew( HSlider ); - qhb->add_child(image_quality); - image_quality->set_h_size_flags(SIZE_EXPAND_FILL); - SpinBox *qspin = memnew( SpinBox ); - image_quality->share(qspin); - qhb->add_child(qspin); - image_quality->set_min(0); - image_quality->set_max(1); - image_quality->set_step(0.01); - image_vb->add_margin_child(TTR("Compress for Disk (Lossy) Quality:"),qhb); - image_shrink = memnew( SpinBox ); - image_shrink->set_min(1); - image_shrink->set_max(8); - image_shrink->set_step(0.1); - image_vb->add_margin_child(TTR("Shrink All Images:"),image_shrink); - sections->add_child(image_vb); - - image_formats=memnew(Tree); - image_formats->set_hide_root(true); - TreeItem *root = image_formats->create_item(NULL); - List<String> fmts; - ImageLoader::get_recognized_extensions(&fmts); - for(List<String>::Element *E=fmts.front();E;E=E->next()) { - - TreeItem *fmt = image_formats->create_item(root); - fmt->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); - fmt->set_text(0,E->get()); - fmt->set_editable(0,true); - formats.push_back(fmt); - } - image_vb->add_margin_child(TTR("Compress Formats:")+" ",image_formats,true); - - /// groups - HBoxContainer *group_hb = memnew( HBoxContainer ); - group_hb->set_name(TTR("Image Groups")); - sections->add_child(group_hb); - VBoxContainer *group_vb_left = memnew( VBoxContainer); - group_hb->add_child(group_vb_left); - - VBoxContainer *gvb = memnew(VBoxContainer); - HBoxContainer *ghb = memnew(HBoxContainer); - gvb->add_child(ghb); - - group_new_name = memnew( LineEdit ); - group_new_name->set_h_size_flags(SIZE_EXPAND_FILL); - ghb->add_child(group_new_name); - - group_add = memnew(ToolButton); - group_add->connect("pressed",this,"_group_add"); - ghb->add_child(group_add); - - group_new_name_error = memnew( Label ); - group_new_name_error->add_color_override("font_color",Color(1,0.4,0.4)); - gvb->add_child(group_new_name_error); - group_new_name_error->hide(); - - groups=memnew(Tree); - groups->set_v_size_flags(SIZE_EXPAND_FILL); - groups->connect("cell_selected",this,"_group_selected",varray(),CONNECT_DEFERRED); - groups->connect("button_pressed",this,"_group_del",varray(),CONNECT_DEFERRED); - groups->set_hide_root(true); - gvb->add_child(groups); - - group_vb_left->add_margin_child(TTR("Groups:"),gvb,true); - //group_vb_left->add_child( memnew( HSeparator)); - group_options = memnew(VBoxContainer); - group_vb_left->add_child(group_options); - - - group_image_action = memnew(OptionButton); - group_image_action->add_item(TTR("Default")); - group_image_action->add_item(TTR("Compress Disk")); - group_image_action->add_item(TTR("Compress RAM")); - group_image_action->add_item(TTR("Keep Original")); - group_options->add_margin_child(TTR("Compress Mode:"),group_image_action); - group_image_action->connect("item_selected",this,"_group_changed"); - - group_lossy_quality = memnew( HSlider ); - group_lossy_quality->set_min(0.1); - group_lossy_quality->set_max(1.0); - group_lossy_quality->set_step(0.01); - group_lossy_quality->set_value(0.7); - group_lossy_quality->connect("value_changed",this,"_quality_edited"); - - HBoxContainer *gqhb = memnew( HBoxContainer ); - SpinBox *gqspin = memnew( SpinBox ); - group_lossy_quality->share(gqspin); - group_lossy_quality->set_h_size_flags(SIZE_EXPAND_FILL); - gqhb->add_child(group_lossy_quality); - gqhb->add_child(gqspin); - group_options->add_margin_child(TTR("Lossy Quality:"),gqhb); - - group_atlas = memnew(CheckButton); - group_atlas->set_pressed(true); - group_options->add_margin_child(TTR("Atlas:"),group_atlas); - group_atlas->connect("toggled",this,"_group_changed"); - - group_shrink = memnew(SpinBox); - group_shrink->set_min(1); - group_shrink->set_max(8); - group_shrink->set_value(1); - group_shrink->set_step(0.001); - group_options->add_margin_child(TTR("Shrink By:"),group_shrink); - group_shrink->connect("value_changed",this,"_group_changed"); - - atlas_preview = memnew( Button ); - atlas_preview->set_text(TTR("Preview Atlas")); - group_options->add_child(atlas_preview); - atlas_preview->show(); - atlas_preview->connect("pressed",this,"_group_atlas_preview"); - Control *ec = memnew(Control ); - ec->set_custom_minimum_size(Size2(150,1)); - gvb->add_child(ec); - - VBoxContainer *group_vb_right = memnew( VBoxContainer ); - group_hb->add_child(group_vb_right); - group_vb_right->set_h_size_flags(SIZE_EXPAND_FILL); - - HBoxContainer *filter_hb = memnew (HBoxContainer); - - group_images_filter = memnew( LineEdit ); - group_vb_right->add_margin_child(TTR("Image Filter:"),filter_hb); - filter_hb->add_child(group_images_filter); - group_images_filter->set_h_size_flags(SIZE_EXPAND_FILL); - group_images_filter->connect("text_changed",this,"_image_filter_changed"); - group_images = memnew( Tree ); - group_images->set_v_size_flags(SIZE_EXPAND_FILL); - group_vb_right->add_margin_child(TTR("Images:"),group_images,true); - - Button *filt_select_all = memnew( Button ); - filt_select_all->set_text(TTR("Select All")); - filter_hb->add_child(filt_select_all); - filt_select_all->connect("pressed",this,"_group_select_all"); - - Button *filt_select_none = memnew( Button ); - filt_select_none->set_text(TTR("Select None")); - filter_hb->add_child(filt_select_none); - filt_select_none->connect("pressed",this,"_group_select_none"); - - atlas_preview_dialog = memnew( AcceptDialog ); - ScrollContainer *scroll = memnew( ScrollContainer ); - atlas_preview_dialog->add_child(scroll); - //atlas_preview_dialog->set_child_rect(scroll); - atlas_preview_frame = memnew( TextureRect ); - scroll->add_child(atlas_preview_frame); - add_child(atlas_preview_dialog); - - - group_images->set_hide_root(true); - group_images->set_columns(2); - group_images->set_column_expand(0,true); - group_images->set_column_expand(1,false); - group_images->set_column_min_width(1,100); - group_images->set_column_titles_visible(true); - group_images->set_column_title(0,TTR("Images")); - group_images->set_column_title(1,TTR("Group")); - group_images->connect("item_edited",this,"_group_item_edited",varray(),CONNECT_DEFERRED); - -/* SpinBox *group_shrink; - CheckButton *group_atlas; - OptionButton *group_image_action;*/ - - -/* progress = memnew( Label ); - add_child(progress); - progress->set_area_as_parent_rect(); - progress->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,25); - progress->hide(); - progress->set_align(Label::ALIGN_CENTER);*/ - -/* - button_reload = memnew( Button ); - button_reload->set_pos(Point2(3,2)); - button_reload->set_size(Point2(20,5)); - button_reload->set_flat(true); - //add_child(button_reload); - button_reload->connect("pressed",this,"_rescan"); - hbc->add_child(button_reload); -*/ - - - sample_vbox = memnew( VBoxContainer ); - sample_vbox->set_name(TTR("Samples")); - sections->add_child(sample_vbox); - sample_mode = memnew( OptionButton ); - sample_vbox->add_margin_child(TTR("Sample Conversion Mode: (.wav files):"),sample_mode); - sample_mode->add_item(TTR("Keep")); - sample_mode->add_item(TTR("Compress (RAM - IMA-ADPCM)")); - sample_max_hz = memnew( SpinBox ); - sample_max_hz->set_max(192000); - sample_max_hz->set_min(8000); - sample_vbox->add_margin_child(TTR("Sampling Rate Limit (Hz):"),sample_max_hz); - sample_trim = memnew( CheckButton ); - sample_trim->set_text(TTR("Trim")); - sample_vbox->add_margin_child(TTR("Trailing Silence:"),sample_trim); - - script_vbox = memnew( VBoxContainer ); - script_vbox->set_name(TTR("Script")); - sections->add_child(script_vbox); - script_mode = memnew( OptionButton ); - script_vbox->add_margin_child(TTR("Script Export Mode:"),script_mode); - script_mode->add_item(TTR("Text")); - script_mode->add_item(TTR("Compiled")); - script_mode->add_item(TTR("Encrypted (Provide Key Below)")); - script_key = memnew( LineEdit ); - script_vbox->add_margin_child(TTR("Script Encryption Key (256-bits as hex):"),script_key); - - + ClassDB::bind_method("_add_preset",&ProjectExportDialog::_add_preset); + ClassDB::bind_method("_edit_preset",&ProjectExportDialog::_edit_preset); + ClassDB::bind_method("_runnable_pressed",&ProjectExportDialog::_runnable_pressed); + ClassDB::bind_method("_name_changed",&ProjectExportDialog::_name_changed); + ClassDB::bind_method("_delete_preset",&ProjectExportDialog::_delete_preset); + ClassDB::bind_method("_delete_preset_confirm",&ProjectExportDialog::_delete_preset_confirm); + ClassDB::bind_method("get_drag_data_fw",&ProjectExportDialog::get_drag_data_fw); + ClassDB::bind_method("can_drop_data_fw",&ProjectExportDialog::can_drop_data_fw); + ClassDB::bind_method("drop_data_fw",&ProjectExportDialog::drop_data_fw); + ClassDB::bind_method("_export_type_changed",&ProjectExportDialog::_export_type_changed); + ClassDB::bind_method("_filter_changed",&ProjectExportDialog::_filter_changed); + ClassDB::bind_method("_tree_changed",&ProjectExportDialog::_tree_changed); + ClassDB::bind_method("_patch_button_pressed",&ProjectExportDialog::_patch_button_pressed); + ClassDB::bind_method("_patch_selected",&ProjectExportDialog::_patch_selected); + ClassDB::bind_method("_patch_deleted",&ProjectExportDialog::_patch_deleted); + ClassDB::bind_method("_patch_edited",&ProjectExportDialog::_patch_edited); + ClassDB::bind_method("_export_pck_zip",&ProjectExportDialog::_export_pck_zip); + ClassDB::bind_method("_export_pck_zip_selected",&ProjectExportDialog::_export_pck_zip_selected); + + +} +ProjectExportDialog::ProjectExportDialog() { + + HBoxContainer *hbox = memnew( HBoxContainer ); + add_child(hbox); + + VBoxContainer *preset_vb = memnew( VBoxContainer ); + preset_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); + hbox->add_child(preset_vb); + + HBoxContainer *preset_hb = memnew( HBoxContainer ); + preset_hb->add_child(memnew(Label(TTR("Presets")))); + preset_hb->add_spacer(); + preset_vb->add_child(preset_hb); + + add_preset = memnew( MenuButton ); + add_preset->set_text(TTR("Add..")); + add_preset->get_popup()->connect("index_pressed",this,"_add_preset"); + preset_hb->add_child(add_preset); + MarginContainer *mc = memnew( MarginContainer ); + preset_vb->add_child(mc); + mc->set_v_size_flags(SIZE_EXPAND_FILL); + presets = memnew( ItemList ); + presets->set_drag_forwarding(this); + mc->add_child(presets); + presets->connect("item_selected",this,"_edit_preset"); + delete_preset = memnew( ToolButton ); + preset_hb->add_child(delete_preset); + delete_preset->connect("pressed",this,"_delete_preset"); + + VBoxContainer *settings_vb = memnew( VBoxContainer ); + settings_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); + hbox->add_child(settings_vb); + + name = memnew(LineEdit); + settings_vb->add_margin_child(TTR("Name:"),name); + name->connect("text_changed",this,"_name_changed"); + runnable = memnew(CheckButton); + runnable->set_text(TTR("Runnable")); + runnable->connect("pressed",this,"_runnable_pressed"); + settings_vb->add_child(runnable); + + sections = memnew (TabContainer ); + settings_vb->add_child(sections); + sections->set_v_size_flags(SIZE_EXPAND_FILL); + + parameters = memnew (PropertyEditor ); + sections->add_child(parameters); + parameters->set_name(TTR("Options")); + parameters->hide_top_label(); + parameters->set_v_size_flags(SIZE_EXPAND_FILL); + parameters->set_hide_script(true); + + VBoxContainer *resources_vb = memnew( VBoxContainer ); + sections->add_child(resources_vb); + resources_vb->set_name(TTR("Resources")); + + export_filter = memnew( OptionButton ); + export_filter->add_item(TTR("Export all resources in the project")); + export_filter->add_item(TTR("Export selected scenes (and dependencies)")); + export_filter->add_item(TTR("Export selected resources (and dependencies)")); + resources_vb->add_margin_child(TTR("Export Mode:"),export_filter); + export_filter->connect("item_selected",this,"_export_type_changed"); + + include_label = memnew( Label ); + include_label->set_text(TTR("Resources to export:")); + resources_vb->add_child(include_label); + include_margin = memnew( MarginContainer ); + include_margin->set_v_size_flags(SIZE_EXPAND_FILL); + resources_vb->add_child(include_margin); + + include_files = memnew(Tree); + include_margin->add_child(include_files); + include_files->connect("item_edited",this,"_tree_changed"); + + include_filters = memnew( LineEdit ); + resources_vb->add_margin_child(TTR("Filters to export non-resource files (comma separated, e.g: *.json, *.txt)"),include_filters); + include_filters->connect("text_changed",this,"_filter_changed"); + + exclude_filters = memnew( LineEdit ); + resources_vb->add_margin_child(TTR("Filters to exclude files from project (comma separated, e.g: *.json, *.txt)"),exclude_filters); + exclude_filters->connect("text_changed",this,"_filter_changed"); + + VBoxContainer *patch_vb = memnew( VBoxContainer ); + sections->add_child(patch_vb); + patch_vb->set_name(TTR("Patches")); + + patches = memnew( Tree ); + patch_vb->add_child(patches); + patches->set_v_size_flags(SIZE_EXPAND_FILL); + patches->set_hide_root(true); + patches->connect("button_pressed",this,"_patch_button_pressed"); + patches->connect("item_edited",this,"_patch_edited"); + patches->set_drag_forwarding(this); + patches->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true); + + HBoxContainer *patches_hb = memnew( HBoxContainer ); + patch_vb->add_child(patches_hb); + patches_hb->add_spacer(); + patch_export = memnew( Button ); + patch_export->set_text(TTR("Make Patch")); + patches_hb->add_child(patch_export); + patches_hb->add_spacer(); + + patch_dialog = memnew( FileDialog ); + patch_dialog->add_filter("*.pck ; Pack File"); + patch_dialog->set_mode(FileDialog::MODE_OPEN_FILE); + patch_dialog->connect("file_selected",this,"_patch_selected"); + add_child(patch_dialog); + + patch_erase = memnew( ConfirmationDialog ); + patch_erase->get_ok()->set_text(TTR("Delete")); + patch_erase->connect("confirmed",this,"_patch_deleted"); + add_child(patch_erase); + + + //disable by default + name->set_editable(false); + runnable->set_disabled(true); + delete_preset->set_disabled(true); + sections->hide(); + parameters->edit(NULL); + + delete_confirm = memnew( ConfirmationDialog ); + add_child(delete_confirm); + delete_confirm->get_ok()->set_text(TTR("Delete")); + delete_confirm->connect("confirmed",this,"_delete_preset_confirm"); updating=false; - error = memnew( AcceptDialog ); - add_child(error); - - confirm = memnew( ConfirmationDialog ); - add_child(confirm); - confirm->connect("confirmed",this,"_confirmed"); - - get_ok()->set_text(TTR("Export PCK/Zip")); - + get_ok()->set_text("Export PCK/Zip"); + export_button = add_button("Export Project",!OS::get_singleton()->get_swap_ok_cancel(),"export"); - expopt="--,Export,Bundle"; + export_pck_zip = memnew( FileDialog ); + export_pck_zip->add_filter("*.zip ; ZIP File"); + export_pck_zip->add_filter("*.pck ; Godot Game Pack"); + export_pck_zip->set_access(FileDialog::ACCESS_FILESYSTEM); + export_pck_zip->set_mode(FileDialog::MODE_SAVE_FILE); + add_child(export_pck_zip); + export_pck_zip->connect("file_selected",this,"_export_pck_zip_selected"); - file_export = memnew( EditorFileDialog ); - add_child(file_export); - file_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - file_export->set_current_dir( EditorSettings::get_singleton()->get("filesystem/directories/default_project_export_path") ); - - file_export->set_title(TTR("Export Project")); - file_export->connect("file_selected", this,"_export_action"); - - file_export_password = memnew( LineEdit ); - file_export_password->set_secret(true); - file_export_password->set_editable(false); - file_export->get_vbox()->add_margin_child(TTR("Password:"),file_export_password); - - pck_export = memnew( EditorFileDialog ); - pck_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - pck_export->set_current_dir( EditorSettings::get_singleton()->get("filesystem/directories/default_project_export_path") ); - pck_export->set_title(TTR("Export Project PCK")); - pck_export->connect("file_selected", this,"_export_action_pck"); - pck_export->add_filter("*.pck ; Data Pack"); - pck_export->add_filter("*.zip ; Zip"); - add_child(pck_export); + set_hide_on_ok(false); - button_export = add_button(TTR("Export.."),!OS::get_singleton()->get_swap_ok_cancel(),"export_pck"); - updating_script=false; - ei="EditorIcons"; - ot="Object"; - pending_update_tree=true; - _create_android_keystore_window(); + editor_icons = "EditorIcons"; } - ProjectExportDialog::~ProjectExportDialog() { } - -void ProjectExport::popup_export() { - - Set<String> presets; - presets.insert("default"); - - List<PropertyInfo> pi; - GlobalConfig::get_singleton()->get_property_list(&pi); - export_preset->clear(); - - for (List<PropertyInfo>::Element *E=pi.front();E;E=E->next()) { - - if (!E->get().name.begins_with("export_presets/")) - continue; - presets.insert(E->get().name.get_slice("/",1)); - } - - for(Set<String>::Element *E=presets.front();E;E=E->next()) { - - export_preset->add_item(E->get()); - } - - - - popup_centered(Size2(300,100)); - - - -} -Error ProjectExport::export_project(const String& p_preset) { - - return OK; - -#if 0 - - String selected=p_preset; - - PoolVector<String> preset_settings = GlobalConfig::get_singleton()->get("export_presets/"+selected); - String preset_path=GlobalConfig::get_singleton()->get("export_presets_path/"+selected); - if (preset_path=="") { - - error->set_text("Export path empty, see export options"); - error->popup_centered_minsize(Size2(300,100)); - ERR_FAIL_V(ERR_INVALID_DATA); - } - - int pc=preset_settings.size(); - - DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - if (d->change_dir(preset_path)!=OK) { - - memdelete(d); - error->set_text("Can't access to export path:\n "+preset_path); - error->popup_centered_minsize(Size2(300,100)); - ERR_FAIL_V(ERR_INVALID_DATA); - } - - if (pc==0) { - memdelete(d); - return OK; - } - if (pc%3 != 0 ) { - memdelete(d); - error->set_text("Corrupted export data.."); - error->popup_centered_minsize(Size2(300,100)); - ERR_EXPLAIN("Corrupted export data..."); - ERR_FAIL_V(ERR_INVALID_DATA); - } - - Map<String,ProjectExportSettings::ItemData> export_action; - - - Map<String,Map<String,String> > remapped_paths; - - Set<String> scene_extensions; - Set<String> resource_extensions; - - { - - List<String> l; - /* - SceneLoader::get_recognized_extensions(&l); - for(List<String>::Element *E=l.front();E;E=E->next()) { - - scene_extensions.insert(E->get()); - } - */ - ResourceLoader::get_recognized_extensions_for_type("",&l); - for(List<String>::Element *E=l.front();E;E=E->next()) { - - resource_extensions.insert(E->get()); - } - } - - Vector<String> names = GlobalConfig::get_singleton()->get_optimizer_presets(); - - //prepare base paths - - for(int i=0;i<pc;i+=3) { - - - String name = preset_settings[i+0]; - String pname=preset_settings[i+1]; - String deps=preset_settings[i+2]; - int idx=1; - if (pname=="") { - pname="copy"; - } else { - - for(int j=0;j<names.size();j++) { - if (pname==names[j]) { - idx=j+2; - break; - } - } - } - - int dep_idx=0; - - for(int j=0;j<ProjectExportSettings::DA_MAX;j++) { - if (ProjectExportSettings::da_string[j]==deps) { - dep_idx=j; - break; - } - } - - if (idx>=0) { - export_action[name].action=idx; - export_action[name].depaction=dep_idx; - } - - } - - - Set<String> bundle_exceptions; - for (Map<String,ProjectExportSettings::ItemData>::Element *E=export_action.front();E;E=E->next()) { - bundle_exceptions.insert(E->key()); - } - - - { - - // find dependencies and add them to export - - Map<String,ProjectExportSettings::ItemData> dependencies; - - for (Map<String,ProjectExportSettings::ItemData>::Element *E=export_action.front();E;E=E->next()) { - - ProjectExportSettings::ItemData &id=E->get(); - - if (id.depaction!=ProjectExportSettings::DA_COPY && id.depaction!=ProjectExportSettings::DA_OPTIMIZE) - continue; //no copy or optimize, go on - List<String> deplist; - ResourceLoader::get_dependencies(E->key(),&deplist); - - while (deplist.size()) { - - String dependency = deplist.front()->get(); - deplist.pop_front(); - if (export_action.has(dependency)) - continue; //taged to export, will not override - if (dependencies.has(dependency)) { - - if (id.action <= dependencies[dependency].action ) - continue; - } - - ProjectExportSettings::ItemData depid; - if (id.depaction==ProjectExportSettings::DA_COPY || id.action==ProjectExportSettings::DA_COPY) - depid.action=ProjectExportSettings::DA_COPY; - else if (id.depaction==ProjectExportSettings::DA_OPTIMIZE) - depid.action=id.action; - depid.depaction=0; - - dependencies[dependency]=depid; - - ResourceLoader::get_dependencies(dependency,&deplist); - } - - - } - - for (Map<String,ProjectExportSettings::ItemData>::Element *E=dependencies.front();E;E=E->next()) { - export_action[E->key()]=E->get(); - } - } - - - - int idx=0; - for (Map<String,ProjectExportSettings::ItemData>::Element *E=export_action.front();E;E=E->next(),idx++) { - - - String path=E->key(); - if (E->get().action==0) - continue; //nothing to do here - String preset; - if (E->get().action==1) - preset=""; - else - preset=names[E->get().action-2]; - - print_line("Exporting "+itos(idx)+"/"+itos(export_action.size())+": "+path); - - String base_dir = GlobalConfig::get_singleton()->localize_path(path.get_base_dir()).replace("\\","/").replace("res://",""); - DirAccess *da=DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - String cwd = d->get_current_dir(); - da->change_dir(cwd); - print_line("base dir: "+base_dir); - String remap_platform="all"; - - for(int j=0;j<base_dir.get_slice_count("/");j++) { - - String p = base_dir.get_slice("/",j); - if (da->change_dir(p)!=OK) { - - Error err = da->make_dir(p); - if (err!=OK) { - memdelete(da); - memdelete(d); - ERR_EXPLAIN("Cannot make dir: "+cwd+"/"+p); - ERR_FAIL_V(ERR_CANT_CREATE); - } - - if (da->change_dir(p)!=OK) { - - memdelete(da); - memdelete(d); - ERR_EXPLAIN("Cannot change to dir: "+cwd+"/"+p); - ERR_FAIL_V(ERR_CANT_CREATE); - } - - } - - cwd=da->get_current_dir(); - } - - memdelete(da); - //cwd is the target dir - - String source_file; - - print_line("Exporting: "+source_file); - bool delete_source=false; - if (preset=="") { - //just copy! - - source_file=path; - delete_source=false; - } else { - - delete_source=true; - //create an optimized source file - - if (!GlobalConfig::get_singleton()->has("optimizer_presets/"+preset)) { - memdelete(d); - ERR_EXPLAIN("Unknown optimizer preset: "+preset); - ERR_FAIL_V(ERR_INVALID_DATA); - } - - - Dictionary dc = GlobalConfig::get_singleton()->get("optimizer_presets/"+preset); - - ERR_FAIL_COND_V(!dc.has("__type__"),ERR_INVALID_DATA); - String type=dc["__type__"]; - - Ref<EditorOptimizedSaver> saver; - - for(int i=0;i<editor_data->get_optimized_saver_count();i++) { - - if (editor_data->get_optimized_saver(i)->get_target_name()==type) { - saver=editor_data->get_optimized_saver(i); - } - } - - if (saver.is_null()) { - memdelete(d); - ERR_EXPLAIN("Preset '"+preset+"' references nonexistent saver: "+type); - ERR_FAIL_COND_V(saver.is_null(),ERR_INVALID_DATA); - } - - List<Variant> keys; - dc.get_key_list(&keys); - - saver->clear(); - - for(List<Variant>::Element *E=keys.front();E;E=E->next()) { - - saver->set(E->get(),dc[E->get()]); - } - - - remap_platform=saver->get_target_platform(); - if (remap_platform=="") - remap_platform="all"; - - - if (resource_extensions.has(path.extension().to_lower())) { - - uint32_t flags=0; - - /* - if (saver->is_bundle_scenes_enabled()) - flags|=Reso::FLAG_BUNDLE_INSTANCED_SCENES; - */ - saver->set_bundle_exceptions(NULL); - if (E->get().depaction>=ProjectExportSettings::DA_BUNDLE) { - flags|=ResourceSaver::FLAG_BUNDLE_RESOURCES; - if (E->get().depaction==ProjectExportSettings::DA_BUNDLE) - saver->set_bundle_exceptions(&bundle_exceptions); - - } - - if (saver->is_remove_editor_data_enabled()) - flags|=ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES; - if (saver->is_big_endian_data_enabled()) - flags|=ResourceSaver::FLAG_SAVE_BIG_ENDIAN; - - RES res = ResourceLoader::load(path); - - if (res.is_null()) { - - memdelete(d); - ERR_EXPLAIN("Error loading resource to optimize: "+path); - ERR_FAIL_V(ERR_INVALID_DATA); - } - - if (saver->is_compress_translations_enabled() && res->get_type()=="Translation") { - - Ref<PHashTranslation> ct = Ref<PHashTranslation>( memnew( PHashTranslation ) ); - ct->generate(res); - res=ct; - } - - - //dst_file=path.get_file(); - //dst_file = cwd+"/"+dst_file.substr(0,dst_file.length()-dst_file.extension().length())+"opt.scn"; - - //String write_file = path.substr(0,path.length()-path.extension().length())+"optimized.res"; - String write_file = path+".opt.res"; - - - print_line("DST RES FILE: "+write_file); - Error err = ResourceSaver::save(write_file,res,flags,saver); - if (err) { - memdelete(d); - ERR_EXPLAIN("Error saving optimized resource: "+write_file); - ERR_FAIL_COND_V(err,ERR_CANT_OPEN); - } - source_file=write_file; - //project_settings->add_remapped_path(src_scene,path,platform); - - } - - - } - - String dst_file; - dst_file=cwd+"/"+source_file.get_file(); - print_line("copying from: "+source_file); - print_line("copying to: "+dst_file); - Error err = d->copy(source_file,dst_file); - - if (delete_source) - d->remove(source_file); - - if (err) { - - - ERR_EXPLAIN("Error copying from: "+source_file+" to "+dst_file+"."); - ERR_FAIL_COND_V(err,err); - } - - String src_remap=path; - String dst_remap=source_file; - print_line("remap from: "+src_remap); - print_line("remap to: "+dst_remap); - if (src_remap!=dst_remap) { - - - remapped_paths[remap_platform][src_remap]=dst_remap; - } - - //do the copy man... - - } - - Map<String,Variant> added_settings; - - - for (Map<String,Map<String,String> >::Element *E=remapped_paths.front();E;E=E->next()) { - - String platform=E->key(); - PoolVector<String> remaps; - for(Map<String,String>::Element *F=E->get().front();F;F=F->next() ) { - - remaps.push_back(F->key()); - remaps.push_back(F->get()); - } - - - - //added_settings["remap/"+platform]=remaps;` - added_settings["remap/"+platform]=Variant(remaps).operator Array(); - } - - String engine_cfg_path=d->get_current_dir()+"/godot.cfg"; - print_line("enginecfg: "+engine_cfg_path); - GlobalConfig::get_singleton()->save_custom(engine_cfg_path,added_settings); - - memdelete(d); - return OK; -#endif -} - -ProjectExport::ProjectExport(EditorData* p_data) { - - editor_data=p_data; - VBoxContainer *vbc = memnew( VBoxContainer ); - add_child(vbc); - //set_child_rect(vbc); - set_title(TTR("Project Export")); - label = memnew( Label ); - label->set_text(TTR("Export Preset:")); - vbc->add_child(label); - export_preset = memnew (OptionButton); - vbc->add_child(export_preset); - get_ok()->set_text(TTR("Export")); - set_hide_on_ok(false); - error = memnew( AcceptDialog ); - add_child(error); - - -} -#endif diff --git a/tools/editor/project_export.h b/tools/editor/project_export.h index c528a23121..c977e90e56 100644 --- a/tools/editor/project_export.h +++ b/tools/editor/project_export.h @@ -35,6 +35,7 @@ #include "scene/gui/label.h" #include "tools/editor/editor_file_dialog.h" #include "scene/gui/button.h" +#include "scene/gui/file_dialog.h" #include "scene/gui/dialogs.h" #include "scene/gui/tab_container.h" #include "os/dir_access.h" @@ -44,203 +45,98 @@ #include "scene/gui/slider.h" #include "tools/editor/editor_file_system.h" #include "property_editor.h" -#include "editor_import_export.h" +#include "editor_export.h" + -#if 0 class EditorNode; class ProjectExportDialog : public ConfirmationDialog { GDCLASS( ProjectExportDialog, ConfirmationDialog ); -public: - enum ExportAction { - ACTION_NONE, - ACTION_COPY, - ACTION_BUNDLE, - ACTION_MAX - - }; - - static const char *da_string[ACTION_MAX]; - private: - EditorNode *editor; - String expopt; - TabContainer *sections; - bool updating_tree; - bool pending_update_tree; - AcceptDialog *error; - ConfirmationDialog *confirm; - ConfirmationDialog *confirm_keystore; - Button *button_reload; - LineEdit *filters, *filters_exclude; - HBoxContainer *plat_errors; - Label *platform_error_string; + MenuButton *add_preset; + Button *delete_preset; + ItemList *presets; - StringName ei; - StringName ot; + LineEdit *name; + PropertyEditor *parameters; + CheckButton *runnable; - Tree * tree; EditorFileDialog *pck_export; EditorFileDialog *file_export; - LineEdit *file_export_password; Button *button_export; - String _delete_attempt; - bool updating; - void _tree_changed(); - void _update_tree(); - - bool _create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_dir); - void _rescan(); - //void _confirmed(); - void _scan_finished(); - - void _validate_platform(); - /////////////////// - - Tree * platforms; - PropertyEditor *platform_options; - - OptionButton *export_mode; - CheckButton *convert_text_scenes; - VBoxContainer *tree_vb; - - VBoxContainer *image_vb; - OptionButton *image_action; - HSlider *image_quality; - SpinBox *image_shrink; - Tree *image_formats; - Vector<TreeItem*> formats; - - LineEdit *group_new_name; - HSlider *group_lossy_quality; - Label *group_new_name_error; - VBoxContainer *group_options; - Tree *groups; - SpinBox *group_shrink; - CheckButton *group_atlas; - OptionButton *group_image_action; - Button *group_add; - Tree *group_images; - LineEdit *group_images_filter; - Button *atlas_preview; - - - AcceptDialog *atlas_preview_dialog; - TextureRect *atlas_preview_frame; - - - VBoxContainer *script_vbox; - OptionButton *script_mode; - LineEdit *script_key; + ConfirmationDialog *delete_confirm; - VBoxContainer *sample_vbox; - OptionButton *sample_mode; - SpinBox *sample_max_hz; - CheckButton *sample_trim; + OptionButton *export_filter; + LineEdit *include_filters; + LineEdit *exclude_filters; + Tree *include_files; - ConfirmationDialog* keystore_create_dialog; - EditorFileDialog* keystore_file_dialog; + Label* include_label; + MarginContainer *include_margin; + StringName editor_icons; - void _export_mode_changed(int p_idx); - void _prop_edited(String what); + Tree *patches; + Button *patch_export; + int patch_index; + FileDialog *patch_dialog; + ConfirmationDialog *patch_erase; - void _update_platform(); - void _update_exporter(); - void _platform_selected(); + Button *export_button; - void _filters_edited(String what); - void _filters_exclude_edited(String what); - void _update_group_tree(); + void _patch_selected(const String& p_path); + void _patch_deleted(); - void _image_filter_changed(String); - bool _update_group_treef(TreeItem *p_parent,EditorFileSystemDirectory *p_dir,const Set<String>& p_extensions,const String& p_groups,const Map<StringName,int>& p_group_index); - void _group_item_edited(); - void _group_atlas_preview(); + void _runnable_pressed(); + void _name_changed(const String& p_string); + void _add_preset(int p_platform); + void _edit_preset(int p_index); + void _delete_preset(); + void _delete_preset_confirm(); + void _update_presets(); + void _export_type_changed(int p_which); + void _filter_changed(const String& p_filter); + void _fill_resource_tree(); + bool _fill_tree(EditorFileSystemDirectory *p_dir,TreeItem *p_item,Ref<EditorExportPreset> ¤t,bool p_only_scenes); + void _tree_changed(); - void _quality_edited(float what); - void _image_export_edited(int what); - void _shrink_edited(float what); - - void _sample_convert_edited(int what); - - void _update_group_list(); - void _select_group(const String& p_by_name); - + void _patch_button_pressed(Object* p_item,int p_column,int p_id); + void _patch_edited(); - String _get_selected_group(); - void _update_group(); - void _group_changed(Variant v); - void _group_selected(); - void _group_add(); - void _group_select_all(); - void _group_select_none(); - void _group_del(Object *item,int p_column, int p_button); - bool updating_script; - void _update_script(); - void _script_edited(Variant v); - void _export_action(const String& p_file); - void _export_action_pck(const String& p_file); - void ok_pressed(); - void custom_action(const String&); - LineEdit* _create_keystore_input(Control* container, const String& p_label, const String& name); - void _create_android_keystore_window(); - void _create_android_keystore(); - bool _check_android_setting(const Ref<EditorExportPlatform>& exporter); - void _check_keystore_path(const String& path); - void _keystore_dir_selected(const String& path); - void _keystore_created(); + Variant get_drag_data_fw(const Point2& p_point,Control* p_from); + bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const; + void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from); - void _save_export_cfg(); - void _format_toggled(); + FileDialog *export_pck_zip; + void _export_pck_zip(); + void _export_pck_zip_selected(const String& p_path); protected: void _notification(int p_what); static void _bind_methods(); public: - String get_selected_path() const; - - Error export_platform(const String& p_platform, const String& p_path, bool p_debug,const String& p_password,bool p_quit_after=false); - void popup_export(); - ProjectExportDialog(EditorNode *p_editor); + + ProjectExportDialog(); ~ProjectExportDialog(); }; -class EditorData; -class ProjectExport : public ConfirmationDialog { - GDCLASS( ProjectExport, ConfirmationDialog ); - - EditorData *editor_data; - - AcceptDialog *error; - Label *label; - OptionButton *export_preset; -public: - - Error export_project(const String& p_preset); - void popup_export(); - - - ProjectExport(EditorData* p_data); - -}; #endif // PROJECT_EXPORT_SETTINGS_H -#endif + diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp index 99afe9f3a1..ed3c59cc4a 100644 --- a/tools/editor/project_settings.cpp +++ b/tools/editor/project_settings.cpp @@ -29,7 +29,7 @@ #include "project_settings.h" #include "scene/gui/tab_container.h" -#include "globals.h" +#include "global_config.h" #include "os/keyboard.h" #include "editor_node.h" #include "scene/gui/margin_container.h" @@ -242,7 +242,7 @@ void ProjectSettings::_device_input_add() { undo_redo->add_undo_method(this,"_settings_changed"); undo_redo->commit_action(); - _show_last_added(ie); + _show_last_added(ie, name); } @@ -279,12 +279,14 @@ void ProjectSettings::_press_a_key_confirm() { undo_redo->add_undo_method(this,"_settings_changed"); undo_redo->commit_action(); - _show_last_added(ie); + _show_last_added(ie, name); } -void ProjectSettings::_show_last_added(const InputEvent& p_event) { +void ProjectSettings::_show_last_added(const InputEvent& p_event, const String &p_name) { TreeItem *r = input_editor->get_root(); + String name = p_name; + name.erase(0,6); if (!r) return; r=r->get_children(); @@ -292,6 +294,10 @@ void ProjectSettings::_show_last_added(const InputEvent& p_event) { return; bool found = false; while(r){ + if (r->get_text(0) != name) { + r=r->get_next(); + continue; + } TreeItem *child = r->get_children(); while(child){ Variant input = child->get_meta("__input"); @@ -377,7 +383,7 @@ void ProjectSettings::_add_item(int p_item){ } break; case InputEvent::JOYPAD_BUTTON: { - device_id->set_value(3); + device_id->set_value(0); device_index_label->set_text(TTR("Joypad Button Index:")); device_index->clear(); diff --git a/tools/editor/project_settings.h b/tools/editor/project_settings.h index bb925a5fd9..96ac2e2c11 100644 --- a/tools/editor/project_settings.h +++ b/tools/editor/project_settings.h @@ -111,7 +111,7 @@ class ProjectSettings : public AcceptDialog { void _action_button_pressed(Object* p_obj, int p_column,int p_id); void _wait_for_key(const InputEvent& p_event); void _press_a_key_confirm(); - void _show_last_added(const InputEvent& p_event); + void _show_last_added(const InputEvent& p_event, const String& p_name); void _settings_prop_edited(const String& p_name); void _settings_changed(); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 9a5fff3fb4..19b7b2ce66 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -33,12 +33,12 @@ #include "io/image_loader.h" #include "class_db.h" #include "print_string.h" -#include "globals.h" +#include "global_config.h" #include "scene/resources/font.h" #include "pair.h" #include "scene/scene_string_names.h" #include "editor_settings.h" -#include "editor_import_export.h" +#include "editor_export.h" #include "editor_node.h" #include "multi_node_edit.h" #include "array_property_edit.h" @@ -48,7 +48,7 @@ #include "editor_file_system.h" #include "create_dialog.h" #include "property_selector.h" -#include "globals.h" +#include "global_config.h" void CustomPropertyEditor::_notification(int p_what) { @@ -889,7 +889,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty menu->clear(); menu->set_size(Size2(1,1)); - if (p_name=="script/script" && hint_text=="Script" && owner->cast_to<Node>()) { + if (p_name=="script" && hint_text=="Script" && owner->cast_to<Node>()) { menu->add_icon_item(get_icon("Script","EditorIcons"),TTR("New Script"),OBJ_MENU_NEW_SCRIPT); menu->add_separator(); } else if (hint_text!="") { @@ -3141,7 +3141,7 @@ void PropertyEditor::update_tree() { continue; - if (hide_script && p.name=="script/script") + if (hide_script && p.name=="script") continue; String basename=p.name; @@ -4780,7 +4780,7 @@ void SectionedPropertyEditor::update_category_list() { else if ( !(pi.usage&PROPERTY_USAGE_EDITOR) ) continue; - if (pi.name.find(":")!=-1 || pi.name=="script/script" || pi.name=="resource_name" || pi.name=="resource_path") + if (pi.name.find(":")!=-1 || pi.name=="script" || pi.name=="resource_name" || pi.name=="resource_path") continue; int sp = pi.name.find("/"); if (sp==-1) diff --git a/tools/editor/resources_dock.cpp b/tools/editor/resources_dock.cpp index 5348c8c122..8648361bae 100644 --- a/tools/editor/resources_dock.cpp +++ b/tools/editor/resources_dock.cpp @@ -33,7 +33,7 @@ #include "io/resource_saver.h" #include "editor_settings.h" #include "project_settings.h" -#include "globals.h" +#include "global_config.h" #include "editor_file_system.h" diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index eee4aefce3..4f3700adb5 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -29,7 +29,7 @@ #include "scene_tree_dock.h" #include "editor_node.h" -#include "globals.h" +#include "global_config.h" #include "os/keyboard.h" #include "scene/resources/packed_scene.h" #include "editor_settings.h" diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp index 496d8670eb..dfaa1f645c 100644 --- a/tools/editor/script_create_dialog.cpp +++ b/tools/editor/script_create_dialog.cpp @@ -29,7 +29,7 @@ #include "script_create_dialog.h" #include "script_language.h" -#include "globals.h" +#include "global_config.h" #include "io/resource_saver.h" #include "os/file_access.h" #include "editor_file_system.h" diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index 248eecc1c8..fa33ffe5c7 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -39,7 +39,7 @@ #include "scene/gui/rich_text_label.h" #include "scene/gui/margin_container.h" #include "property_editor.h" -#include "globals.h" +#include "global_config.h" #include "editor_node.h" #include "main/performance.h" #include "editor_profiler.h" diff --git a/tools/editor/settings_config_dialog.cpp b/tools/editor/settings_config_dialog.cpp index cd8403b271..6a62e035ec 100644 --- a/tools/editor/settings_config_dialog.cpp +++ b/tools/editor/settings_config_dialog.cpp @@ -30,7 +30,7 @@ #include "editor_settings.h" #include "scene/gui/margin_container.h" -#include "globals.h" +#include "global_config.h" #include "editor_file_system.h" #include "editor_node.h" #include "os/keyboard.h" |